From: AJ ONeal Date: Wed, 2 Dec 2020 23:31:18 +0000 (-0700) Subject: move serviceman to github releases X-Git-Url: https://git.josue.xyz/?p=webi-installers%2F.git;a=commitdiff_plain;h=bd7309fd6e8009984a6c380a5cc82f30f20584d8 move serviceman to github releases --- diff --git a/serviceman/README.md b/serviceman/README.md index ba9d16b..e050968 100644 --- a/serviceman/README.md +++ b/serviceman/README.md @@ -5,11 +5,7 @@ tagline: | Serviceman: cross-platform service management for Linux, Mac, and Windows. --- -## Updating `serviceman` - -```bash -webi serviceman@stable -``` +To update or switch versions, run `webi serviceman@stable` ## Cheat Sheet diff --git a/serviceman/install.ps1 b/serviceman/install.ps1 new file mode 100644 index 0000000..8c1879f --- /dev/null +++ b/serviceman/install.ps1 @@ -0,0 +1,57 @@ +#!/usr/bin/env pwsh + +###################### +# Install serviceman # +###################### + +# Every package should define these variables +$pkg_cmd_name = "serviceman" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\serviceman.exe" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\serviceman-v$Env:WEBI_VERSION\bin\serviceman.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\serviceman-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\serviceman-v$Env:WEBI_VERSION" +$pkg_src = "$pkg_src_cmd" + +$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE")) +{ + # TODO: arch detection + echo "Downloading serviceman from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & move "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src_cmd")) +{ + echo "Installing serviceman" + + # TODO: create package-specific temp directory + # Enter tmp + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\serviceman-v*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\serviceman.exe" -Recurse -ErrorAction Ignore + + # Unpack archive file into this temporary directory + # Windows BSD-tar handles zip. Imagine that. + echo "Unpacking $pkg_download" + & tar xf "$pkg_download" + + # Settle unpacked archive into place + echo "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory -Force + Move-Item -Path ".\serviceman.exe" -Destination "$pkg_src_bin" + + # Exit tmp + popd +} + +echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" +Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse diff --git a/serviceman/install.sh b/serviceman/install.sh index 06ed1e7..3602521 100644 --- a/serviceman/install.sh +++ b/serviceman/install.sh @@ -1,29 +1,42 @@ #!/bin/bash -{ - +function __init_serviceman() { set -e set -u - # Test if in PATH - set +e - my_serviceman=$(command -v serviceman) - set -e - if [ -n "$my_serviceman" ]; then - if [ "$my_serviceman" != "$HOME/.local/bin/serviceman" ]; then - echo "a serviceman installation (which make take precedence) exists at:" - echo " $my_serviceman" - echo "" - fi - fi - - # Get arch envs, etc - webi_download "https://rootprojects.org/serviceman/dist/$(uname -s)/$(uname -m)/serviceman" "$HOME/Downloads/serviceman" - chmod +x "$HOME/Downloads/serviceman" - mv "$HOME/Downloads/serviceman" "$HOME/.local/bin/" - - # add to ~/.local/bin to PATH, just in case - webi_path_add $HOME/.local/bin # > /dev/null 2> /dev/null - # TODO inform user to add to path, apart from pathman? + ###################### + # Install serviceman # + ###################### + + # Every package should define these 6 variables + pkg_cmd_name="serviceman" + + pkg_dst_cmd="$HOME/.local/bin/serviceman" + pkg_dst="$pkg_dst_cmd" + + pkg_src_cmd="$HOME/.local/opt/serviceman-v$WEBI_VERSION/bin/serviceman" + pkg_src_dir="$HOME/.local/opt/serviceman-v$WEBI_VERSION" + pkg_src="$pkg_src_cmd" + + pkg_install() { + # $HOME/.local/opt/serviceman-v0.8.0/bin + mkdir -p "$pkg_src_bin" + + # mv ./serviceman* "$HOME/.local/opt/serviceman-v0.8.0/bin/serviceman" + mv ./"$pkg_cmd_name"* "$pkg_src_cmd" + + # chmod a+x "$HOME/.local/opt/serviceman-v0.8.0/bin/serviceman" + chmod a+x "$pkg_src_cmd" + } + + pkg_get_current_version() { + # 'serviceman version' has output in this format: + # serviceman v0.8.0 (f3ab547) 2020-12-02T16:19:10-07:00 + # This trims it down to just the version number: + # 0.8.0 + echo "$(serviceman --version 2>/dev/null | head -n 1 | cut -d' ' -f2 | sed 's:^v::')" + } } + +__init_serviceman diff --git a/serviceman/releases.js b/serviceman/releases.js new file mode 100644 index 0000000..4853646 --- /dev/null +++ b/serviceman/releases.js @@ -0,0 +1,18 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'therootcompany'; +var repo = 'serviceman'; + +module.exports = function (request) { + return github(request, owner, repo).then(function (all) { + return all; + }); +}; + +if (module === require.main) { + module.exports(require('@root/request')).then(function (all) { + all = require('../_webi/normalize.js')(all); + console.info(JSON.stringify(all)); + }); +}