add xz support, add gitea
authorAJ ONeal <coolaj86@gmail.com>
Mon, 8 Jun 2020 03:24:25 +0000 (21:24 -0600)
committerAJ ONeal <coolaj86@gmail.com>
Mon, 8 Jun 2020 03:24:49 +0000 (21:24 -0600)
gitea/install.bash [new file with mode: 0644]
gitea/releases.js [new file with mode: 0644]
webi/bootstrap.bash
webi/template.bash

diff --git a/gitea/install.bash b/gitea/install.bash
new file mode 100644 (file)
index 0000000..63973d4
--- /dev/null
@@ -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 (file)
index 0000000..80eb1bb
--- /dev/null
@@ -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));
+  });
+}
index 61e196ba62ac9becd3e9d7b5cbd9a4a6a0422184..5ddd4fb9b557f65d866564219980c87ad3727034 100644 (file)
@@ -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
 
index 0c6f506e984f842df9611704224b5a4ec3852069..9ea165ed92d80d5bdd5557cabd487296328df97e 100644 (file)
@@ -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"