move serviceman to github releases

This commit is contained in:
AJ ONeal
2020-12-02 16:31:18 -07:00
parent 9aa31c5167
commit bd7309fd6e
4 changed files with 109 additions and 25 deletions
+1 -5
View File
@@ -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
+57
View File
@@ -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
+33 -20
View File
@@ -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
######################
# Install serviceman #
######################
# 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/"
# Every package should define these 6 variables
pkg_cmd_name="serviceman"
# 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?
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
+18
View File
@@ -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));
});
}