Skip to content

Commit c4dd886

Browse files
author
R. S. Doiel
committed
Quick Save
1 parent e752b8a commit c4dd886

File tree

2 files changed

+45
-19
lines changed

2 files changed

+45
-19
lines changed

installer.ps1

+28-14
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@
44
#
55
# Set the package name and version to install
66
#
7+
param(
8+
[Parameter()]
9+
[String]$VERSION = "1.2.9"
10+
)
11+
[String]$PKG_VERSION = [Environment]::GetEnvironmentVariable("PKG_VERSION")
12+
if ($PKG_VERSION) {
13+
$VERSION = "${PKG_VERSION}"
14+
Write-Output "Using '${PKG_VERSION}' for version value '${VERSION}'"
15+
}
16+
717
$PACKAGE = "datatools"
8-
$VERSION = "1.2.9"
918
$GIT_GROUP = "caltechlibrary"
1019
$RELEASE = "https://github.com/${GIT_GROUP}/${PACKAGE}/releases/tag/v${VERSION}"
1120
$SYSTEM_TYPE = Get-ComputerInfo -Property CsSystemType
@@ -15,34 +24,39 @@ if ($SYSTEM_TYPE.CsSystemType.Contains("ARM64")) {
1524
$MACHINE = "x86_64"
1625
}
1726

27+
1828
# FIGURE OUT Install directory
1929
$BIN_DIR = "${Home}\bin"
20-
Write-Output "${PACKAGE} will be installed in ${BIN_DIR}"
30+
Write-Output "${PACKAGE} v${VERSION} will be installed in ${BIN_DIR}"
2131

2232
#
2333
# Figure out what the zip file is named
2434
#
2535
$ZIPFILE = "${PACKAGE}-v${VERSION}-Windows-${MACHINE}.zip"
36+
Write-Output "Fetching Zipfile ${ZIPFILE}"
2637

2738
#
2839
# Check to see if this zip file has been downloaded.
2940
#
3041
$DOWNLOAD_URL = "https://github.com/${GIT_GROUP}/${PACKAGE}/releases/download/v${VERSION}/${ZIPFILE}"
42+
Write-Output "Download URL ${DOWNLOAD_URL}"
3143

3244
if (!(Test-Path $BIN_DIR)) {
3345
New-Item $BIN_DIR -ItemType Directory | Out-Null
3446
}
3547
curl.exe -Lo "${ZIPFILE}" "${DOWNLOAD_URL}"
36-
37-
tar.exe xf "${ZIPFILE}" -C "${Home}"
38-
39-
Remove-Item $ZIPFILE
40-
41-
$User = [System.EnvironmentVariableTarget]::User
42-
$Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
43-
if (!(";${Path};".ToLower() -like "*;${BIN_DIR};*".ToLower())) {
44-
[System.Environment]::SetEnvironmentVariable('Path', "${Path};${BIN_DIR}", $User)
45-
$Env:Path += ";${BIN_DIR}"
48+
#if ([System.IO.File]::Exists($ZIPFILE)) {
49+
if (!(Test-Path $ZIPFILE)) {
50+
Write-Output "Failed to download ${ZIPFILE} from ${DOWNLOAD_URL}"
51+
} else {
52+
tar.exe xf "${ZIPFILE}" -C "${Home}"
53+
#Remove-Item $ZIPFILE
54+
55+
$User = [System.EnvironmentVariableTarget]::User
56+
$Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
57+
if (!(";${Path};".ToLower() -like "*;${BIN_DIR};*".ToLower())) {
58+
[System.Environment]::SetEnvironmentVariable('Path', "${Path};${BIN_DIR}", $User)
59+
$Env:Path += ";${BIN_DIR}"
60+
}
61+
Write-Output "${PACKAGE} was installed successfully to ${BIN_DIR}"
4662
}
47-
48-
Write-Output "${PACKAGE} was installed successfully to ${BIN_DIR}"

installer.sh

+17-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ PACKAGE="datatools"
77
VERSION="1.2.9"
88
GIT_GROUP="caltechlibrary"
99
RELEASE="https://github.com/$GIT_GROUP/$PACKAGE/releases/tag/v$VERSION"
10+
if [ "$PKG_VERSION" != "" ]; then
11+
VERSION="${PKG_VERSION}"
12+
echo "${PKG_VERSION} used for version v${VERSION}"
13+
fi
1014

1115
#
1216
# Get the name of this script.
@@ -27,6 +31,11 @@ case "$OS_NAME" in
2731
;;
2832
esac
2933

34+
if [ "$1" != "" ]; then
35+
VERSION="$1"
36+
echo "Version set to v${VERSION}"
37+
fi
38+
3039
ZIPFILE="$PACKAGE-v$VERSION-$OS_NAME-$MACHINE.zip"
3140

3241
#
@@ -43,14 +52,17 @@ cat<<EOT
4352
4453
EOT
4554

55+
if [ ! -d "$HOME/Downloads" ]; then
56+
mkdir -p "$HOME/Downloads"
57+
fi
4658
if [ ! -f "$HOME/Downloads/$ZIPFILE" ]; then
4759
cat<<EOT
4860
49-
To install $PACKAGE you need to download
61+
To install $PACKAGE you need to download
5062
5163
$ZIPFILE
5264
53-
from
65+
from
5466
5567
$RELEASE
5668
@@ -85,14 +97,14 @@ rm .binfiles.tmp
8597
# Make sure $HOME/bin is in the path
8698
#
8799
case :$PATH: in
88-
*:$HOME/bin:*)
100+
*:$HOME/bin:*)
89101
;;
90102
*)
91103
# shellcheck disable=SC2016
92104
echo 'export PATH="$HOME/bin:$PATH"' >>"$HOME/.bashrc"
93105
# shellcheck disable=SC2016
94106
echo 'export PATH="$HOME/bin:$PATH"' >>"$HOME/.zshrc"
95-
;;
107+
;;
96108
esac
97109

98110
# shellcheck disable=SC2031
@@ -101,7 +113,7 @@ if [ "$EXPLAIN_OS_POLICY" = "no" ]; then
101113
102114
You need to take additional steps to complete installation.
103115
104-
Your operating system security policied needs to "allow"
116+
Your operating system security policied needs to "allow"
105117
running programs from $PACKAGE.
106118
107119
Example: on macOS you can type open the programs in finder.

0 commit comments

Comments
 (0)