diff --git a/_webi/template.ps1 b/_webi/template.ps1 index 3201046..7be7ec8 100644 --- a/_webi/template.ps1 +++ b/_webi/template.ps1 @@ -57,7 +57,10 @@ function webi_add_path } # Run pathman to set up the folder -& "$Env:USERPROFILE\.local\bin\pathman.exe" add ~/.local/bin +if (Test-Path -Path "$Env:USERPROFILE.local\bin\pathman.exe") +{ + & "$Env:USERPROFILE\.local\bin\pathman.exe" add ~/.local/bin +} {{ installer }} diff --git a/_webi/webi-pwsh.ps1 b/_webi/webi-pwsh.ps1 index eaaac85..9962259 100644 --- a/_webi/webi-pwsh.ps1 +++ b/_webi/webi-pwsh.ps1 @@ -52,9 +52,10 @@ IF($Env:WEBI_HOST -eq $null -or $Env:WEBI_HOST -eq "") if (!(Test-Path -Path .local\bin\pathman.exe)) { - & curl.exe -fsSL -A "$Env:WEBI_UA" "$Env:WEBI_HOST/packages/pathman/install.ps1" -o .\.local\tmp\pathman-setup.ps1 - powershell .\.local\tmp\pathman-setup.ps1 - # TODO del .\.local\tmp\pathman-setup.bat + $PATHMAN_URL = "$Env:WEBI_HOST/api/installers/pathman.ps1?formats=zip,exe,tar" + # Invoke-WebRequest -UserAgent "Windows amd64" "$PATHMAN_URL" -OutFile ".\.local\tmp\pathman.install.ps1" + & curl.exe -fsSL -A "$Env:WEBI_UA" "$PATHMAN_URL" -o .\.local\tmp\pathman.install.ps1 + powershell .\.local\tmp\pathman.install.ps1 } # Run pathman to set up the folder diff --git a/pathman/install.bat b/pathman/install.bat deleted file mode 100644 index 67ae251..0000000 --- a/pathman/install.bat +++ /dev/null @@ -1,19 +0,0 @@ -pushd "%userprofile%" || goto :error - IF NOT EXIST .local ( - mkdir .local || goto :error - ) - IF NOT EXIST .local\bin ( - mkdir .local\bin || goto :error - ) - - pushd .local\bin || goto :error - rem TODO %PROCESSOR_ARCH% - powershell $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest "https://rootprojects.org/pathman/dist/windows/amd64/pathman.exe" -OutFile pathman.exe || goto :error - popd || goto :error -popd - -goto :EOF - -:error -echo Failed with error #%errorlevel%. -exit /b %errorlevel% diff --git a/pathman/install.ps1 b/pathman/install.ps1 index 5ec3a4b..26944ca 100644 --- a/pathman/install.ps1 +++ b/pathman/install.ps1 @@ -1,3 +1,60 @@ #!/usr/bin/env pwsh -curl.exe -fsSL -A "$Env:WEBI_UA" "https://rootprojects.org/pathman/dist/windows/amd64/pathman.exe" -o "$Env:USERPROFILE\.local\bin\pathman.exe" +################### +# Install pathman # +################### + +# Every package should define these variables +$pkg_cmd_name = "pathman" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\pathman.exe" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\pathman-v$Env:WEBI_VERSION\bin\pathman.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\pathman-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\pathman-v$Env:WEBI_VERSION" +$pkg_src = "$pkg_src_cmd" + +New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | out-null +$pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE" + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) +{ + echo "Downloading pathman from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & move "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src_cmd")) +{ + echo "Installing pathman" + + # TODO: create package-specific temp directory + # Enter tmp + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\pathman-v*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\pathman.exe" -Recurse -ErrorAction Ignore + + # Unpack archive file into this temporary directory + # Windows BSD-tar handles zip. Imagine that. + echo "Unpacking $pkg_download" + & tar xf "$pkg_download" + + # Settle unpacked archive into place + echo "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory -Force | out-null + Move-Item -Path ".\pathman-v*"-Destination "$pkg_src_cmd" + + # Exit tmp + popd +} + +echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" +Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | out-null +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse + +# for the special case of pathman bootstrapping itself +& "$Env:USERPROFILE\.local\bin\pathman.exe" add ~/.local/bin diff --git a/pathman/releases.js b/pathman/releases.js index 019ca9b..8317779 100644 --- a/pathman/releases.js +++ b/pathman/releases.js @@ -7,6 +7,9 @@ var baseurl = 'https://git.rootprojects.org'; module.exports = function (request) { return github(request, owner, repo, baseurl).then(function (all) { + all.releases = all.releases.filter(function (release) { + return !/debug/.test(release.name); + }); return all; }); };