From 40039867028cefc5c2de4dd19b96d0f043538627 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Thu, 23 Apr 2020 05:51:34 +0300 Subject: [PATCH] switch layout --- builders/build-node.ps1 | 4 +++- builders/nix-node-builder.psm1 | 4 ++++ builders/node-builder.psm1 | 7 ++++++- builders/win-node-builder.psm1 | 4 ++++ helpers/nix-helpers.psm1 | 16 ++++++++++++++++ helpers/win-helpers.psm1 | 16 ++++++++++++++++ 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 helpers/nix-helpers.psm1 create mode 100644 helpers/win-helpers.psm1 diff --git a/builders/build-node.ps1 b/builders/build-node.ps1 index 88d0f43..7213bd7 100644 --- a/builders/build-node.ps1 +++ b/builders/build-node.ps1 @@ -23,9 +23,11 @@ param( [Parameter (Mandatory=$true)][Version] $Version, [Parameter (Mandatory=$true)][string] $Platform, [string] $Architecture = "x64" - ) +Import-Module (Join-Path $PSScriptRoot "../helpers" | Join-Path -ChildPath "nix-helpers.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "../helpers" | Join-Path -ChildPath "win-helpers.psm1") -DisableNameChecking + function Get-NodeBuilder { <# .SYNOPSIS diff --git a/builders/nix-node-builder.psm1 b/builders/nix-node-builder.psm1 index f6da58b..9184469 100644 --- a/builders/nix-node-builder.psm1 +++ b/builders/nix-node-builder.psm1 @@ -40,6 +40,10 @@ class NixNodeBuilder : NodeBuilder { return "${base}/v$($this.Version)/node-v$($this.Version)-$($this.Platform)-$($this.Architecture).tar.gz" } + [void] UnpackBinaries($archivePath) { + Unpack-TarArchive -ArchivePath $archivePath -OutputDirectory $this.ArtifactLocation + } + [void] CreateInstallationScript() { <# .SYNOPSIS diff --git a/builders/node-builder.psm1 b/builders/node-builder.psm1 index 88b2f15..5563598 100644 --- a/builders/node-builder.psm1 +++ b/builders/node-builder.psm1 @@ -15,6 +15,9 @@ class NodeBuilder { .PARAMETER Architecture The architecture with which Node.js should be built. + .PARAMETER TempFolderLocation + The location of temporary files that will be used during Node.js package generation. Using system BUILD_STAGINGDIRECTORY variable value. + .PARAMETER ArtifactLocation The location of generated Node.js artifact. Using system environment BUILD_BINARIESDIRECTORY variable value. @@ -26,6 +29,7 @@ class NodeBuilder { [version] $Version [string] $Platform [string] $Architecture + [string] $TempFolderLocation [string] $ArtifactLocation [string] $InstallationTemplatesLocation @@ -35,6 +39,7 @@ class NodeBuilder { $this.Architecture = $architecture $this.ArtifactLocation = $env:BUILD_BINARIESDIRECTORY + $this.TempFolderLocation = $env:BUILD_STAGINGDIRECTORY $this.InstallationTemplatesLocation = Join-Path -Path $PSScriptRoot -ChildPath "../installers" } @@ -56,7 +61,7 @@ class NodeBuilder { $binariesUri = $this.GetBinariesUri() $targetFilename = [IO.Path]::GetFileName($binariesUri) - $targetFilepath = Join-Path -Path $this.ArtifactLocation -ChildPath $targetFilename + $targetFilepath = Join-Path -Path $this.TempFolderLocation -ChildPath $targetFilename Write-Debug "Download binaries from $binariesUri to $targetFilepath" try { diff --git a/builders/win-node-builder.psm1 b/builders/win-node-builder.psm1 index 2a30752..1329196 100644 --- a/builders/win-node-builder.psm1 +++ b/builders/win-node-builder.psm1 @@ -40,6 +40,10 @@ class WinNodeBuilder : NodeBuilder { return "${base}/v$($this.Version)/node-v$($this.Version)-win-$($this.Architecture).7z" } + [void] UnpackBinaries($archivePath) { + Unpack-7ZipArchive -ArchivePath $archivePath -OutputDirectory $this.ArtifactLocation + } + [void] CreateInstallationScript() { <# .SYNOPSIS diff --git a/helpers/nix-helpers.psm1 b/helpers/nix-helpers.psm1 new file mode 100644 index 0000000..de7a57a --- /dev/null +++ b/helpers/nix-helpers.psm1 @@ -0,0 +1,16 @@ +<# +.SYNOPSIS +Unpack *.tar file +#> +function Unpack-TarArchive { + param( + [Parameter(Mandatory=$true)] + [String]$ArchivePath, + [Parameter(Mandatory=$true)] + [String]$OutputDirectory + ) + + Write-Debug "Unpack $ArchivePath to $OutputDirectory" + tar -C $OutputDirectory -xzf $ArchivePath + +} \ No newline at end of file diff --git a/helpers/win-helpers.psm1 b/helpers/win-helpers.psm1 new file mode 100644 index 0000000..099566f --- /dev/null +++ b/helpers/win-helpers.psm1 @@ -0,0 +1,16 @@ +<# +.SYNOPSIS +Unpack *.7z file +#> +function Unpack-7ZipArchive { + param( + [Parameter(Mandatory=$true)] + [String]$ArchivePath, + [Parameter(Mandatory=$true)] + [String]$OutputDirectory + ) + + Write-Debug "Unpack $ArchivePath to $OutputDirectory" + 7z x $ArchivePath -o$OutputDirectory + +} \ No newline at end of file