diff --git a/bucket/concfg.json b/bucket/concfg.json index 2604ec605..07d6051b4 100644 --- a/bucket/concfg.json +++ b/bucket/concfg.json @@ -2,6 +2,6 @@ "homepage": "https://github.com/lukesampson/concfg", "version": "0.2013.07.01", "url": "https://github.com/lukesampson/concfg/archive/master.zip", - "extract_subdir": "concfg-master", + "extract_dir": "concfg-master", "bin": "bin\\concfg.ps1" } \ No newline at end of file diff --git a/bucket/cowsay.json b/bucket/cowsay.json index d1ce1f76d..90d85e20f 100644 --- a/bucket/cowsay.json +++ b/bucket/cowsay.json @@ -2,6 +2,6 @@ "version": "0.2013.07.19", "homepage": "https://github.com/lukesampson/cowsay-psh", "url": "https://github.com/lukesampson/cowsay-psh/archive/master.zip", - "extract_subdir": "cowsay-psh-master", + "extract_dir": "cowsay-psh-master", "bin": ["cowsay.ps1","cowthink.ps1"] } \ No newline at end of file diff --git a/bucket/curl.json b/bucket/curl.json index 597efed89..e80baa2fb 100644 --- a/bucket/curl.json +++ b/bucket/curl.json @@ -6,7 +6,7 @@ "http://curl.haxx.se/gknw.net/7.30.0/dist-w32/curl-7.30.0-rtmp-ssh2-ssl-sspi-zlib-idn-static-bin-w32.zip", "http://curl.haxx.se/ca/cacert.pem#/curl-ca-bundle.crt" ], - "extract_subdir": "curl-7.30.0-rtmp-ssh2-ssl-sspi-zlib-idn-static-bin-w32", + "extract_dir": "curl-7.30.0-rtmp-ssh2-ssl-sspi-zlib-idn-static-bin-w32", "hash": [ "sha256:90af768c246136c14a2ae52e8775fa4d976eda4632159bc565e1a539b4f15e1a", null diff --git a/bucket/go.json b/bucket/go.json index ffe363f0e..e6e8b87ea 100644 --- a/bucket/go.json +++ b/bucket/go.json @@ -12,7 +12,7 @@ "hash": "sha1:dee46d45e27193c14e07e695aa4c13d7fdc9de9b" } }, - "extract_subdir": "go", + "extract_dir": "go", "add_env_path": "bin", "set_env": { "GOROOT": "$dir" diff --git a/bucket/postgresql.json b/bucket/postgresql.json index d8bd3faf7..225a50e3e 100644 --- a/bucket/postgresql.json +++ b/bucket/postgresql.json @@ -12,7 +12,7 @@ "hash": "sha256:26bd5d1555a3c010b0c58a4aaf5e1acd16bcf819926984f0716496d326768502" } }, - "extract_subdir": "pgsql", + "extract_dir": "pgsql", "bin": [ "bin\\clusterdb.exe", "bin\\createdb.exe", diff --git a/bucket/pshazz.json b/bucket/pshazz.json index 392530025..80f98c5fc 100644 --- a/bucket/pshazz.json +++ b/bucket/pshazz.json @@ -1,6 +1,6 @@ { "version": "0.2013.07.10", "url": "https://github.com/lukesampson/pshazz/archive/master.zip", - "extract_subdir": "pshazz-master", + "extract_dir": "pshazz-master", "bin": [ "bin\\pshazz.ps1" ] } \ No newline at end of file diff --git a/bucket/scriptcs.json b/bucket/scriptcs.json index 116389c48..91f18c256 100644 --- a/bucket/scriptcs.json +++ b/bucket/scriptcs.json @@ -3,7 +3,7 @@ "version": "0.6.0-alpha-130707", "license": "Apache 2.0", "url": "https://www.myget.org/F/scriptcsnightly/api/v2/package/scriptcs/0.6.0-alpha-130707?fn=/dl.zip", - "extract_subdir": "tools\\scriptcs", + "extract_dir": "tools\\scriptcs", "hash": "sha256:d0521827f09813cb3e22402e32a0089cf0b425981f3182568c47811717682750", "bin": "scriptcs.exe" } \ No newline at end of file diff --git a/bucket/vim.json b/bucket/vim.json index e0e6e5de1..477f5e824 100644 --- a/bucket/vim.json +++ b/bucket/vim.json @@ -12,7 +12,7 @@ "md5:e16ec5b633d2f00bf511529e6abf3670", "sha256:f6081071fa95a6f49c049e9d2aed2d2a2632ec47635b4b497a97bab5f5add498" ], - "extract_subdir": "vim\\vim73", + "extract_dir": "vim\\vim73", "bin": [ "vim.exe", "vimtutor.ps1" ], "post_install": "if(!(test-path ~\\.vimrc)) { cp \"$(split-path(scoop which vim))\\vimrc_example.vim\" ~\\.vimrc diff --git a/bucket/winmerge.json b/bucket/winmerge.json index cdc1d288e..714f3c08f 100644 --- a/bucket/winmerge.json +++ b/bucket/winmerge.json @@ -3,6 +3,6 @@ "license": "GPL2", "url": "http://downloads.sourceforge.net/project/winmerge/stable/2.14.0/WinMerge-2.14.0-exe.zip", "hash": "sha256:9c77580ff9594536ce84dbbf0095e4b8654892a713989c378b9349c833c0f177", - "extract_subdir": "WinMerge-2.14.0-exe", + "extract_dir": "WinMerge-2.14.0-exe", "bin": "WinMergeU.exe" } \ No newline at end of file diff --git a/lib/decompress.ps1 b/lib/decompress.ps1 index 2f9f4cb51..c077137b6 100644 --- a/lib/decompress.ps1 +++ b/lib/decompress.ps1 @@ -7,16 +7,15 @@ function requires_7zip($fname) { $fname -match '(\.gz)|(\.tar)|(\.lzma)|(\.7z)$' } -function extract_7zip($path, $recurse) { +function extract_7zip($path, $to, $recurse) { if(!$recurse) { write-host "extracting..." -nonewline } - $dir = split-path $path - $output = 7z x "$path" -o"$dir" + $output = 7z x "$path" -o"$to" if($lastexitcode -ne 0) { abort "exit code was $lastexitcode" } # recursively extract files, e.g. for .tar.gz $output | sls '^Extracting\s+(.*)$' | % { $fname = $_.matches[0].groups[1].value - if(requires_7zip $fname) { extract_7zip "$dir\$fname" $true } + if(requires_7zip $fname) { extract_7zip "$to\$fname" $to $true } } rm $path diff --git a/lib/install.ps1 b/lib/install.ps1 index ff0c91ab2..2bac7ad05 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -69,7 +69,7 @@ function dl_urls($app, $version, $manifest, $architecture, $dir) { write-host "extracting..." -nonewline # use tmp directory and copy so we can prevent 'folder merge' errors when multiple URLs $null = mkdir "$dir\_scoop_unzip" - unzip "$dir\$fname" "$dir\_scoop_unzip" $manifest.extract_subdir + unzip "$dir\$fname" "$dir\_scoop_unzip" (extract_dir $manifest $architecture) cp "$dir\_scoop_unzip\*" "$dir" -recurse -force rm -r -force "$dir\_scoop_unzip" rm "$dir\$fname" @@ -79,7 +79,16 @@ function dl_urls($app, $version, $manifest, $architecture, $dir) { warn "aborting: you'll need to run 'scoop uninstall $app' to clean up" abort "7-zip is required. you can install it with 'scoop install 7zip'" } - extract_7zip "$dir\$fname" $manifest.extract_subdir + $to = $dir + $extract_dir = extract_dir $manifest $architecture + if($extract_dir) { + $to = "$dir\_scoop_extract" + } + extract_7zip "$dir\$fname" $to + if($extract_dir) { + gci "$to\$extract_dir" -r | mv -dest "$dir" -force + rm -r -force "$to" + } } } @@ -342,7 +351,7 @@ function rm_env($manifest) { $manifest.set_env | gm -member noteproperty | % { $name = $_.name; env $name $null - rm env:\$name + if(test-path env:\$name) { rm env:\$name } } } } diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 92e749ebf..b851330b9 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -65,4 +65,5 @@ function url($manifest, $arch) { arch_specific 'url' $manifest $arch } function installer($manifest, $arch) { arch_specific 'installer' $manifest $arch } function uninstaller($manifest, $arch) { arch_specific 'uninstaller' $manifest $arch } function msi($manifest, $arch) { arch_specific 'msi' $manifest $arch } -function hash($manifest, $arch) { arch_specific 'hash' $manifest $arch } \ No newline at end of file +function hash($manifest, $arch) { arch_specific 'hash' $manifest $arch } +function extract_dir($manifest, $arch) { arch_specific 'extract_dir' $manifest $arch} \ No newline at end of file