From: AJ ONeal Date: Fri, 3 Jul 2020 06:18:13 +0000 (+0000) Subject: support bare executables and xbin on windows for jq X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=84965a2207ca49c6e9413749930c6a73d6546088;p=webi-installers%2F.git support bare executables and xbin on windows for jq --- diff --git a/_webi/bootstrap.sh b/_webi/bootstrap.sh index 64cf2c3..877ad81 100644 --- a/_webi/bootstrap.sh +++ b/_webi/bootstrap.sh @@ -53,6 +53,8 @@ fi if [ -n "\$(command -v unzip)" ]; then my_ext="zip,\$my_ext" fi +# for mac/linux 'exe' refers to the uncompressed binary without extension +my_ext="exe,\$my_ext" if [ -n "\$(command -v tar)" ]; then my_ext="tar,\$my_ext" fi diff --git a/_webi/normalize.js b/_webi/normalize.js index df34ad2..3003bb9 100644 --- a/_webi/normalize.js +++ b/_webi/normalize.js @@ -38,8 +38,10 @@ var arches = [ 's390x' ]; var archMap = { - amd64: /(amd.?64|x64|[_\-]64)/i, - x86: /(86)(\b|_)/i, + //amd64: /(amd.?64|x64|[_\-]64)/i, + amd64: /(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)64(\b|_)/i, + //x86: /(86)(\b|_)/i, + x86: /(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)(86|32)(\b|_)/i, ppc64le: /(\b|_)(ppc64le)/i, ppc64: /(\b|_)(ppc64)(\b|_)/i, arm64: /(\b|_)(arm64|arm)/i, @@ -86,8 +88,12 @@ function normalize(all) { // pkg-v1.0.tar.gz => ['gz', 'tar', '0', 'pkg-v1'] // pkg-v1.0.tar => ['tar', '0' ,'pkg-v1'] // pkg-v1.0.zip => ['zip', '0', 'pkg-v1'] - var exts = (rel.name || rel.download).split('.').reverse().slice(0, 2); - var ext; + var exts = (rel.name || rel.download).split('.'); + if (1 === exts.length) { + // for bare releases in the format of foo-linux-amd64 + rel.ext = 'exe'; + } + exts = exts.reverse().slice(0, 2); if ('tar' === exts[1]) { rel.ext = exts.reverse().join('.'); } else if ('tgz' == exts[0]) { @@ -95,6 +101,10 @@ function normalize(all) { } else { rel.ext = exts[0]; } + if (/\-|linux|mac|os[_\-]?x|arm|amd|86|64|mip/i.test(rel.ext)) { + // for bare releases in the format of foo.linux-amd64 + rel.ext = 'exe'; + } } supported.formats[rel.ext] = true; diff --git a/_webi/template.sh b/_webi/template.sh index ed590c1..1f23197 100644 --- a/_webi/template.sh +++ b/_webi/template.sh @@ -180,8 +180,8 @@ webi_extract() { echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE" unzip "$HOME/Downloads/$WEBI_PKG_FILE" > __unzip__.log elif [ "exe" == "$WEBI_EXT" ]; then - # do nothing (but don't leave an empty if block either) - true + echo "Moving $HOME/Downloads/$WEBI_PKG_FILE" + mv "$HOME/Downloads/$WEBI_PKG_FILE" . elif [ "xz" == "$WEBI_EXT" ]; then echo "Inflating $HOME/Downloads/$WEBI_PKG_FILE" unxz -c "$HOME/Downloads/$WEBI_PKG_FILE" > $(basename "$WEBI_PKG_FILE") @@ -268,7 +268,7 @@ if [ -n "$(command -v pkg_get_current_version)" ]; then pkg_dst_cmd="${pkg_dst_cmd:-$HOME/.local/bin/$pkg_cmd_name}" pkg_dst="$pkg_dst_cmd" # "$(dirname "$(dirname $pkg_dst_cmd)")" - pkg_src_cmd="${pkg_src_cmd:-$HOME/.local/xbin/$pkg_cmd_name-$WEBI_VERSION}" + pkg_src_cmd="${pkg_src_cmd:-$HOME/.local/xbin/$pkg_cmd_name-v$WEBI_VERSION}" pkg_src="$pkg_src_cmd" # "$(dirname "$(dirname $pkg_src_cmd)")" else pkg_dst="${pkg_dst:-$HOME/.local/opt/$pkg_cmd_name}" diff --git a/_webi/webi.ps1 b/_webi/webi.ps1 index ebe0a02..7d8de29 100644 --- a/_webi/webi.ps1 +++ b/_webi/webi.ps1 @@ -18,6 +18,10 @@ if (!(Test-Path -Path .local\bin)) { New-Item -Path .local\bin -ItemType Directory } +if (!(Test-Path -Path .local\xbin)) +{ + New-Item -Path .local\xbin -ItemType Directory +} Set-Content -Path .local\bin\webi.bat -Value "@echo off`r`npushd %USERPROFILE%`r`npowershell -ExecutionPolicy Bypass .local\bin\webi.ps1 %1`r`npopd" if (!(Test-Path -Path .local\opt)) { @@ -52,9 +56,10 @@ if (!(Test-Path -Path .local\bin\pathman.exe)) # Fetch .ps1 # TODO detect formats -# Invoke-WebRequest -UserAgent "Windows amd64" "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" -OutFile ".\.local\tmp\$exename.install.ps1" -echo "Downloading $Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" -& curl.exe -fsSL -A "$Env:WEBI_UA" "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" -o .\.local\tmp\$exename.install.ps1 +$PKG_URL = "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,exe,tar" +echo "Downloading $PKG_URL" +# Invoke-WebRequest -UserAgent "Windows amd64" "$PKG_URL" -OutFile ".\.local\tmp\$exename.install.ps1" +& curl.exe -fsSL -A "$Env:WEBI_UA" "$PKG_URL" -o .\.local\tmp\$exename.install.ps1 # Run .ps1 powershell .\.local\tmp\$exename.install.ps1