You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
873 B
PowerShell
41 lines
873 B
PowerShell
5 years ago
|
<#
|
||
|
.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
|
||
|
}
|