X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Farchive%2Flib%2Fpuppet_x%2Fbodeco%2Farchive.rb;h=31dc38616d5848a1f6711be04c6fc6a1d4e163f6;hb=e4cad560b870eff15ff4d562afd0af3d45af78cd;hp=506feb672bd11bd335700284c3b13f25ca8c4514;hpb=ce70d6baf887ae03a2a6a7f5e73eb2e2c3dea208;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/archive/lib/puppet_x/bodeco/archive.rb b/3rdparty/modules/archive/lib/puppet_x/bodeco/archive.rb index 506feb672..31dc38616 100644 --- a/3rdparty/modules/archive/lib/puppet_x/bodeco/archive.rb +++ b/3rdparty/modules/archive/lib/puppet_x/bodeco/archive.rb @@ -7,11 +7,7 @@ module PuppetX class Archive def initialize(file) @file = file - @file_path = if Facter.value(:osfamily) == 'windows' - '"' + file + '"' - else - Shellwords.shellescape file - end + @file_path = Shellwords.shellescape file end def checksum(type) @@ -65,36 +61,6 @@ module PuppetX 'C:\\Program Files\\7-Zip\\7z.exe' elsif File.directory?('C:\\Program Files (x86)\\7-zip') 'C:\\Program Files (x86)\\7-Zip\\7z.exe' - elsif @file_path =~ %r{.zip"$} - # Fallback to powershell for zipfiles - this works with windows - # 2012+ if your powershell/.net is too old the script will fail - # on execution and ask user to install 7zip. - # We have to manually extract each entry in the zip file - # to ensure we extract fresh copy because `ExtractToDirectory` - # method does not support overwriting - ps = <<-END - try { - Add-Type -AssemblyName System.IO.Compression.FileSystem -erroraction "silentlycontinue" - $zipFile = [System.IO.Compression.ZipFile]::openread(#{@file_path}) - foreach ($zipFileEntry in $zipFile.Entries) { - $pwd = (Get-Item -Path ".\" -Verbose).FullName - $outputFile = [io.path]::combine($pwd, $zipFileEntry.FullName) - $dir = ([io.fileinfo]$outputFile).DirectoryName - - if (-not(Test-Path -type Container -path $dir)) { - mkdir $dir - } - if ($zipFileEntry.Name -ne "") { - write-host "[extract] $zipFileEntry.Name" - [System.IO.Compression.ZipFileExtensions]::ExtractToFile($zipFileEntry, $outputFile, $true) - } - } - } catch [System.invalidOperationException] { - write-error "Your OS does not support System.IO.Compression.FileSystem - please install 7zip" - } - END - - "powershell -command #{ps.gsub(%r{"}, '\\"').gsub(%r{\n}, '; ')}" else raise Exception, '7z.exe not available' end @@ -103,8 +69,7 @@ module PuppetX def command(options) if Facter.value(:osfamily) == 'windows' opt = parse_flags('x -aoa', options, '7z') - cmd = win_7zip - cmd =~ %r{7z.exe} ? "#{cmd} #{opt} #{@file_path}" : cmd + "#{win_7zip} #{opt} #{@file_path}" else case @file when %r{\.tar$}