Skip to content

Commit 63e9d5a

Browse files
authored
[PackerBuildV1] Replace decompress-zip with extract-zip (#19576)
1 parent 5b83369 commit 63e9d5a

File tree

71 files changed

+9397
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+9397
-27
lines changed

Diff for: Tasks/PackerBuildV1/_buildConfigs/Node20/package-lock.json

+72
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Tasks/PackerBuildV1/_buildConfigs/Node20/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"azure-pipelines-task-lib": "^4.3.1",
99
"azure-pipelines-tasks-azure-arm-rest": "3.221.2",
1010
"agent-base": "^6.0.2",
11-
"decompress-zip": "^0.3.3"
11+
"decompress-zip": "^0.3.3",
12+
"extract-zip": "2.0.1"
1213
},
1314
"devDependencies": {
1415
"typescript": "5.1.6"

Diff for: Tasks/PackerBuildV1/src/utilities.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ var fs = require('fs');
55
import * as os from "os";
66
import * as path from "path";
77
import * as stream from "stream";
8+
#if NODE20
9+
import * as extract from 'extract-zip'
10+
#else
811
var DecompressZip = require('decompress-zip');
12+
#endif
913
import * as tl from "azure-pipelines-task-lib/task";
1014

1115
// copy source file to destination folder. destination folder will be created if it does not exists, otherwise its contents will be overwritten.
@@ -53,7 +57,14 @@ export async function unzip(zipLocation, unzipLocation): Promise<string> {
5357
if(tl.exist(unzipLocation)) {
5458
tl.rmRF(unzipLocation);
5559
}
56-
60+
#if NODE20
61+
tl.debug(`Using extract-zip package for extracting archive`);
62+
extract(zipLocation, { dir: unzipLocation }).then(() => {
63+
resolve("true");
64+
}).catch((error) => {
65+
reject(error);
66+
});
67+
#else
5768
var unzipper = new DecompressZip(zipLocation);
5869
tl.debug('extracting ' + zipLocation + ' to ' + unzipLocation);
5970
unzipper.on('error', err => reject(err));
@@ -65,6 +76,7 @@ export async function unzip(zipLocation, unzipLocation): Promise<string> {
6576
unzipper.extract({
6677
path: unzipLocation
6778
});
79+
#endif
6880
});
6981

7082
return finishPromise;

Diff for: Tasks/PackerBuildV1/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"author": "Microsoft Corporation",
1515
"version": {
1616
"Major": 1,
17-
"Minor": 231,
17+
"Minor": 236,
1818
"Patch": 0
1919
},
2020
"demands": [],

Diff for: Tasks/PackerBuildV1/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"author": "Microsoft Corporation",
1515
"version": {
1616
"Major": 1,
17-
"Minor": 231,
17+
"Minor": 236,
1818
"Patch": 0
1919
},
2020
"demands": [],

Diff for: _generated/PackerBuildV1.versionmap.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|1.231.0
2-
Node20_229_6|1.231.2
1+
Default|1.236.0
2+
Node20_229_6|1.236.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"variables": {
3+
"client_id": "{{env `client_id`}}",
4+
"client_secret": "{{env `client_secret`}}",
5+
"subscription_id": "{{env `subscription_id`}}",
6+
"tenant_id": "{{env `tenant_id`}}",
7+
"object_id": "{{env `object_id`}}",
8+
"resource_group": "{{env `resource_group`}}",
9+
"storage_account": "{{env `storage_account`}}",
10+
"image_url": "{{env `image_url`}}",
11+
"location": "{{env `location`}}",
12+
"script_relative_path": "{{env `script_relative_path`}}",
13+
"script_arguments": "{{env `script_arguments`}}",
14+
"package_path": "{{env `package_path`}}",
15+
"package_name": "{{env `package_name`}}",
16+
"capture_name_prefix": "{{env `capture_name_prefix`}}",
17+
"skip_clean": "{{env `skip_clean`}}"
18+
},
19+
"builders": [{
20+
"type": "azure-arm",
21+
"client_id": "{{user `client_id`}}",
22+
"client_secret": "{{user `client_secret`}}",
23+
"resource_group_name": "{{user `resource_group`}}",
24+
"storage_account": "{{user `storage_account`}}",
25+
"subscription_id": "{{user `subscription_id`}}",
26+
"tenant_id": "{{user `tenant_id`}}",
27+
"object_id": "{{user `object_id`}}",
28+
29+
"os_type": "Linux",
30+
"image_url": "{{user `image_url`}}",
31+
"location": "{{user `location`}}",
32+
"vm_size": "Standard_D3_v2",
33+
34+
"capture_container_name": "vsts-buildimagetask",
35+
"capture_name_prefix": "{{user `capture_name_prefix`}}"
36+
}],
37+
"provisioners": [{
38+
"type": "shell",
39+
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
40+
"inline": [
41+
"rm -rf /deployTemp",
42+
"mkdir /deployTemp",
43+
"chmod 777 /deployTemp"
44+
]
45+
},
46+
{
47+
"type": "file",
48+
"source": "{{user `package_path`}}",
49+
"destination": "/deployTemp/{{user `package_name`}}"
50+
},
51+
{
52+
"type": "shell",
53+
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
54+
"inline": [
55+
"cd /deployTemp",
56+
"ls",
57+
"chmod +x /deployTemp/{{user `package_name`}}/{{user `script_relative_path`}}",
58+
"/deployTemp/{{user `package_name`}}/{{user `script_relative_path`}} {{user `script_arguments`}}"
59+
]
60+
},
61+
{
62+
"type": "shell",
63+
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
64+
"inline": [
65+
"/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
66+
],
67+
"skip_clean": "{{user `skip_clean`}}"
68+
}]
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"variables": {
3+
"client_id": "{{env `client_id`}}",
4+
"client_secret": "{{env `client_secret`}}",
5+
"subscription_id": "{{env `subscription_id`}}",
6+
"tenant_id": "{{env `tenant_id`}}",
7+
"object_id": "{{env `object_id`}}",
8+
"resource_group": "{{env `resource_group`}}",
9+
"storage_account": "{{env `storage_account`}}",
10+
"image_url": "{{env `image_url`}}",
11+
"location": "{{env `location`}}",
12+
"script_relative_path": "{{env `script_relative_path`}}",
13+
"script_arguments": "{{env `script_arguments`}}",
14+
"package_path": "{{env `package_path`}}",
15+
"package_name": "{{env `package_name`}}",
16+
"capture_name_prefix": "{{env `capture_name_prefix`}}",
17+
"skip_clean": "{{env `skip_clean`}}",
18+
"managed_image_name": "{{env `managed_image_name`}}"
19+
},
20+
"builders": [{
21+
"type": "azure-arm",
22+
"client_id": "{{user `client_id`}}",
23+
"client_secret": "{{user `client_secret`}}",
24+
"managed_image_resource_group_name": "{{user `resource_group`}}",
25+
"managed_image_name": "{{user `managed_image_name`}}",
26+
"subscription_id": "{{user `subscription_id`}}",
27+
"tenant_id": "{{user `tenant_id`}}",
28+
"object_id": "{{user `object_id`}}",
29+
30+
"os_type": "Linux",
31+
"image_url": "{{user `image_url`}}",
32+
"location": "{{user `location`}}",
33+
"vm_size": "Standard_D3_v2"
34+
35+
}],
36+
"provisioners": [{
37+
"type": "shell",
38+
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
39+
"inline": [
40+
"rm -rf /deployTemp",
41+
"mkdir /deployTemp",
42+
"chmod 777 /deployTemp"
43+
]
44+
},
45+
{
46+
"type": "file",
47+
"source": "{{user `package_path`}}",
48+
"destination": "/deployTemp/{{user `package_name`}}"
49+
},
50+
{
51+
"type": "shell",
52+
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
53+
"inline": [
54+
"cd /deployTemp",
55+
"ls",
56+
"chmod +x /deployTemp/{{user `package_name`}}/{{user `script_relative_path`}}",
57+
"/deployTemp/{{user `package_name`}}/{{user `script_relative_path`}} {{user `script_arguments`}}"
58+
]
59+
},
60+
{
61+
"type": "shell",
62+
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
63+
"inline": [
64+
"/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
65+
],
66+
"skip_clean": "{{user `skip_clean`}}"
67+
}]
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"variables": {
3+
"client_id": "{{env `client_id`}}",
4+
"client_secret": "{{env `client_secret`}}",
5+
"subscription_id": "{{env `subscription_id`}}",
6+
"tenant_id": "{{env `tenant_id`}}",
7+
"object_id": "{{env `object_id`}}",
8+
"resource_group": "{{env `resource_group`}}",
9+
"storage_account": "{{env `storage_account`}}",
10+
"image_url": "{{env `image_url`}}",
11+
"location": "{{env `location`}}",
12+
"script_relative_path": "{{env `script_relative_path`}}",
13+
"script_arguments": "{{env `script_arguments`}}",
14+
"package_path": "{{env `package_path`}}",
15+
"package_name": "{{env `package_name`}}",
16+
"capture_name_prefix": "{{env `capture_name_prefix`}}",
17+
"managed_image_name": "{{env `managed_image_name`}}"
18+
},
19+
"builders": [{
20+
"type": "azure-arm",
21+
"client_id": "{{user `client_id`}}",
22+
"client_secret": "{{user `client_secret`}}",
23+
"managed_image_resource_group_name": "{{user `resource_group`}}",
24+
"managed_image_name": "{{user `managed_image_name`}}",
25+
"subscription_id": "{{user `subscription_id`}}",
26+
"tenant_id": "{{user `tenant_id`}}",
27+
"object_id": "{{user `object_id`}}",
28+
29+
"os_type": "Windows",
30+
"image_url": "{{user `image_url`}}",
31+
"location": "{{user `location`}}",
32+
"vm_size": "Standard_D3_v2",
33+
34+
"communicator": "winrm",
35+
"winrm_use_ssl": "true",
36+
"winrm_insecure": "true",
37+
"winrm_timeout": "15m",
38+
"winrm_username": "packer"
39+
40+
}],
41+
"provisioners": [{
42+
"type": "windows-shell",
43+
"inline": [
44+
"cmd /c \"if exist c:\\\\DeployTemp rd /s /q c:\\\\DeployTemp\"",
45+
"cmd /c \"mkdir c:\\\\DeployTemp\""
46+
]
47+
},
48+
{
49+
"type": "file",
50+
"source": "{{user `package_path`}}",
51+
"destination": "c:\\DeployTemp"
52+
},
53+
{
54+
"type": "powershell",
55+
"inline": [
56+
"cd \"C:\\DeployTemp\"",
57+
"ls",
58+
"C:\\DeployTemp\\{{user `package_name`}}\\{{user `script_relative_path`}} {{user `script_arguments`}}"
59+
]
60+
},
61+
{
62+
"type": "powershell",
63+
"inline": [
64+
"if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
65+
"& $Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quit /quiet"
66+
]
67+
}]
68+
}

0 commit comments

Comments
 (0)