7 # Every package should define these variables
10 $pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\k9s.exe"
11 $pkg_dst = "$pkg_dst_cmd"
13 $pkg_src_cmd = "$Env:USERPROFILE\.local\opt\k9s-v$Env:WEBI_VERSION\bin\k9s.exe"
14 $pkg_src_bin = "$Env:USERPROFILE\.local\opt\k9s-v$Env:WEBI_VERSION\bin"
15 $pkg_src_dir = "$Env:USERPROFILE\.local\opt\k9s-v$Env:WEBI_VERSION"
16 $pkg_src = "$pkg_src_cmd"
18 $pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
21 IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"))
23 # TODO: arch detection
24 echo "Downloading k9s from $Env:WEBI_PKG_URL to $pkg_download"
25 & curl.exe -A -L "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
26 & move "$pkg_download.part" "$pkg_download"
29 IF (!(Test-Path -Path "$pkg_src_cmd"))
33 # TODO: create package-specific temp directory
37 # Remove any leftover tmp cruft
38 Remove-Item -Path ".\k9s-v*" -Recurse -ErrorAction Ignore
39 Remove-Item -Path ".\k9s.exe" -Recurse -ErrorAction Ignore
41 # Unpack archive file into this temporary directory
42 # Windows BSD-tar handles zip. Imagine that.
43 echo "Unpacking $pkg_download"
44 & tar xf "$pkg_download"
46 # Settle unpacked archive into place
47 echo "Install Location: $pkg_src_cmd"
48 New-Item "$pkg_src_bin" -ItemType Directory -Force | out-null
49 Move-Item -Path "k9s.exe" -Destination "$pkg_src_bin"
55 echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
56 Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | out-null
57 Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
58 Remove-Item -Path "$pkg_src" -Recurse -ErrorAction Ignore