Compare commits

..

21 Commits

Author SHA1 Message Date
AJ ONeal
fdbcf36859 feat(git): option to install from package manager 2023-12-28 02:03:16 -07:00
AJ ONeal
c6e096e00d f: feat(fish): option to install from package manager 2023-12-28 02:03:16 -07:00
AJ ONeal
08f04711c8 feat(fish): option to install from package manager 2023-12-28 02:03:16 -07:00
AJ ONeal
a9298f6262 fix(ollama-darwin): filter out .app, manually set arch for universal 2023-12-28 02:02:31 -07:00
AJ ONeal
38de94bdcb fix(goreleaser): handle extraneous build term '1' 2023-12-28 02:02:31 -07:00
AJ ONeal
fe50089c1a fix(watchexec): remove 'cli-' prefix from literal version 2023-12-28 02:02:31 -07:00
AJ ONeal
835e0c2582 ref(shellcheck): remove superfluous target matching 2023-12-28 02:02:30 -07:00
AJ ONeal
73b0b27c13 fix(zoxide): remove incorrect arch detection 2023-12-28 02:02:25 -07:00
AJ ONeal
9a3cfbb573 fix(zig): filter out legacy armv6kz (RPi 1) one-off 2023-12-17 03:20:48 -07:00
AJ ONeal
50069182eb fix(pwsh): arch = 'musl' should be libc = 'musl' 2023-12-17 03:20:24 -07:00
AJ ONeal
546aee8fbb ref: releases.js => installers.js 2023-12-12 02:57:03 -07:00
AJ ONeal
7c61a19e20 ref(internal): packages.js => projects.js 2023-12-12 02:57:02 -07:00
AJ ONeal
e92081b08c fix(sd): update for v1 package structure 2023-12-12 02:56:40 -07:00
AJ ONeal
281c004445 ref(webi): show supported OSes, Arches, Libcs & Packages more clearly on error 2023-12-12 02:56:01 -07:00
AJ ONeal
e2300c6999 fix: fn_get_os for bootstrap & install 2023-12-12 01:58:58 -07:00
AJ ONeal
c116cb417f fix: remove extra / in doc url 2023-12-12 01:58:58 -07:00
AJ ONeal
c080b96fcc fix(git-tag): repo => _repo to distinguish from installers 2023-12-12 01:58:57 -07:00
AJ ONeal
e9a473d14a fix(git-tag): circumvent race condition on simultaneous duplicate git clone 2023-12-12 01:58:57 -07:00
AJ ONeal
3966d3adf8 fix(releases): bump timeout to 15s for uncached github requests 2023-12-12 01:44:11 -07:00
AJ ONeal
2fe6824472 chore: bump version to 1.2.8 2023-11-22 10:08:18 -07:00
AJ ONeal
4510a61cf0 fix(envman): split non-portable function.env => function.sh, function.fish 2023-11-22 10:05:12 -07:00
20 changed files with 384 additions and 212 deletions

View File

