forked from actions/versions-package-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nix-helpers.psm1
41 lines (35 loc) · 873 Bytes
/
nix-helpers.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<#
.SYNOPSIS
Unpack *.tar file
#>
function Extract-TarArchive {
param(
[Parameter(Mandatory=$true)]
[String]$ArchivePath,
[Parameter(Mandatory=$true)]
[String]$OutputDirectory
)
Write-Debug "Extract $ArchivePath to $OutputDirectory"
tar -C $OutputDirectory -xzf $ArchivePath --strip 1
}
function Create-TarArchive {
param(
[Parameter(Mandatory=$true)]
[String]$SourceFolder,
[Parameter(Mandatory=$true)]
[String]$ArchivePath,
[string]$CompressionType = "gz",
[switch]$DereferenceSymlinks
)
$arguments = @(
"-c", "--$CompressionType"
)
if ($DereferenceSymlinks) {
$arguments += "-h"
}
$arguments += @("-f", $ArchivePath, ".")
Push-Location $SourceFolder
Write-Debug "tar $arguments"
tar @arguments
Pop-Location
}