Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PackerBuildV1] Replace decompress-zip with extract-zip #19576

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions Tasks/PackerBuildV1/_buildConfigs/Node20/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Tasks/PackerBuildV1/_buildConfigs/Node20/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"azure-pipelines-task-lib": "^4.3.1",
"azure-pipelines-tasks-azure-arm-rest": "3.221.2",
"agent-base": "^6.0.2",
"decompress-zip": "^0.3.3"
"decompress-zip": "^0.3.3",
"extract-zip": "2.0.1"
},
"devDependencies": {
"typescript": "5.1.6"
Expand Down
14 changes: 13 additions & 1 deletion Tasks/PackerBuildV1/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ var fs = require('fs');
import * as os from "os";
import * as path from "path";
import * as stream from "stream";
#if NODE20
import * as extract from 'extract-zip'
#else
var DecompressZip = require('decompress-zip');
#endif
import * as tl from "azure-pipelines-task-lib/task";

// copy source file to destination folder. destination folder will be created if it does not exists, otherwise its contents will be overwritten.
Expand Down Expand Up @@ -53,7 +57,14 @@ export async function unzip(zipLocation, unzipLocation): Promise<string> {
if(tl.exist(unzipLocation)) {
tl.rmRF(unzipLocation);
}

#if NODE20
tl.debug(`Using extract-zip package for extracting archive`);
extract(zipLocation, { dir: unzipLocation }).then(() => {
resolve("true");
}).catch((error) => {
reject(error);
});
#else
var unzipper = new DecompressZip(zipLocation);
tl.debug('extracting ' + zipLocation + ' to ' + unzipLocation);
unzipper.on('error', err => reject(err));
Expand All @@ -65,6 +76,7 @@ export async function unzip(zipLocation, unzipLocation): Promise<string> {
unzipper.extract({
path: unzipLocation
});
#endif
});

return finishPromise;
Expand Down
2 changes: 1 addition & 1 deletion Tasks/PackerBuildV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 231,
"Minor": 236,
"Patch": 0
},
"demands": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/PackerBuildV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 231,
"Minor": 236,
"Patch": 0
},
"demands": [],
Expand Down
4 changes: 2 additions & 2 deletions _generated/PackerBuildV1.versionmap.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Default|1.231.0
Node20_229_6|1.231.2
Default|1.236.0
Node20_229_6|1.236.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"variables": {
"client_id": "{{env `client_id`}}",
"client_secret": "{{env `client_secret`}}",
"subscription_id": "{{env `subscription_id`}}",
"tenant_id": "{{env `tenant_id`}}",
"object_id": "{{env `object_id`}}",
"resource_group": "{{env `resource_group`}}",
"storage_account": "{{env `storage_account`}}",
"image_url": "{{env `image_url`}}",
"location": "{{env `location`}}",
"script_relative_path": "{{env `script_relative_path`}}",
"script_arguments": "{{env `script_arguments`}}",
"package_path": "{{env `package_path`}}",
"package_name": "{{env `package_name`}}",
"capture_name_prefix": "{{env `capture_name_prefix`}}",
"skip_clean": "{{env `skip_clean`}}"
},
"builders": [{
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"resource_group_name": "{{user `resource_group`}}",
"storage_account": "{{user `storage_account`}}",
"subscription_id": "{{user `subscription_id`}}",
"tenant_id": "{{user `tenant_id`}}",
"object_id": "{{user `object_id`}}",

"os_type": "Linux",
"image_url": "{{user `image_url`}}",
"location": "{{user `location`}}",
"vm_size": "Standard_D3_v2",

"capture_container_name": "vsts-buildimagetask",
"capture_name_prefix": "{{user `capture_name_prefix`}}"
}],
"provisioners": [{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
"rm -rf /deployTemp",
"mkdir /deployTemp",
"chmod 777 /deployTemp"
]
},
{
"type": "file",
"source": "{{user `package_path`}}",
"destination": "/deployTemp/{{user `package_name`}}"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
"cd /deployTemp",
"ls",
"chmod +x /deployTemp/{{user `package_name`}}/{{user `script_relative_path`}}",
"/deployTemp/{{user `package_name`}}/{{user `script_relative_path`}} {{user `script_arguments`}}"
]
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
"/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
],
"skip_clean": "{{user `skip_clean`}}"
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"variables": {
"client_id": "{{env `client_id`}}",
"client_secret": "{{env `client_secret`}}",
"subscription_id": "{{env `subscription_id`}}",
"tenant_id": "{{env `tenant_id`}}",
"object_id": "{{env `object_id`}}",
"resource_group": "{{env `resource_group`}}",
"storage_account": "{{env `storage_account`}}",
"image_url": "{{env `image_url`}}",
"location": "{{env `location`}}",
"script_relative_path": "{{env `script_relative_path`}}",
"script_arguments": "{{env `script_arguments`}}",
"package_path": "{{env `package_path`}}",
"package_name": "{{env `package_name`}}",
"capture_name_prefix": "{{env `capture_name_prefix`}}",
"skip_clean": "{{env `skip_clean`}}",
"managed_image_name": "{{env `managed_image_name`}}"
},
"builders": [{
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"managed_image_resource_group_name": "{{user `resource_group`}}",
"managed_image_name": "{{user `managed_image_name`}}",
"subscription_id": "{{user `subscription_id`}}",
"tenant_id": "{{user `tenant_id`}}",
"object_id": "{{user `object_id`}}",

"os_type": "Linux",
"image_url": "{{user `image_url`}}",
"location": "{{user `location`}}",
"vm_size": "Standard_D3_v2"

}],
"provisioners": [{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
"rm -rf /deployTemp",
"mkdir /deployTemp",
"chmod 777 /deployTemp"
]
},
{
"type": "file",
"source": "{{user `package_path`}}",
"destination": "/deployTemp/{{user `package_name`}}"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
"cd /deployTemp",
"ls",
"chmod +x /deployTemp/{{user `package_name`}}/{{user `script_relative_path`}}",
"/deployTemp/{{user `package_name`}}/{{user `script_relative_path`}} {{user `script_arguments`}}"
]
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
"/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
],
"skip_clean": "{{user `skip_clean`}}"
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"variables": {
"client_id": "{{env `client_id`}}",
"client_secret": "{{env `client_secret`}}",
"subscription_id": "{{env `subscription_id`}}",
"tenant_id": "{{env `tenant_id`}}",
"object_id": "{{env `object_id`}}",
"resource_group": "{{env `resource_group`}}",
"storage_account": "{{env `storage_account`}}",
"image_url": "{{env `image_url`}}",
"location": "{{env `location`}}",
"script_relative_path": "{{env `script_relative_path`}}",
"script_arguments": "{{env `script_arguments`}}",
"package_path": "{{env `package_path`}}",
"package_name": "{{env `package_name`}}",
"capture_name_prefix": "{{env `capture_name_prefix`}}",
"managed_image_name": "{{env `managed_image_name`}}"
},
"builders": [{
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"managed_image_resource_group_name": "{{user `resource_group`}}",
"managed_image_name": "{{user `managed_image_name`}}",
"subscription_id": "{{user `subscription_id`}}",
"tenant_id": "{{user `tenant_id`}}",
"object_id": "{{user `object_id`}}",

"os_type": "Windows",
"image_url": "{{user `image_url`}}",
"location": "{{user `location`}}",
"vm_size": "Standard_D3_v2",

"communicator": "winrm",
"winrm_use_ssl": "true",
"winrm_insecure": "true",
"winrm_timeout": "15m",
"winrm_username": "packer"

}],
"provisioners": [{
"type": "windows-shell",
"inline": [
"cmd /c \"if exist c:\\\\DeployTemp rd /s /q c:\\\\DeployTemp\"",
"cmd /c \"mkdir c:\\\\DeployTemp\""
]
},
{
"type": "file",
"source": "{{user `package_path`}}",
"destination": "c:\\DeployTemp"
},
{
"type": "powershell",
"inline": [
"cd \"C:\\DeployTemp\"",
"ls",
"C:\\DeployTemp\\{{user `package_name`}}\\{{user `script_relative_path`}} {{user `script_arguments`}}"
]
},
{
"type": "powershell",
"inline": [
"if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
"& $Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quit /quiet"
]
}]
}
Loading