From: AJ ONeal Date: Mon, 4 May 2020 17:48:03 +0000 (+0000) Subject: nix non-archive caddy and fix \b regexp detection X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=9b6ad3123438f931b12aaf88041db55cafaf4f81;p=webi-installers%2F.git nix non-archive caddy and fix \b regexp detection --- diff --git a/_common/github.js b/_common/github.js index 7b62ea3..ef3a64f 100644 --- a/_common/github.js +++ b/_common/github.js @@ -38,7 +38,7 @@ function getAllReleases( all.releases.push({ name: name, version: release['tag_name'], // TODO tags aren't always semver / sensical - lts: /\b(lts)\b/.test(release['tag_name']), + lts: /(\b|_)(lts)(\b|_)/.test(release['tag_name']), channel: !release['prerelease'] ? 'stable' : 'beta', date: (release['published_at'] || '').replace(/T.*/, ''), os: '', // will be guessed by download filename diff --git a/_common/normalize.js b/_common/normalize.js index f2279d1..f210aa3 100644 --- a/_common/normalize.js +++ b/_common/normalize.js @@ -2,11 +2,12 @@ // this may need customizations between packages const osMap = { - macos: /\b(apple|mac|darwin|iPhone|iOS|iPad)/i, - linux: /\b(linux)/i, - windows: /\b(win|microsoft|msft)/i, - sunos: /\b(sun)/i, - aix: /\b(aix)/i + macos: /(\b|_)(apple|mac|darwin|iPhone|iOS|iPad)/i, + linux: /(\b|_)(linux)/i, + freebsd: /(\b|_)(freebsd)/i, + windows: /(\b|_)(win|microsoft|msft)/i, + sunos: /(\b|_)(sun)/i, + aix: /(\b|_)(aix)/i }; // evaluation order matters @@ -23,13 +24,13 @@ var archArr = [ ]; var archMap = { amd64: /(amd.?64|x64|[_\-]64)/i, - x86: /(86)\b/i, - ppc64le: /\b(ppc64le)/i, - ppc64: /\b(ppc64)\b/i, - arm64: /\b(arm64|arm)/i, - armv7l: /\b(armv?7l)/i, - armv6l: /\b(armv?6l)/i, - s390x: /\b(s390x)/i + x86: /(86)(\b|_)/i, + ppc64le: /(\b|_)(ppc64le)/i, + ppc64: /(\b|_)(ppc64)(\b|_)/i, + arm64: /(\b|_)(arm64|arm)/i, + armv7l: /(\b|_)(armv?7l)/i, + armv6l: /(\b|_)(armv?6l)/i, + s390x: /(\b|_)(s390x)/i }; function normalize(all) { @@ -38,9 +39,10 @@ function normalize(all) { rel.name = rel.download.replace(/.*\//, ''); } if (!rel.os) { + console.log('name:', rel.name); rel.os = Object.keys(osMap).find(function (regKey) { - //console.log('release os:', rel.download, regKey, osMap[regKey]); + console.log('release os:', regKey, osMap[regKey], osMap[regKey].test(rel.name || rel.download), rel.name, rel.download); return osMap[regKey].test(rel.name || rel.download); }) || 'unknown'; } diff --git a/caddy/caddy.bash b/caddy/caddy.bash new file mode 100644 index 0000000..652a05b --- /dev/null +++ b/caddy/caddy.bash @@ -0,0 +1,57 @@ +# title: Caddy +# homepage: https://github.com/caddyserver/caddy +# tagline: Fast, multi-platform web server with automatic HTTPS +# description: | +# Caddy is an extensible server platform that uses TLS by default. +# examples: | +# ```bash +# caddy start +# ``` + +set -e +set -u + +################# +# Install caddy # +################# + +new_caddy="${HOME}/.local/bin/caddy" + +# Test for existing version +set +e +cur_caddy="$(command -v caddy)" +set -e +if [ -n "$cur_caddy" ]; then + cur_ver=$(caddy version | head -n 1 | cut -d ' ' -f 2) + if [ "$cur_ver" == "$WEBI_VERSION" ]; then + echo "caddy v$WEBI_VERSION already installed at $cur_caddy" + exit 0 + elif [ "$cur_caddy" != "$new_caddy" ]; then + echo "WARN: possible conflict with caddy v$WEBI_VERSION at $cur_caddy" + 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 caddy 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 caddy v${WEBI_VERSION} as "$new_caddy" + mv ./caddy-*/caddy "$HOME/.local/bin/" +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 'caddy'" +echo "" diff --git a/caddy/releases.js b/caddy/releases.js index 57c0aee..964f481 100644 --- a/caddy/releases.js +++ b/caddy/releases.js @@ -6,6 +6,10 @@ var repo = 'caddy'; module.exports = function (request) { return github(request, owner, repo).then(function (all) { + // remove checksums and .deb + all.releases = all.releases.filter(function (rel) { + return !/(\.txt)|(\.deb)$/i.test(rel.name); + }); return all; }); }; diff --git a/caddy/rg.bash b/caddy/rg.bash deleted file mode 100644 index 652a05b..0000000 --- a/caddy/rg.bash +++ /dev/null @@ -1,57 +0,0 @@ -# title: Caddy -# homepage: https://github.com/caddyserver/caddy -# tagline: Fast, multi-platform web server with automatic HTTPS -# description: | -# Caddy is an extensible server platform that uses TLS by default. -# examples: | -# ```bash -# caddy start -# ``` - -set -e -set -u - -################# -# Install caddy # -################# - -new_caddy="${HOME}/.local/bin/caddy" - -# Test for existing version -set +e -cur_caddy="$(command -v caddy)" -set -e -if [ -n "$cur_caddy" ]; then - cur_ver=$(caddy version | head -n 1 | cut -d ' ' -f 2) - if [ "$cur_ver" == "$WEBI_VERSION" ]; then - echo "caddy v$WEBI_VERSION already installed at $cur_caddy" - exit 0 - elif [ "$cur_caddy" != "$new_caddy" ]; then - echo "WARN: possible conflict with caddy v$WEBI_VERSION at $cur_caddy" - 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 caddy 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 caddy v${WEBI_VERSION} as "$new_caddy" - mv ./caddy-*/caddy "$HOME/.local/bin/" -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 'caddy'" -echo ""