4
4
#
5
5
# Set the package name and version to install
6
6
#
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
+
7
17
$PACKAGE = " datatools"
8
- $VERSION = " 1.2.9"
9
18
$GIT_GROUP = " caltechlibrary"
10
19
$RELEASE = " https://github.com/${GIT_GROUP} /${PACKAGE} /releases/tag/v${VERSION} "
11
20
$SYSTEM_TYPE = Get-ComputerInfo - Property CsSystemType
@@ -15,34 +24,39 @@ if ($SYSTEM_TYPE.CsSystemType.Contains("ARM64")) {
15
24
$MACHINE = " x86_64"
16
25
}
17
26
27
+
18
28
# FIGURE OUT Install directory
19
29
$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} "
21
31
22
32
#
23
33
# Figure out what the zip file is named
24
34
#
25
35
$ZIPFILE = " ${PACKAGE} -v${VERSION} -Windows-${MACHINE} .zip"
36
+ Write-Output " Fetching Zipfile ${ZIPFILE} "
26
37
27
38
#
28
39
# Check to see if this zip file has been downloaded.
29
40
#
30
41
$DOWNLOAD_URL = " https://github.com/${GIT_GROUP} /${PACKAGE} /releases/download/v${VERSION} /${ZIPFILE} "
42
+ Write-Output " Download URL ${DOWNLOAD_URL} "
31
43
32
44
if (! (Test-Path $BIN_DIR )) {
33
45
New-Item $BIN_DIR - ItemType Directory | Out-Null
34
46
}
35
47
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} "
46
62
}
47
-
48
- Write-Output " ${PACKAGE} was installed successfully to ${BIN_DIR} "
0 commit comments