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