From 7d1cc7b0a291f8612cfffb18e221a3ca06ca1bfb Mon Sep 17 00:00:00 2001 From: "R. S. Doiel" Date: Thu, 11 Jul 2024 08:25:47 -0700 Subject: [PATCH] updated installer generators --- INSTALL.md | 9 +++++++- codemeta-bash-installer.tmpl | 22 ++++++++++++++----- codemeta-ps1-installer.tmpl | 42 ++++++++++++++++++++++++------------ installer.ps1 | 42 ++++++++++++++++++++++++------------ 4 files changed, 81 insertions(+), 34 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index f658135..7dd6d74 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -5,7 +5,7 @@ Installation *skimmer* is a command line program run from a shell like Bash. You can find compiled version in the [releases](https://github.com/rsdoiel/skimmer/releases/latest) -## Quick install with curl +## Quick install with curl or irm The following curl command can be used to run the installer on most POSIX systems. Programs are installed into `$HOME/bin`. `$HOME/bin` will @@ -16,6 +16,13 @@ following. curl https://rsdoiel.github.io/skimmer/installer.sh | sh ~~~ +On Windows you'd use the following command + +~~~ +irm https://rsdoiel.github.io/skimmer/installer.ps1 | iex +~~~ + + ## Compiled version This is generalized instructions for a release. diff --git a/codemeta-bash-installer.tmpl b/codemeta-bash-installer.tmpl index 4612eba..cb21f5d 100644 --- a/codemeta-bash-installer.tmpl +++ b/codemeta-bash-installer.tmpl @@ -7,6 +7,10 @@ PACKAGE="$name$" VERSION="$version$" GIT_GROUP="$git_org_or_person$" RELEASE="https://github.com/$$GIT_GROUP/$$PACKAGE/releases/tag/v$$VERSION" +if [ "$$PKG_VERSION" != "" ]; then + VERSION="$${PKG_VERSION}" + echo "$${PKG_VERSION} used for version v$${VERSION}" +fi # # Get the name of this script. @@ -27,6 +31,11 @@ case "$$OS_NAME" in ;; esac +if [ "$$1" != "" ]; then + VERSION="$$1" + echo "Version set to v$${VERSION}" +fi + ZIPFILE="$$PACKAGE-v$$VERSION-$$OS_NAME-$$MACHINE.zip" # @@ -43,14 +52,17 @@ cat<>"$$HOME/.bashrc" # shellcheck disable=SC2016 echo 'export PATH="$$HOME/bin:$$PATH"' >>"$$HOME/.zshrc" - ;; + ;; esac # shellcheck disable=SC2031 @@ -101,7 +113,7 @@ if [ "$$EXPLAIN_OS_POLICY" = "no" ]; then You need to take additional steps to complete installation. - Your operating system security policied needs to "allow" + Your operating system security policied needs to "allow" running programs from $$PACKAGE. Example: on macOS you can type open the programs in finder. diff --git a/codemeta-ps1-installer.tmpl b/codemeta-ps1-installer.tmpl index b39ce90..3fc0c44 100644 --- a/codemeta-ps1-installer.tmpl +++ b/codemeta-ps1-installer.tmpl @@ -4,8 +4,17 @@ # # Set the package name and version to install # +param( + [Parameter()] + [String]$$VERSION = "$version$" +) +[String]$$PKG_VERSION = [Environment]::GetEnvironmentVariable("PKG_VERSION") +if ($$PKG_VERSION) { + $$VERSION = "$${PKG_VERSION}" + Write-Output "Using '$${PKG_VERSION}' for version value '$${VERSION}'" +} + $$PACKAGE = "$name$" -$$VERSION = "$version$" $$GIT_GROUP = "$git_org_or_person$" $$RELEASE = "https://github.com/$${GIT_GROUP}/$${PACKAGE}/releases/tag/v$${VERSION}" $$SYSTEM_TYPE = Get-ComputerInfo -Property CsSystemType @@ -15,34 +24,39 @@ if ($$SYSTEM_TYPE.CsSystemType.Contains("ARM64")) { $$MACHINE = "x86_64" } + # FIGURE OUT Install directory $$BIN_DIR = "$${Home}\bin" -Write-Output "$${PACKAGE} will be installed in $${BIN_DIR}" +Write-Output "$${PACKAGE} v$${VERSION} will be installed in $${BIN_DIR}" # # Figure out what the zip file is named # $$ZIPFILE = "$${PACKAGE}-v$${VERSION}-Windows-$${MACHINE}.zip" +Write-Output "Fetching Zipfile $${ZIPFILE}" # # Check to see if this zip file has been downloaded. # $$DOWNLOAD_URL = "https://github.com/$${GIT_GROUP}/$${PACKAGE}/releases/download/v$${VERSION}/$${ZIPFILE}" +Write-Output "Download URL $${DOWNLOAD_URL}" if (!(Test-Path $$BIN_DIR)) { New-Item $$BIN_DIR -ItemType Directory | Out-Null } curl.exe -Lo "$${ZIPFILE}" "$${DOWNLOAD_URL}" - -tar.exe xf "$${ZIPFILE}" -C "$${Home}" - -Remove-Item $$ZIPFILE - -$$User = [System.EnvironmentVariableTarget]::User -$$Path = [System.Environment]::GetEnvironmentVariable('Path', $$User) -if (!(";$${Path};".ToLower() -like "*;$${BIN_DIR};*".ToLower())) { - [System.Environment]::SetEnvironmentVariable('Path', "$${Path};$${BIN_DIR}", $$User) - $$Env:Path += ";$${BIN_DIR}" +#if ([System.IO.File]::Exists($$ZIPFILE)) { +if (!(Test-Path $$ZIPFILE)) { + Write-Output "Failed to download $${ZIPFILE} from $${DOWNLOAD_URL}" +} else { + tar.exe xf "$${ZIPFILE}" -C "$${Home}" + #Remove-Item $$ZIPFILE + + $$User = [System.EnvironmentVariableTarget]::User + $$Path = [System.Environment]::GetEnvironmentVariable('Path', $$User) + if (!(";$${Path};".ToLower() -like "*;$${BIN_DIR};*".ToLower())) { + [System.Environment]::SetEnvironmentVariable('Path', "$${Path};$${BIN_DIR}", $$User) + $$Env:Path += ";$${BIN_DIR}" + } + Write-Output "$${PACKAGE} was installed successfully to $${BIN_DIR}" } - -Write-Output "$${PACKAGE} was installed successfully to $${BIN_DIR}" diff --git a/installer.ps1 b/installer.ps1 index 98823ef..47a5ab4 100755 --- a/installer.ps1 +++ b/installer.ps1 @@ -4,8 +4,17 @@ # # Set the package name and version to install # +param( + [Parameter()] + [String]$VERSION = "0.0.13" +) +[String]$PKG_VERSION = [Environment]::GetEnvironmentVariable("PKG_VERSION") +if ($PKG_VERSION) { + $VERSION = "${PKG_VERSION}" + Write-Output "Using '${PKG_VERSION}' for version value '${VERSION}'" +} + $PACKAGE = "skimmer" -$VERSION = "0.0.13" $GIT_GROUP = "rsdoiel" $RELEASE = "https://github.com/${GIT_GROUP}/${PACKAGE}/releases/tag/v${VERSION}" $SYSTEM_TYPE = Get-ComputerInfo -Property CsSystemType @@ -15,34 +24,39 @@ if ($SYSTEM_TYPE.CsSystemType.Contains("ARM64")) { $MACHINE = "x86_64" } + # FIGURE OUT Install directory $BIN_DIR = "${Home}\bin" -Write-Output "${PACKAGE} will be installed in ${BIN_DIR}" +Write-Output "${PACKAGE} v${VERSION} will be installed in ${BIN_DIR}" # # Figure out what the zip file is named # $ZIPFILE = "${PACKAGE}-v${VERSION}-Windows-${MACHINE}.zip" +Write-Output "Fetching Zipfile ${ZIPFILE}" # # Check to see if this zip file has been downloaded. # $DOWNLOAD_URL = "https://github.com/${GIT_GROUP}/${PACKAGE}/releases/download/v${VERSION}/${ZIPFILE}" +Write-Output "Download URL ${DOWNLOAD_URL}" if (!(Test-Path $BIN_DIR)) { New-Item $BIN_DIR -ItemType Directory | Out-Null } curl.exe -Lo "${ZIPFILE}" "${DOWNLOAD_URL}" - -tar.exe xf "${ZIPFILE}" -C "${Home}" - -Remove-Item $ZIPFILE - -$User = [System.EnvironmentVariableTarget]::User -$Path = [System.Environment]::GetEnvironmentVariable('Path', $User) -if (!(";${Path};".ToLower() -like "*;${BIN_DIR};*".ToLower())) { - [System.Environment]::SetEnvironmentVariable('Path', "${Path};${BIN_DIR}", $User) - $Env:Path += ";${BIN_DIR}" +#if ([System.IO.File]::Exists($ZIPFILE)) { +if (!(Test-Path $ZIPFILE)) { + Write-Output "Failed to download ${ZIPFILE} from ${DOWNLOAD_URL}" +} else { + tar.exe xf "${ZIPFILE}" -C "${Home}" + #Remove-Item $ZIPFILE + + $User = [System.EnvironmentVariableTarget]::User + $Path = [System.Environment]::GetEnvironmentVariable('Path', $User) + if (!(";${Path};".ToLower() -like "*;${BIN_DIR};*".ToLower())) { + [System.Environment]::SetEnvironmentVariable('Path', "${Path};${BIN_DIR}", $User) + $Env:Path += ";${BIN_DIR}" + } + Write-Output "${PACKAGE} was installed successfully to ${BIN_DIR}" } - -Write-Output "${PACKAGE} was installed successfully to ${BIN_DIR}"