diff --git a/hanko/README.md b/hanko/README.md new file mode 100644 index 000000000..1db21d799 --- /dev/null +++ b/hanko/README.md @@ -0,0 +1,14 @@ +--- +title: hanko +homepage: https://github.com/SRv6d/hanko +tagline: | + Keeps your allowed signers file up to date. +--- + +## Add your first allowed signer + +```sh +$ hanko signer add octocat octocat@github.com +Updated configuration file ~/.config/hanko/config.toml +Updated allowed signers file ~/.config/git/allowed_signers in 105.315473ms +``` diff --git a/hanko/install.ps1 b/hanko/install.ps1 new file mode 100644 index 000000000..34f91635e --- /dev/null +++ b/hanko/install.ps1 @@ -0,0 +1,54 @@ +#!/usr/bin/env pwsh + +################### +# Install hanko # +################### + +# Every package should define these variables +$pkg_cmd_name = "rg" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\hanko.exe" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\hanko-v$Env:WEBI_VERSION\bin\hanko.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\hanko-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\hanko-v$Env:WEBI_VERSION" +$pkg_src = "$pkg_src_cmd" + +New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | Out-Null +$pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE" + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) { + Write-Output "Downloading hanko from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & Move-Item "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src_cmd")) { + Write-Output "Installing hanko" + + # Enter tmp + Push-Location .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\hanko-v*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\hanko.exe" -Recurse -ErrorAction Ignore + + # Unpack archive file into this temporary directory + # Windows BSD-tar handles zip. Imagine that. + Write-Output "Unpacking $pkg_download" + & tar xf "$pkg_download" + + # Settle unpacked archive into place + Write-Output "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory -Force | Out-Null + Move-Item -Path ".\hanko-*\hanko.exe" -Destination "$pkg_src_bin" + + # Exit tmp + Pop-Location +} + +Write-Output "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" +Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | Out-Null +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse diff --git a/hanko/install.sh b/hanko/install.sh new file mode 100644 index 000000000..545116f1f --- /dev/null +++ b/hanko/install.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# shellcheck disable=SC2034 + +__init_hanko() { + set -e + set -u + + ################## + # Install hanko # + ################## + + # Every package should define these 6 variables + pkg_cmd_name="hanko" + + pkg_dst_cmd="${HOME}/.local/bin/hanko" + pkg_dst="${pkg_dst_cmd}" + + pkg_src_cmd="${HOME}/.local/opt/hanko-v${WEBI_VERSION}/bin/hanko" + pkg_src_dir="${HOME}/.local/opt/hanko-v${WEBI_VERSION}" + pkg_src="${pkg_src_cmd}" + + pkg_install() { + # $HOME/.local/opt/hanko-v1.0.1/bin + mkdir -p "$(dirname "${pkg_src_cmd}")" + + # mv ./hanko* "$HOME/.local/opt/hanko-v1.0.1/bin/hanko" + mv ./"${pkg_cmd_name}"* "${pkg_src_cmd}" + + # chmod a+x "$HOME/.local/opt/hanko-v1.0.1/bin/hanko" + chmod a+x "${pkg_src_cmd}" + } + + pkg_get_current_version() { + # 'hanko --version' has output in this format: + # hanko 0.5.1 + # This trims it down to just the version number: + # 0.5.1 + hanko --version 2> /dev/null | head -n 1 | cut -d ' ' -f 2 + } + +} + +__init_hanko diff --git a/hanko/releases.js b/hanko/releases.js new file mode 100644 index 000000000..9825e4b54 --- /dev/null +++ b/hanko/releases.js @@ -0,0 +1,18 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'SRv6d'; +var repo = 'hanko'; + +module.exports = function () { + return github(null, owner, repo).then(function (all) { + return all; + }); +}; + +if (module === require.main) { + module.exports().then(function (all) { + all = require('../_webi/normalize.js')(all); + console.info(JSON.stringify(all)); + }); +}