@@ -6,11 +6,12 @@ var Crypto = require('crypto');
var util = require('util');
var exec = util.promisify(require('child_process').exec);
var Fs = require('node:fs/promises');
var FsSync = require('node:fs');
var Path = require('node:path');
var repoBaseDir = process.env.REPO_BASE_DIR || '';
if (!repoBaseDir) {
repoBaseDir = Path.resolve('./repos');
repoBaseDir = Path.resolve('./_repos');
// for stderr
console.error(`[Warn] REPO_BASE_DIR= not set, ${repoBaseDir}`);
}
@@ -20,8 +21,29 @@ var Repos = {};
Repos.clone = async function (repoPath, gitUrl) {
let uuid = Crypto.randomUUID();
let tmpPath = `${repoPath}.${uuid}.tmp`;
let bakPath = `${repoPath}.${uuid}.dup`;
await exec(`git clone --bare --filter=tree:0 ${gitUrl} ${tmpPath}`);
await Fs.rename(tmpPath, repoPath);
try {
FsSync.accessSync(repoPath);
return;
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
// sync to avoid race conditions
try {
FsSync.renameSync(repoPath, bakPath);
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
FsSync.renameSync(tmpPath, repoPath);
await Fs.rm(bakPath, { force: true, recursive: true });
};
Repos.checkExists = async function (repoPath) {

View File

@@ -27,18 +27,42 @@ fn_show_welcome() { (
echo ""
echo " $(t_attn 'Success')? Star it! $(t_url 'https://github.com/webinstall/webi-installers')"
echo " $(t_attn 'Problem')? Report it: $(t_url 'https://github.com/webinstall/webi-installers/issues')"
echo " $(t_dim "(your system is") $(t_host "$(uname -s)")/$(t_host "$(uname -m)") $(t_dim "with") $(t_host "$(fn_get_libc)") $(t_dim "&") $(t_host "$(fn_get_http_client_name)")$(t_dim ")")"
echo " $(t_dim "(your system is") $(t_host "$(fn_get_os)")/$(t_host "$(uname -m)") $(t_dim "with") $(t_host "$(fn_get_libc)") $(t_dim "&") $(t_host "$(fn_get_http_client_name)")$(t_dim ")")"
sleep 0.2
); }
fn_get_os() { (
# Ex:
# GNU/Linux
# Android
# Linux (often Alpine, musl)
# Darwin
b_os="$(uname -o 2> /dev/null || echo '')"
b_sys="$(uname -s)"
if test -z "${b_os}" || test "${b_os}" = "${b_sys}"; then
# ex: 'Darwin' (and plain, non-GNU 'Linux')
echo "${b_sys}"
return 0
fi
if echo "${b_os}" | grep -q "${b_sys}"; then
# ex: 'GNU/Linux'
echo "${b_os}"
return 0
fi
# ex: 'Android/Linux'
echo "${b_os}/${b_sys}"
); }
fn_get_libc() { (
# Ex:
# musl
# libc
if ldd /bin/ls 2> /dev/null | grep -q 'musl' 2> /dev/null; then
echo 'musl'
elif uname -o | grep -q 'GNU' || uname -s | grep -q 'Linux'; then
elif fn_get_os | grep -q 'GNU|Linux'; then
echo 'gnu'
else
echo 'libc'
@@ -177,9 +201,9 @@ fn_curl() { (
fn_get_target_triple_user_agent() { (
# Ex:
# x86_64/unknown Linux/5.15.107-2-pve gnu
# x86_64/unknown GNU/Linux/5.15.107-2-pve gnu
# arm64/unknown Darwin/22.6.0 libc
echo "$(uname -m)/unknown $(uname -s)/$(uname -r) $(fn_get_libc)"
echo "$(uname -m)/unknown $(fn_get_os)/$(uname -r) $(fn_get_libc)"
); }
fn_download_to_path() { (

View File

@@ -1,36 +1,19 @@
'use strict';
var Installers = module.exports;
var Crypto = require('crypto');
var Fs = require('node:fs/promises');
var path = require('node:path');
var request = require('@root/request');
var _normalize = require('../_webi/normalize.js');
var reInstallTpl = /\s*#?\s*{{ installer }}/;
var Releases = module.exports;
Releases.get = async function (pkgdir) {
let get;
try {
get = require(path.join(pkgdir, 'releases.js'));
} catch (e) {
let err = new Error('no releases.js for', pkgdir.split(/[\/\\]+/).pop());
err.code = 'E_NO_RELEASE';
throw err;
}
let all = await get(request);
return _normalize(all);
};
function padScript(txt) {
return txt.replace(/^/g, ' ');
}
var BAD_SH_RE = /[<>'"`$\\]/;
Releases.renderBash = async function (
Installers.renderBash = async function (
pkgdir,
rel,
{ baseurl, pkg, tag, ver, os = '', arch = '', libc = '', formats },
@@ -90,7 +73,7 @@ Releases.renderBash = async function (
.join(',')
.replace(/'/g, '');
let webiChecksum = await Releases.getWebiShChecksum();
let webiChecksum = await Installers.getWebiShChecksum();
let envReplacements = [
['WEBI_CHECKSUM', webiChecksum],
['WEBI_PKG', webiPkg],
@@ -99,7 +82,7 @@ Releases.renderBash = async function (
['WEBI_ARCH', arch],
['WEBI_LIBC', libc],
['WEBI_TAG', tag],
['WEBI_RELEASES', `${baseurl}/${releaseUrl}`],
['WEBI_RELEASES', `${baseurl}${releaseUrl}`],
['WEBI_CSV', releaseCsv],
['WEBI_VERSION', rel.version],
['WEBI_MAJOR', v.major],
@@ -147,7 +130,7 @@ Releases.renderBash = async function (
return tplTxt;
};
Releases.renderPowerShell = async function (
Installers.renderPowerShell = async function (
pkgdir,
rel,
{ baseurl, pkg, tag, ver, os, arch, libc = '', formats },
@@ -224,7 +207,7 @@ var _webiShMeta = {
checksum: '',
mtime: 0,
};
Releases.getWebiShChecksum = async function () {
Installers.getWebiShChecksum = async function () {
let now = Date.now();
let ago = now - _webiShMeta.updated_at;
if (ago <= _webiShMeta.stale) {

View File

@@ -26,6 +26,7 @@ __bootstrap_webi() {
#PKG_ARCHES=
#PKG_LIBCS=
#PKG_FORMATS=
#PKG_LATEST=
WEBI_PKG_DOWNLOAD=""
WEBI_DOWNLOAD_DIR="${HOME}/Downloads"
if command -v xdg-user-dir > /dev/null; then
@@ -125,8 +126,12 @@ __bootstrap_webi() {
{
echo ""
echo " $(t_err "Error: no '${PKG_NAME:-"Unknown Package"}@${WEBI_TAG:-"Unknown Tag"}' release for '${WEBI_OS:-"Unknown OS"}' (${WEBI_LIBC:-"Unknown Libc"}) on '${WEBI_ARCH:-"Unknown CPU"}' as one of '${WEBI_FORMATS:-"Unknown File Type"}'")"
echo " '$PKG_NAME' is available for '$PKG_OSES' ($PKG_LIBCS) on '$PKG_ARCHES' as one of '$PKG_FORMATS'"
echo " (check that the package name and version are correct)"
echo ""
echo " CPUs: $PKG_ARCHES"
echo " OSes: $PKG_OSES"
echo " libcs: $PKG_LIBCS"
echo " Package Formats: $PKG_FORMATS"
echo " (check that the package name and version are correct)"
echo ""
my_release_url="$(echo "$WEBI_RELEASES" | sed 's:?.*::')"
@@ -533,18 +538,42 @@ fn_show_welcome_back() { (
echo ""
echo " $(t_attn 'Success')? Star it! $(t_url 'https://github.com/webinstall/webi-installers')"
echo " $(t_attn 'Problem')? Report it: $(t_url 'https://github.com/webinstall/webi-installers/issues')"
echo " $(t_dim "(your system is") $(t_host "$(uname -s)")/$(t_host "$(uname -m)") $(t_dim "with") $(t_host "$(fn_get_libc)") $(t_dim "&") $(t_host "$(fn_get_http_client_name)")$(t_dim ")")"
echo " $(t_dim "(your system is") $(t_host "$(fn_get_os)")/$(t_host "$(uname -m)") $(t_dim "with") $(t_host "$(fn_get_libc)") $(t_dim "&") $(t_host "$(fn_get_http_client_name)")$(t_dim ")")"
sleep 0.2
); }
fn_get_os() { (
# Ex:
# GNU/Linux
# Android
# Linux (often Alpine, musl)
# Darwin
b_os="$(uname -o 2> /dev/null || echo '')"
b_sys="$(uname -s)"
if test -z "${b_os}" || test "${b_os}" = "${b_sys}"; then
# ex: 'Darwin' (and plain, non-GNU 'Linux')
echo "${b_sys}"
return 0
fi
if echo "${b_os}" | grep -q "${b_sys}"; then
# ex: 'GNU/Linux'
echo "${b_os}"
return 0
fi
# ex: 'Android/Linux'
echo "${b_os}/${b_sys}"
); }
fn_get_libc() { (
# Ex:
# musl
# libc
if ldd /bin/ls 2> /dev/null | grep -q 'musl' 2> /dev/null; then
echo 'musl'
elif uname -o | grep -q 'GNU' || uname -s | grep -q 'Linux'; then
elif fn_get_os | grep -q 'GNU|Linux'; then
echo 'gnu'
else
echo 'libc'
@@ -683,9 +712,9 @@ fn_curl() { (
fn_get_target_triple_user_agent() { (
# Ex:
# x86_64/unknown Linux/5.15.107-2-pve gnu
# x86_64/unknown GNU/Linux/5.15.107-2-pve gnu
# arm64/unknown Darwin/22.6.0 libc
echo "$(uname -m)/unknown $(uname -s)/$(uname -r) $(fn_get_libc)"
echo "$(uname -m)/unknown $(fn_get_os)/$(uname -r) $(fn_get_libc)"
); }
fn_download_to_path() { (
@@ -853,7 +882,7 @@ fn_envman_init_load_sh() { (
touch -a ~/.config/envman/PATH.env
touch -a ~/.config/envman/ENV.env
touch -a ~/.config/envman/alias.env
touch -a ~/.config/envman/function.env
touch -a ~/.config/envman/function.sh
# ENV first because we may use it in PATH
test -z "\${ENVMAN_LOAD:-}" && . ~/.config/envman/ENV.env
@@ -862,7 +891,7 @@ test -z "\${ENVMAN_LOAD:-}" && . ~/.config/envman/PATH.env
export ENVMAN_LOAD='loaded'
# function first because we may use it in alias
test -z "\${g_envman_load_sh:-}" && . ~/.config/envman/function.env
test -z "\${g_envman_load_sh:-}" && . ~/.config/envman/function.sh
test -z "\${g_envman_load_sh:-}" && . ~/.config/envman/alias.env
g_envman_load_sh='loaded'
@@ -918,14 +947,14 @@ fn_envman_init_load_fish() { (
touch -a ~/.config/envman/PATH.env
touch -a ~/.config/envman/ENV.env
touch -a ~/.config/envman/alias.env
touch -a ~/.config/envman/function.env
touch -a ~/.config/envman/function.fish
not set -q ENVMAN_LOAD; and source ~/.config/envman/ENV.env
not set -q ENVMAN_LOAD; and source ~/.config/envman/PATH.env
set -x ENVMAN_LOAD 'loaded'
not set -q g_envman_load_fish; and source ~/.config/envman/function.env
not set -q g_envman_load_fish; and source ~/.config/envman/function.fish
not set -q g_envman_load_fish; and source ~/.config/envman/alias.env
set -g g_envman_load_fish 'loaded'

View File

@@ -1,96 +0,0 @@
'use strict';
var frontmarker = require('./frontmarker.js');
var fs = require('fs');
var path = require('path');
var pkgs = module.exports;
pkgs.create = function (Pkgs, basepath) {
if (!Pkgs) {
Pkgs = {};
}
if (!basepath) {
basepath = path.join(__dirname, '../');
}
Pkgs.all = function () {
return fs.promises.readdir(basepath).then(function (nodes) {
var items = [];
return nodes
.reduce(function (p, node) {
return p.then(function () {
return pkgs.get(node).then(function (meta) {
if (meta && '_' !== node[0]) {
meta.name = node;
items.push(meta);
}
});
});
}, Promise.resolve())
.then(function () {
return items;
});
});
};
Pkgs.get = function (node) {
return fs.promises.access(path.join(basepath, node)).then(function () {
return Pkgs._get(node);
});
};
Pkgs._get = function (node) {
var curlbash = path.join(basepath, node, 'install.sh');
var readme = path.join(basepath, node, 'README.md');
var winstall = path.join(basepath, node, 'install.ps1');
return Promise.all([
fs.promises
.readFile(readme, 'utf-8')
.then(function (txt) {
// TODO
return frontmarker.parse(txt);
})
.catch(function (e) {
if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
console.error("failed to read '" + node + "/README.md'");
console.error(e);
}
}),
fs.promises.access(curlbash).catch(function (e) {
// no *nix installer
curlbash = '';
if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
console.error("failed to parse '" + node + "/install.sh'");
console.error(e);
}
}),
fs.promises.access(winstall).catch(function (e) {
// no winstaller
winstall = '';
if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
console.error("failed to read '" + node + "/install.ps1'");
console.error(e);
}
}),
]).then(function (items) {
var meta = items[0] || items[1];
if (!meta) {
// doesn't exist
return;
}
meta.windows = !!winstall;
meta.bash = !!curlbash;
return meta;
});
};
return Pkgs;
};
pkgs.create(pkgs);
if (module === require.main) {
pkgs.all().then(function (data) {
console.info('package info:');
console.info(data);
});
}

1
_webi/packages.js Symbolic link
View File

@@ -0,0 +1 @@
projects.js

96
_webi/projects.js Normal file
View File

@@ -0,0 +1,96 @@
'use strict';
var frontmarker = require('./frontmarker.js');
var fs = require('fs');
var path = require('path');
var pkgs = module.exports;
pkgs.create = function (Pkgs, basepath) {
if (!Pkgs) {
Pkgs = {};
}
if (!basepath) {
basepath = path.join(__dirname, '../');
}
Pkgs.all = function () {
return fs.promises.readdir(basepath).then(function (nodes) {
var items = [];
return nodes
.reduce(function (p, node) {
return p.then(function () {
return pkgs.get(node).then(function (meta) {
if (meta && '_' !== node[0]) {
meta.name = node;
items.push(meta);
}
});
});
}, Promise.resolve())
.then(function () {
return items;
});
});
};
Pkgs.get = function (node) {
return fs.promises.access(path.join(basepath, node)).then(function () {
return Pkgs._get(node);
});
};
Pkgs._get = function (node) {
var curlbash = path.join(basepath, node, 'install.sh');
var readme = path.join(basepath, node, 'README.md');
var winstall = path.join(basepath, node, 'install.ps1');
return Promise.all([
fs.promises
.readFile(readme, 'utf-8')
.then(function (txt) {
// TODO
return frontmarker.parse(txt);
})
.catch(function (e) {
if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
console.error("failed to read '" + node + "/README.md'");
console.error(e);
}
}),
fs.promises.access(curlbash).catch(function (e) {
// no *nix installer
curlbash = '';
if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
console.error("failed to parse '" + node + "/install.sh'");
console.error(e);
}
}),
fs.promises.access(winstall).catch(function (e) {
// no winstaller
winstall = '';
if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
console.error("failed to read '" + node + "/install.ps1'");
console.error(e);
}
}),
]).then(function (items) {
var meta = items[0] || items[1];
if (!meta) {
// doesn't exist
return;
}
meta.windows = !!winstall;
meta.bash = !!curlbash;
return meta;
});
};
return Pkgs;
};
pkgs.create(pkgs);
if (module === require.main) {
pkgs.all().then(function (data) {
console.info('package info:');
console.info(data);
});
}

View File

@@ -1,19 +1,19 @@
'use strict';
var Installers = module.exports;
var InstallerServer = module.exports;
var Fs = require('fs/promises');
var path = require('path');
var uaDetect = require('./ua-detect.js');
var packages = require('./packages.js');
var Releases = require('./releases.js');
var Projects = require('./projects.js');
var Installers = require('./installers.js');
// handlers caching and transformation, probably should be broken down
var getReleases = require('./transform-releases.js');
var Releases = require('./transform-releases.js');
Installers.INSTALLERS_DIR = path.join(__dirname, '..');
Installers.serveInstaller = async function (
InstallerServer.INSTALLERS_DIR = path.join(__dirname, '..');
InstallerServer.serveInstaller = async function (
baseurl,
ua,
pkg,
@@ -22,7 +22,7 @@ Installers.serveInstaller = async function (
formats,
libc,
) {
let [rel, opts] = await Installers.helper({
let [rel, opts] = await InstallerServer.helper({
ua,
pkg,
tag,
@@ -33,13 +33,13 @@ Installers.serveInstaller = async function (
baseurl,
});
var pkgdir = path.join(Installers.INSTALLERS_DIR, pkg);
var pkgdir = path.join(InstallerServer.INSTALLERS_DIR, pkg);
if ('ps1' === ext) {
return Releases.renderPowerShell(pkgdir, rel, opts);
return Installers.renderPowerShell(pkgdir, rel, opts);
}
return Releases.renderBash(pkgdir, rel, opts);
return Installers.renderBash(pkgdir, rel, opts);
};
Installers.helper = async function ({ ua, pkg, tag, formats, libc }) {
InstallerServer.helper = async function ({ ua, pkg, tag, formats, libc }) {
// TODO put some of this in a middleware? or common function?
// TODO maybe move package/version/lts/channel detection into getReleases
@@ -84,7 +84,7 @@ Installers.helper = async function ({ ua, pkg, tag, formats, libc }) {
myLibc = 'libc';
}
let cfg = await packages.get(pkg);
let cfg = await Projects.get(pkg);
let releaseQuery = {
pkg: cfg.alias || pkg,
ver,
@@ -99,7 +99,7 @@ Installers.helper = async function ({ ua, pkg, tag, formats, libc }) {
limit: 1,
};
let rels = await getReleases(releaseQuery);
let rels = await Releases.getReleases(releaseQuery);
var rel = rels.releases[0];
var opts = {
@@ -131,11 +131,15 @@ var CURL_PIPE_PS1_BOOT = path.join(__dirname, 'curl-pipe-bootstrap.tpl.ps1');
var CURL_PIPE_SH_BOOT = path.join(__dirname, 'curl-pipe-bootstrap.tpl.sh');
var BAD_SH_RE = /[<>'"`$\\]/;
Installers.getPosixCurlPipeBootstrap = async function ({ baseurl, pkg, ver }) {
InstallerServer.getPosixCurlPipeBootstrap = async function ({
baseurl,
pkg,
ver,
}) {
let bootTxt = await Fs.readFile(CURL_PIPE_SH_BOOT, 'utf8');
var webiPkg = [pkg, ver].filter(Boolean).join('@');
var webiChecksum = await Releases.getWebiShChecksum();
var webiChecksum = await Installers.getWebiShChecksum();
var envReplacements = [
['WEBI_PKG', webiPkg],
['WEBI_HOST', baseurl],
@@ -164,7 +168,7 @@ Installers.getPosixCurlPipeBootstrap = async function ({ baseurl, pkg, ver }) {
return bootTxt;
};
Installers.getPwshCurlPipeBootstrap = async function ({
InstallerServer.getPwshCurlPipeBootstrap = async function ({
baseurl,
pkg,
ver,
@@ -173,7 +177,7 @@ Installers.getPwshCurlPipeBootstrap = async function ({
let bootTxt = await Fs.readFile(CURL_PIPE_PS1_BOOT, 'utf8');
var webiPkg = [pkg, ver].filter(Boolean).join('@');
//var webiChecksum = await Releases.getWebiPs1Checksum();
//var webiChecksum = await InstallerServer.getWebiPs1Checksum();
var envReplacements = [
['Env:WEBI_PKG', webiPkg],
['Env:WEBI_HOST', baseurl],

View File

@@ -32,7 +32,8 @@ if (/\b-?-h(elp)?\b/.test(process.argv.join(' '))) {
var os = require('os');
var fs = require('fs');
var path = require('path');
var Releases = require('./releases.js');
var Releases = require('./transform-releases.js');
var Installers = require('./installers.js');
var ServeInstaller = require('./serve-installer.js');
var pkg = process.argv[2].split('@');
@@ -116,8 +117,8 @@ Releases.get(path.join(process.cwd(), pkgdir)).then(async function (all) {
console.info('');
return Promise.all([
Releases.renderBash(pkgdir, rel, opts).catch(function () {}),
Releases.renderPowerShell(pkgdir, rel, opts).catch(function () {}),
Installers.renderBash(pkgdir, rel, opts).catch(function () {}),
Installers.renderPowerShell(pkgdir, rel, opts).catch(function () {}),
]).then(function (scripts) {
var bashTxt = scripts[0];
var ps1Txt = scripts[1];

View File

@@ -1,7 +1,10 @@
'use strict';
var Releases = module.exports;
var path = require('path');
var Releases = require('./releases.js');
var request = require('@root/request');
var _normalize = require('./normalize.js');
var cache = {};
//var staleAge = 5 * 1000;
@@ -11,6 +14,21 @@ var expiredAge = 15 * 60 * 1000;
let installerDir = path.join(__dirname, '..');
Releases.get = async function (pkgdir) {
let get;
try {
get = require(path.join(pkgdir, 'releases.js'));
} catch (e) {
let err = new Error('no releases.js for', pkgdir.split(/[\/\\]+/).pop());
err.code = 'E_NO_RELEASE';
throw err;
}
let all = await get(request);
return _normalize(all);
};
// TODO needs a proper test, and more accurate (though perhaps far less simple) code
function createFormatsSorter(formats) {
return function sortByVerExt(a, b) {
@@ -122,7 +140,7 @@ async function getCachedReleases(pkg) {
cache[pkg].all = all;
complete = true;
}),
sleep(5000).then(function () {
sleep(15000).then(function () {
if (complete) {
return;
}
@@ -242,7 +260,7 @@ async function filterReleases(
return sortedRels.slice(0, limit || 1000);
}
module.exports = function getReleases({
Releases.getReleases = function ({
_count,
pkg,
ver,
@@ -290,7 +308,7 @@ module.exports = function getReleases({
if (_count < 1) {
// Apple Silicon M1 hacky-do workaround fix
if ('macos' === os && 'arm64' === arch) {
return getReleases({
return Releases.getReleases({
pkg,
ver,
os,
@@ -304,7 +322,7 @@ module.exports = function getReleases({
}
// Windows ARM hacky-do workaround fix
if ('windows' === os && 'arm64' === arch) {
return getReleases({
return Releases.getReleases({
pkg,
ver,
os,
@@ -318,7 +336,7 @@ module.exports = function getReleases({
}
// Raspberry Pi 3+ on Ubuntu arm64 (via Bionic?)
if ('linux' === os && 'arm64' === arch) {
return getReleases({
return Releases.getReleases({
_count: _count + 1,
pkg,
ver,
@@ -333,7 +351,7 @@ module.exports = function getReleases({
}
// armv7 can run armv6
if ('linux' === os && 'armv7l' === arch) {
return getReleases({
return Releases.getReleases({
_count: _count + 1,
pkg,
ver,
@@ -351,7 +369,7 @@ module.exports = function getReleases({
// Raspberry Pi 3+ on Raspbian arm7 (not Ubuntu arm64)
// hail mary
if ('linux' === os && 'armv7l' === arch) {
return getReleases({
return Releases.getReleases({
_count: _count + 1,
pkg,
ver,

View File

@@ -3,17 +3,51 @@ set -e
set -u
if command -v fish > /dev/null; then
if [ ! -e ~/.config/fish/config.fish ]; then
if ! test -r ~/.config/fish/config.fish; then
mkdir -p ~/.config/fish
touch ~/.config/fish/config.fish
chmod 0600 ~/.config/fish/config.fish
fi
fi
else
if command -v sudo > /dev/null; then
my_answer='n'
if command -v apt > /dev/null; then
echo ""
echo "ERROR"
echo " No Webi installer for fish on Linux yet."
echo ""
echo "SOLUTION"
echo " Would you like to install with apt?"
echo " sudo apt install -y fish"
echo ""
printf "Install with sudo and apt [Y/n]? "
elif command -v apk > /dev/null; then
echo ""
echo "ERROR"
echo " No Webi installer for fish on Alpine yet."
echo ""
echo "SOLUTION"
echo " Would you like to install with apk?"
echo " sudo apk add --no-cache fish"
echo ""
printf "Install with sudo and apk [Y/n]? "
elif test "Darwin" != "$(uname -s)"; then
echo "No fish installer for Linux yet."
exit 1
fi
if [ "Darwin" != "$(uname -s)" ]; then
echo "No fish installer for Linux yet. Try this instead:"
echo " sudo apt install -y fish"
exit 1
read -r my_answer < /dev/tty
if test -z "${my_answer}" ||
test "${my_answer}" = "Y" ||
test "${my_answer}" = "y"; then
sudo apt install -y fish
else
exit 1
fi
elif test "Darwin" != "$(uname -s)"; then
echo "No fish installer for Linux yet."
exit 1
fi
fi
################
@@ -37,6 +71,10 @@ pkg_src="$pkg_src_cmd"
# pkg_install must be defined by every package
_macos_post_install() {
if test "Darwin" != "$(uname -s)"; then
return 0
fi
if ! [ -e "$HOME/.local/bin/fish" ]; then
return 0
fi
@@ -71,8 +109,10 @@ _macos_post_install() {
killall cfprefsd
}
# always try to reset the default shells
_macos_post_install
if test "Darwin" = "$(uname -s)"; then
# always try to reset the default shells
_macos_post_install
fi
pkg_install() {
mv fish.app/Contents/Resources/base/usr/local "$HOME/.local/opt/fish-v${WEBI_VERSION}"
@@ -84,7 +124,10 @@ pkg_post_install() {
webi_post_install
# try again to update default shells, now that all files should exist
_macos_post_install
if test "Darwin" = "$(uname -s)"; then
# always try to reset the default shells
_macos_post_install
fi
if [ ! -e ~/.config/fish/config.fish ]; then
mkdir -p ~/.config/fish

View File

@@ -14,11 +14,57 @@ __init_git() {
echo >&2 " for example, try: xcode-select --install"
# sudo xcodebuild -license accept
else
echo >&2 "Error: to install 'git' on Linux use the built-in package manager."
echo >&2 " for example, try: sudo apt install -y git"
fn_prompt_sudo_install git
fi
exit 1
}
fn_prompt_sudo_install() {
a_pkg="${1}"
if command -v sudo > /dev/null; then
my_answer='n'
cmd_pkg_add=''
if command -v apt > /dev/null; then
echo ""
echo "ERROR"
echo " No Webi installer for ${a_pkg} on Linux yet."
echo ""
echo "SOLUTION"
echo " Would you like to install with apt?"
echo " sudo apt install -y ${a_pkg}"
echo ""
printf "Install with sudo and apt [Y/n]? "
cmd_pkg_add='sudo apt install -y'
elif command -v apk > /dev/null; then
echo ""
echo "ERROR"
echo " No Webi installer for ${a_pkg} on Alpine yet."
echo ""
echo "SOLUTION"
echo " Would you like to install with apk?"
echo " sudo apk add --no-cache ${a_pkg}"
echo ""
printf "Install with sudo and apk [Y/n]? "
cmd_pkg_add='sudo apk add --no-cache'
elif test "Darwin" != "$(uname -s)"; then
echo "No ${a_pkg} installer for Linux yet."
exit 1
fi
read -r my_answer < /dev/tty
if test -z "${my_answer}" ||
test "${my_answer}" = "Y" ||
test "${my_answer}" = "y"; then
$cmd_pkg_add "${a_pkg}"
else
exit 1
fi
elif test "Darwin" != "$(uname -s)"; then
echo "No ${a_pkg} installer for Linux yet."
exit 1
fi
}
__init_git

View File

@@ -6,6 +6,7 @@ var repo = 'goreleaser';
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all._names = ['goreleaser', '1'];
return all;
});
};

View File

@@ -7,19 +7,25 @@ var repo = 'ollama';
module.exports = async function (request) {
let all = await github(request, owner, repo);
// TODO why are the 0.0.x releases sorting so high?
let releases = [];
for (let rel of all.releases) {
let isLow = rel.version.startsWith('v0.0.');
if (isLow) {
// this is a janky, sudo-wantin' .app
let isJank = rel.name.startsWith('Ollama-darwin');
if (isJank) {
continue;
}
let isUniversal = rel.name === 'ollama-darwin';
if (isUniversal) {
let x64 = Object.assign({ arch: 'x86_64' }, rel);
releases.push(x64);
rel.arch = 'aarch64';
}
releases.push(rel);
}
all.releases = releases;
all._names = ['Ollama', 'ollama'];
return all;
};

View File

@@ -32,7 +32,7 @@ module.exports = function (request) {
let isMusl = rel.download.match(/(\b|_)(musl|alpine)(\b|_)/i);
if (isMusl) {
// not a fully static build, not gnu-compatible
rel.arch = 'musl';
rel.libc = 'musl';
}
return true;

View File

@@ -20,10 +20,22 @@ __init_sd() {
# pkg_install must be defined by every package
pkg_install() {
# ~/.local/opt/sd-v0.99.9/bin
mkdir -p "$(dirname "$pkg_src_cmd")"
# mv ./sd-*/sd "$pkg_src_cmd"
mv sd-* "$pkg_src_cmd"
if test -f sd-*; then
# ~/.local/opt/sd-v0.99.9/bin
mkdir -p "$(dirname "$pkg_src_cmd")"
mv sd-* "$pkg_src_cmd"
elif test -f sd-*/sd; then
# ~/.local/opt/sd-v0.99.9/bin
mkdir -p "$(dirname "$pkg_src_cmd")"
mv sd-*/sd "$pkg_src_cmd"
if test -f sd-*/sd.1; then
mkdir -p "$pkg_src_dir/share/man/man1"
mv sd-*/sd.1 "$pkg_src_dir/share/man/man1"
fi
elif test -d sd-*/bin; then
mv sd-* "$pkg_src_dir"
fi
}
# pkg_get_current_version is recommended, but (soon) not required

View File

@@ -6,27 +6,6 @@ var repo = 'shellcheck';
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all.releases = all.releases.filter(function (rel) {
// don't include meta versions as actual versions
if (
['latest', 'stable'].includes(rel.version) ||
'v' !== rel.version[0]
) {
return false;
}
return true;
});
all.releases.forEach(function (rel) {
// if there is no os or arch or source designation, and it's a .zip, it's Windows amd64
if (
!/(darwin|mac|linux|x86_64|arm|src|source)/i.test(rel.name) &&
/\.zip$/.test(rel.name)
) {
rel.os = 'windows';
rel.arch = 'amd64';
}
});
return all;
});
};

View File

@@ -6,6 +6,13 @@ var repo = 'watchexec';
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
let builds = [];
for (let build of all.releases) {
build.version = build.version.replace(/^cli-/, '');
builds.push(build);
}
all.releases = builds;
return all;
});
};

View File

@@ -152,7 +152,7 @@ __webi_main() {
my_checksum="$(
fn_checksum
)"
my_version=v1.2.7
my_version=v1.2.8
printf "\e[35mwebi\e[32m %s\e[0m Copyright 2020+ AJ ONeal\n" "${my_version} (${my_checksum})"
printf " \e[36mhttps://webinstall.dev/webi\e[0m\n"
}

View File

@@ -1,6 +1,7 @@
'use strict';
var NON_BUILDS = ['bootstrap', 'src'];
var ODDITIES = NON_BUILDS.concat(['armv6kz-linux']);
module.exports = function (request) {
return request({
@@ -27,8 +28,8 @@ module.exports = function (request) {
return;
}
let isNonBuild = NON_BUILDS.includes(platform);
if (isNonBuild) {
let isOdd = ODDITIES.includes(platform);
if (isOdd) {
return;
}

View File

@@ -6,11 +6,6 @@ var repo = 'zoxide';
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all.releases.forEach(function (rel) {
if (/-arm-/.test(rel.download)) {
rel.arch = 'armv6l';
}
});
return all;
});
};