fix(windows): correctly bootstrap pathman install

This commit is contained in:
AJ ONeal
2023-05-08 20:57:00 +00:00
parent d6757752d5
commit ba4571ec35
5 changed files with 69 additions and 24 deletions
+4 -1
View File
@@ -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 }}
+4 -3
View File
@@ -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
-19
View File
@@ -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%
+58 -1
View File
@@ -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
+3
View File
@@ -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;
});
};