2020-04-23 09:58:18 +00:00
|
|
|
<#
|
|
|
|
.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
|
2020-04-23 15:42:48 +00:00
|
|
|
}
|
2020-04-23 09:58:18 +00:00
|
|
|
|
2020-04-23 15:42:48 +00:00
|
|
|
function Create-TarArchive {
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[String]$SourceFolder,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[String]$ArchivePath,
|
2020-05-29 12:24:03 +00:00
|
|
|
[string]$CompressionType = "gz",
|
|
|
|
[switch]$DereferenceSymlinks
|
2020-04-23 15:42:48 +00:00
|
|
|
)
|
|
|
|
|
2020-05-29 12:24:03 +00:00
|
|
|
$arguments = @(
|
|
|
|
"-c",
|
|
|
|
"-f", $ArchivePath,
|
|
|
|
"."
|
|
|
|
)
|
|
|
|
If ($CompressionType) {
|
|
|
|
$arguments += "--${CompressionType}"
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($DereferenceSymlinks) {
|
|
|
|
$arguments += "-h"
|
|
|
|
}
|
2020-04-23 15:42:48 +00:00
|
|
|
|
|
|
|
Push-Location $SourceFolder
|
2020-05-29 12:24:03 +00:00
|
|
|
Write-Debug "tar $arguments"
|
|
|
|
tar @arguments
|
2020-04-23 15:42:48 +00:00
|
|
|
Pop-Location
|
2020-04-23 09:58:18 +00:00
|
|
|
}
|