Skip to content

Commit

Permalink
updated installer generators
Browse files Browse the repository at this point in the history
  • Loading branch information
R. S. Doiel committed Jul 11, 2024
1 parent 98b0724 commit 7d1cc7b
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 34 deletions.
9 changes: 8 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
22 changes: 17 additions & 5 deletions codemeta-bash-installer.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"

#
Expand All @@ -43,14 +52,17 @@ cat<<EOT
EOT

if [ ! -d "$$HOME/Downloads" ]; then
mkdir -p "$$HOME/Downloads"
fi
if [ ! -f "$$HOME/Downloads/$$ZIPFILE" ]; then
cat<<EOT
To install $$PACKAGE you need to download
To install $$PACKAGE you need to download
$$ZIPFILE
from
from
$$RELEASE
Expand Down Expand Up @@ -85,14 +97,14 @@ rm .binfiles.tmp
# Make sure $$HOME/bin is in the path
#
case :$$PATH: in
*:$$HOME/bin:*)
*:$$HOME/bin:*)
;;
*)
# shellcheck disable=SC2016
echo 'export PATH="$$HOME/bin:$$PATH"' >>"$$HOME/.bashrc"
# shellcheck disable=SC2016
echo 'export PATH="$$HOME/bin:$$PATH"' >>"$$HOME/.zshrc"
;;
;;
esac

# shellcheck disable=SC2031
Expand All @@ -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.
Expand Down
42 changes: 28 additions & 14 deletions codemeta-ps1-installer.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
42 changes: 28 additions & 14 deletions installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"

0 comments on commit 7d1cc7b

Please sign in to comment.