From: AJ ONeal Date: Mon, 8 Jun 2020 03:24:25 +0000 (-0600) Subject: add xz support, add gitea X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=0749de065d9ada0f53efcf27ac9d1f6655954489;p=webi-installers%2F.git add xz support, add gitea --- diff --git a/gitea/install.bash b/gitea/install.bash new file mode 100644 index 0000000..63973d4 --- /dev/null +++ b/gitea/install.bash @@ -0,0 +1,59 @@ +# title: Gitea +# homepage: https://github.com/go-gitea/gitea +# tagline: a modern drop-in grep replacement +# description: | +# `gitea` is a clean, lightweight self-hosted Github alternative, forked from Gogs. Lighter and more user-friendly than Gitlab. +# examples: | +# +# ```bash +# gitea --version +# ``` + +set -e +set -u + +################### +# Install gitea # +################### + +new_gitea="${HOME}/.local/bin/gitea" + +# Test for existing version +set +e +cur_gitea="$(command -v gitea)" +set -e +if [ -n "$cur_gitea" ]; then + cur_ver=$(gitea --version | head -n 1 | cut -d ' ' -f 3) + if [ "$cur_ver" == "$WEBI_VERSION" ]; then + echo "gitea v$WEBI_VERSION already installed at $cur_gitea" + exit 0 + elif [ "$cur_gitea" != "$new_gitea" ]; then + echo "WARN: possible conflict with gitea v$WEBI_VERSION at $cur_gitea" + fi +fi + +# Note: this file is `source`d by the true installer and hence will have the webi functions + +# because we created releases.js we can use webi_download() +# downloads gitea to ~/Downloads +webi_download + +# because this is tar or zip, we can webi_extract() +# extracts to the WEBI_TMP directory, raw (no --strip-prefix) +webi_extract + +pushd "$WEBI_TMP" 2>&1 >/dev/null + echo Installing gitea v${WEBI_VERSION} as "$new_gitea" + mv ./gitea-* "$HOME/.local/bin/gitea" + chmod a+x "$HOME/.local/bin/gitea" +popd 2>&1 >/dev/null + +################### +# Update PATH # +################### + +# TODO get better output from pathman / output the path to add as return to webi bootstrap +webi_path_add "$HOME/.local/bin" + +echo "Installed 'gitea'" +echo "" diff --git a/gitea/releases.js b/gitea/releases.js new file mode 100644 index 0000000..80eb1bb --- /dev/null +++ b/gitea/releases.js @@ -0,0 +1,23 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'go-gitea'; +var repo = 'gitea'; + +module.exports = function (request) { + return github(request, owner, repo).then(function (all) { + // remove checksums and .deb + all.releases = all.releases.filter(function (rel) { + return !/(\.asc)|(\.sha256)|(\.\d-[^\.]*)$/i.test(rel.name); + }); + return all; + }); +}; + +if (module === require.main) { + module.exports(require('@root/request')).then(function (all) { + all = require('../_common/normalize.js')(all); + console.info(JSON.stringify(all)); + //console.info(JSON.stringify(all, null, 2)); + }); +} diff --git a/webi/bootstrap.bash b/webi/bootstrap.bash index 61e196b..5ddd4fb 100644 --- a/webi/bootstrap.bash +++ b/webi/bootstrap.bash @@ -27,15 +27,7 @@ fi my_ext="" set +e -if [ -n "\$(command -v git)" ]; then - my_ext="git,\$my_ext" -fi -if [ -n "\$(command -v tar)" ]; then - my_ext="tar,\$my_ext" -fi -if [ -n "\$(command -v unzip)" ]; then - my_ext="zip,\$my_ext" -fi +# NOTE: the order here is least favorable to most favorable if [ -n "\$(command -v pkgutil)" ]; then my_ext="pkg,\$my_ext" fi @@ -44,6 +36,18 @@ fi # note: could also detect via hdiutil my_ext="dmg,\$my_ext" #fi +if [ -n "\$(command -v git)" ]; then + my_ext="git,\$my_ext" +fi +if [ -n "\$(command -v unzip)" ]; then + my_ext="xz,\$my_ext" +fi +if [ -n "\$(command -v unzip)" ]; then + my_ext="zip,\$my_ext" +fi +if [ -n "\$(command -v tar)" ]; then + my_ext="tar,\$my_ext" +fi my_ext="\$(echo "\$my_ext" | sed 's/,$//')" # nix trailing comma set -e diff --git a/webi/template.bash b/webi/template.bash index 0c6f506..9ea165e 100644 --- a/webi/template.bash +++ b/webi/template.bash @@ -84,6 +84,12 @@ webi_extract() { elif [ "zip" == "$WEBI_EXT" ]; then echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE" unzip "$HOME/Downloads/$WEBI_PKG_FILE" + elif [ "exe" == "$WEBI_EXT" ]; then + # do nothing (but don't leave an empty if block either) + echo -n "" + elif [ "xz" == "$WEBI_EXT" ]; then + echo "Inflating $HOME/Downloads/$WEBI_PKG_FILE" + unxz -c "$HOME/Downloads/$WEBI_PKG_FILE" > $(basename "$WEBI_PKG_FILE") else # do nothing echo "Failed to extract $HOME/Downloads/$WEBI_PKG_FILE"