mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-08-19 03:56:16 +00:00
generalize, a lot
This commit is contained in:
@@ -0,0 +1 @@
|
||||
install-*.sh
|
||||
@@ -14,12 +14,14 @@ Primary and community-submitted packages for
|
||||
|
||||
## Creating an Installer
|
||||
|
||||
An install consists of 5 parts in two files:
|
||||
An install consists of 5 parts in 4 files:
|
||||
|
||||
```
|
||||
my-new-package/
|
||||
- package.yash
|
||||
- releases.js
|
||||
- my-new-package.bash
|
||||
- install.sh
|
||||
- install.bat
|
||||
```
|
||||
|
||||
1. Create Description
|
||||
@@ -38,11 +40,20 @@ variables and functions pre-defined.
|
||||
|
||||
You just fill in the blanks.
|
||||
|
||||
### TL;DR
|
||||
|
||||
Just create an empty directory and run the tests until you get a good result.
|
||||
|
||||
```bash
|
||||
mkdir -p new-package
|
||||
node _webi/test.js ./new-package/
|
||||
```
|
||||
|
||||
### 1. Create Description
|
||||
|
||||
Just copy the format from any of the existing packages. It's like this:
|
||||
|
||||
`my-new-package.bash`:
|
||||
`package.yash`:
|
||||
|
||||
````
|
||||
# title: Node.js
|
||||
@@ -55,8 +66,15 @@ Just copy the format from any of the existing packages. It's like this:
|
||||
# node -e 'console.log("Hello, World!")'
|
||||
# > Hello, World!
|
||||
# ```
|
||||
|
||||
END
|
||||
````
|
||||
|
||||
This is a dumb format. We know. Historical accident (originally these were in
|
||||
bash comments).
|
||||
|
||||
It's in the TODOs to replace this with either YAML or Markdown.
|
||||
|
||||
### 1. Fetch Releases
|
||||
|
||||
All you're doing in this step is just translating from one form of JSON or CSV
|
||||
@@ -115,25 +133,24 @@ pkg_get_current_version() {
|
||||
For the rest of the functions you can like copy/paste from the examples:
|
||||
|
||||
```bash
|
||||
pkg_format_cmd_version() {} # Optional, pretty prints version
|
||||
pkg_format_cmd_version() {} # Override, pretty prints version
|
||||
|
||||
pkg_link_src_dst() {} # Required, may be empty for $HOME/.local/bin commands
|
||||
pkg_link # Override, replaces webi_link()
|
||||
|
||||
pkg_pre_install() { # Required, runs any webi_* commands
|
||||
webi_check # for $HOME/.local/opt tools
|
||||
webi_download # for things that have a releases.js
|
||||
webi_extract # for .xz, .tar.*, and .zip files
|
||||
pkg_pre_install() { # Override, runs any webi_* commands
|
||||
webi_check # for $HOME/.local/opt tools
|
||||
webi_download # for things that have a releases.js
|
||||
webi_extract # for .xz, .tar.*, and .zip files
|
||||
}
|
||||
|
||||
pkg_install() {} # Required, usually just needs to rename extracted folder to
|
||||
# "$HOME/.local/opt/$pkg_cmd_name-v$WEBI_VERSION"
|
||||
pkg_install() {} # Override, usually just needs to rename extracted folder to
|
||||
# "$HOME/.local/opt/$pkg_cmd_name-v$WEBI_VERSION"
|
||||
|
||||
pkg_post_install() { # Required
|
||||
pkg_link_src_dst # should probably call pkg_link_src_dst()
|
||||
webi_path_add "$pkg_dst_bin" # should probably update PATH
|
||||
pkg_post_install() { # Override
|
||||
webi_path_add "$pkg_dst_bin" # should probably update PATH
|
||||
}
|
||||
|
||||
pkg_post_install_message() {} # Optional, pretty print a success message
|
||||
pkg_done_message() {} # Override, pretty print a success message
|
||||
```
|
||||
|
||||
## Script API
|
||||
@@ -162,6 +179,7 @@ WEBI_PKG_FILE=example-macos-amd64.tar.gz
|
||||
|
||||
```bash
|
||||
WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-foobar.XXXXXXXX)"}
|
||||
WEBI_SINGLE=""
|
||||
```
|
||||
|
||||
```bash
|
||||
@@ -169,6 +187,10 @@ webi_check # Checks to see if the selected version is already insta
|
||||
webi_download # Downloads the selected release to $HOME/Downloads/<package-name>.tar.gz
|
||||
webi_extract # Extracts the download to /tmp/<package-name>-<random>/
|
||||
webi_path_add /new/path # Adds /new/path to PATH for bash, zsh, and fish
|
||||
webi_pre_install # Runs webi_check, webi_download, and webi_extract
|
||||
webi_install # Moves extracted files from $WEBI_TMP to $pkg_src
|
||||
webi_link # replaces any existing symlink with the currently selected version
|
||||
webi_post_install # Runs `webi_add_path $pkg_dst_bin`
|
||||
```
|
||||
|
||||
# Roadmap
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: migrate from shmatter to frontmarker
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
@@ -40,7 +38,7 @@ pkg_get_current_version() {
|
||||
# For (re-)linking to the desired installed version
|
||||
# (for example: 'go' is special and needs both $HOME/go and $HOME/.local/opt/go)
|
||||
# (others like 'rg', 'hugo', and 'caddy' are single files that just get replaced)
|
||||
pkg_link_src_dst() {
|
||||
pkg_link() {
|
||||
rm -rf "$pkg_dst"
|
||||
ln -s "$pkg_src" "$pkg_dst"
|
||||
}
|
||||
@@ -60,26 +58,22 @@ pkg_pre_install() {
|
||||
|
||||
# For installing from the extracted package tmp directory
|
||||
pkg_install() {
|
||||
pushd "$WEBI_TMP" 2>&1 >/dev/null
|
||||
# remove the versioned folder, just in case it's there with junk
|
||||
rm -rf "$pkg_src"
|
||||
|
||||
# remove the versioned folder, just in case it's there with junk
|
||||
rm -rf "$pkg_src"
|
||||
|
||||
# rename the entire extracted folder to the new location
|
||||
# (this will be "$HOME/.local/opt/xmpl-v$WEBI_VERSION" by default)
|
||||
mv ./"$pkg_cmd_name"* "$pkg_src"
|
||||
|
||||
popd 2>&1 >/dev/null
|
||||
# rename the entire extracted folder to the new location
|
||||
# (this will be "$HOME/.local/opt/xmpl-v$WEBI_VERSION" by default)
|
||||
mv ./"$pkg_cmd_name"* "$pkg_src"
|
||||
}
|
||||
|
||||
# For updating PATHs and installing companion tools
|
||||
pkg_post_install() {
|
||||
pkg_link_src_dst
|
||||
pkg_link
|
||||
|
||||
# web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
webi_path_add "$pkg_dst_bin"
|
||||
}
|
||||
|
||||
pkg_post_install_message() {
|
||||
echo "Installed 'example' as 'xmpl'"
|
||||
pkg_done_message() {
|
||||
echo "Installed 'example' as 'xmpl' at $pkg_dst_cmd"
|
||||
}
|
||||
@@ -36,7 +36,7 @@ if (module === require.main) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
// limit the example output
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
all = require('../_common/normalize.js')(all);
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
setlocal
|
||||
@echo off
|
||||
pushd "%userprofile%" || goto :error
|
||||
IF NOT EXIST .local (
|
||||
mkdir .local || goto :error
|
||||
)
|
||||
IF NOT EXIST .local\bin (
|
||||
mkdir .local\bin || goto :error
|
||||
)
|
||||
|
||||
rem {{ baseurl }}
|
||||
rem {{ version }}
|
||||
pushd .local\bin || goto :error
|
||||
if NOT EXIST webi.bat (
|
||||
rem without SilentlyContinue this is SLOOOOOOOOOOOOOOOW!
|
||||
powershell $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest https://webinstall.dev/packages/_webi/webi.bat -OutFile webi.bat || goto :error
|
||||
)
|
||||
call .\webi {{ exename }} || goto :error
|
||||
rem pathman add "%userprofile%\.local\bin" >nul 2>&1 || goto :error
|
||||
pathman add "%userprofile%\.local\bin" || goto :error
|
||||
popd || goto :error
|
||||
popd
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
@@ -14,6 +14,8 @@ cat << EOF > "$HOME/.local/bin/webi"
|
||||
set -e
|
||||
set -u
|
||||
|
||||
{
|
||||
|
||||
my_package="\${1:-}"
|
||||
if [ -z "\$my_package" ]; then
|
||||
echo "Usage: webi <package>@<version>"
|
||||
@@ -83,6 +85,8 @@ pushd "\$WEBI_BOOT" 2>&1 > /dev/null
|
||||
popd 2>&1 > /dev/null
|
||||
|
||||
rm -rf "\$WEBI_BOOT"
|
||||
|
||||
}
|
||||
EOF
|
||||
|
||||
chmod a+x "$HOME/.local/bin/webi"
|
||||
@@ -0,0 +1,108 @@
|
||||
'use strict';
|
||||
|
||||
var shmatter = require('shmatter');
|
||||
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) {
|
||||
var yash = path.join(basepath, node, 'package.yash');
|
||||
var curlbash = path.join(basepath, node, 'install.sh');
|
||||
var readme = path.join(basepath, node, 'README.md');
|
||||
var winstall = path.join(basepath, node, 'install.bat');
|
||||
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
|
||||
.readFile(yash, 'utf-8')
|
||||
.then(function (txt) {
|
||||
return shmatter.parse(txt);
|
||||
})
|
||||
.catch(function (e) {
|
||||
// no yash package description
|
||||
yash = '';
|
||||
if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
|
||||
console.error("failed to parse '" + node + "/package.yash'");
|
||||
console.error(e);
|
||||
}
|
||||
return fs.promises.readFile(curlbash, 'utf-8').then(function (txt) {
|
||||
return shmatter.parse(txt);
|
||||
});
|
||||
})
|
||||
.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.bat'");
|
||||
console.error(e);
|
||||
}
|
||||
})
|
||||
]).then(function (items) {
|
||||
var meta = 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);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var request = require('@root/request');
|
||||
var _normalize = require('../_webi/normalize.js');
|
||||
|
||||
var Releases = module.exports;
|
||||
Releases.get = async function (pkgdir) {
|
||||
var get = require(path.join(pkgdir, 'releases.js'));
|
||||
return get(request).then(function (all) {
|
||||
return _normalize(all);
|
||||
});
|
||||
};
|
||||
|
||||
Releases.renderBash = function (
|
||||
pkgdir,
|
||||
rel,
|
||||
{ baseurl, pkg, tag, ver, os, arch, formats }
|
||||
) {
|
||||
return fs.promises
|
||||
.readFile(path.join(pkgdir, 'install.sh'), 'utf8')
|
||||
.then(function (installTxt) {
|
||||
var vers = rel.version.split('.');
|
||||
var v = {
|
||||
major: vers.shift() || '',
|
||||
minor: vers.shift() || '',
|
||||
patch: vers.join('.').replace(/[+\-].*/, ''),
|
||||
build: vers
|
||||
.join('.')
|
||||
.replace(/[^+\-]*/, '')
|
||||
.replace(/^-/, '')
|
||||
};
|
||||
return fs.promises
|
||||
.readFile(path.join(__dirname, 'template.sh'), 'utf8')
|
||||
.then(function (tplTxt) {
|
||||
return tplTxt
|
||||
.replace(/^#?WEBI_PKG=.*/m, "WEBI_PKG='" + pkg + '@' + ver + "'")
|
||||
.replace(/^#?WEBI_NAME=.*/m, "WEBI_NAME='" + pkg + "'")
|
||||
.replace(/^#?WEBI_HOST=.*/m, "WEBI_HOST='" + baseurl + "'")
|
||||
.replace(/^#?WEBI_OS=.*/m, "WEBI_OS='" + (os || '') + "'")
|
||||
.replace(/^#?WEBI_ARCH=.*/m, "WEBI_ARCH='" + (arch || '') + "'")
|
||||
.replace(/^#?WEBI_TAG=.*/m, "WEBI_TAG='" + (tag || '') + "'")
|
||||
.replace(
|
||||
/^#?WEBI_RELEASES=.*/m,
|
||||
"WEBI_RELEASES='" +
|
||||
baseurl +
|
||||
'/api/releases/' +
|
||||
pkg +
|
||||
'@' +
|
||||
tag +
|
||||
'.tab?os=' +
|
||||
rel.os +
|
||||
'&arch=' +
|
||||
rel.arch +
|
||||
'&pretty=true' +
|
||||
"'"
|
||||
)
|
||||
.replace(
|
||||
/^#?WEBI_CSV=.*/m,
|
||||
"WEBI_CSV='" +
|
||||
[
|
||||
rel.version,
|
||||
rel.lts,
|
||||
rel.channel,
|
||||
rel.date,
|
||||
rel.os,
|
||||
rel.arch,
|
||||
rel.ext,
|
||||
'-',
|
||||
rel.download,
|
||||
rel.name,
|
||||
rel.comment || ''
|
||||
]
|
||||
.join(',')
|
||||
.replace(/'/g, '') +
|
||||
"'"
|
||||
)
|
||||
.replace(
|
||||
/^#?WEBI_VERSION=.*/m,
|
||||
'WEBI_VERSION=' + JSON.stringify(rel.version)
|
||||
)
|
||||
.replace(/^#?WEBI_MAJOR=.*/m, 'WEBI_MAJOR=' + v.major)
|
||||
.replace(/^#?WEBI_MINOR=.*/m, 'WEBI_MINOR=' + v.minor)
|
||||
.replace(/^#?WEBI_PATCH=.*/m, 'WEBI_PATCH=' + v.patch)
|
||||
.replace(/^#?WEBI_BUILD=.*/m, 'WEBI_BUILD=' + v.build)
|
||||
.replace(/^#?WEBI_LTS=.*/m, 'WEBI_LTS=' + rel.lts)
|
||||
.replace(/^#?WEBI_CHANNEL=.*/m, 'WEBI_CHANNEL=' + rel.channel)
|
||||
.replace(
|
||||
/^#?WEBI_EXT=.*/m,
|
||||
'WEBI_EXT=' + rel.ext.replace(/tar.*/, 'tar')
|
||||
)
|
||||
.replace(
|
||||
/^#?WEBI_PKG_URL=.*/m,
|
||||
"WEBI_PKG_URL='" + rel.download + "'"
|
||||
)
|
||||
.replace(/^#?WEBI_PKG_FILE=.*/m, "WEBI_PKG_FILE='" + rel.name + "'")
|
||||
.replace(/{{ installer }}/, installTxt);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,296 @@
|
||||
#!/bin/bash
|
||||
|
||||
{
|
||||
|
||||
set -e
|
||||
set -u
|
||||
#set -x
|
||||
|
||||
#WEBI_PKG=
|
||||
#WEBI_NAME=
|
||||
# TODO should this be BASEURL instead?
|
||||
#WEBI_HOST=
|
||||
#WEBI_RELEASES=
|
||||
#WEBI_CSV=
|
||||
#WEBI_TAG=
|
||||
#WEBI_VERSION=
|
||||
#WEBI_MAJOR=
|
||||
#WEBI_MINOR=
|
||||
#WEBI_PATCH=
|
||||
# TODO not sure if BUILD is the best name for this
|
||||
#WEBI_BUILD=
|
||||
#WEBI_LTS=
|
||||
#WEBI_CHANNEL=
|
||||
#WEBI_EXT=
|
||||
#WEBI_PKG_URL=
|
||||
#WEBI_PKG_FILE=
|
||||
WEBI_UA="$(uname -a)"
|
||||
export WEBI_HOST
|
||||
|
||||
##
|
||||
## Set up tmp, download, and install directories
|
||||
##
|
||||
|
||||
WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-${WEBI_PKG:-}.XXXXXXXX)"}
|
||||
|
||||
mkdir -p "$HOME/Downloads"
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
mkdir -p "$HOME/.local/opt"
|
||||
|
||||
##
|
||||
## Detect http client
|
||||
##
|
||||
set +e
|
||||
export WEBI_CURL="$(command -v curl)"
|
||||
export WEBI_WGET="$(command -v wget)"
|
||||
set -e
|
||||
|
||||
my_versioned_name=""
|
||||
_webi_canonical_name() {
|
||||
if [ -n "$my_versioned_name" ]; then
|
||||
echo "$my_versioned_name"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -n "$(command -v pkg_format_cmd_version)" ]; then
|
||||
my_versioned_name="$(pkg_format_cmd_version "$WEBI_VERSION")"
|
||||
else
|
||||
my_versioned_name="'$pkg_cmd_name' v$WEBI_VERSION"
|
||||
fi
|
||||
|
||||
echo "$my_versioned_name"
|
||||
}
|
||||
|
||||
webi_link() {
|
||||
if [ -n "$(command -v pkg_link)" ]; then
|
||||
pkg_link
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -n "$WEBI_SINGLE" ] || [ "single" == "${1:-}" ]; then
|
||||
if [ -d "$pkg_dst_cmd" ]; then
|
||||
rm -rf -i "$pkg_dst_cmd"
|
||||
else
|
||||
rm -f "$pkg_dst_cmd"
|
||||
fi
|
||||
ln -s "$pkg_src_cmd" "$pkg_dst_cmd"
|
||||
else
|
||||
# 'pkg_dst' will default to $HOME/.local/opt/node
|
||||
# 'pkg_src' will be the installed version, such as to $HOME/.local/opt/node-v12.8.0
|
||||
if [ -d "$pkg_dst" ]; then
|
||||
rm -rf -i "$pkg_dst"
|
||||
else
|
||||
rm -f "$pkg_dst"
|
||||
fi
|
||||
ln -s "$pkg_src" "$pkg_dst"
|
||||
fi
|
||||
}
|
||||
|
||||
webi_check() {
|
||||
# Test for existing version
|
||||
set +e
|
||||
my_current_cmd="$(command -v "$pkg_cmd_name")"
|
||||
set -e
|
||||
if [ -n "$my_current_cmd" ]; then
|
||||
pkg_current_version="$(pkg_get_current_version 2>/dev/null | head -n 1)"
|
||||
# remove trailing '.0's for golang's sake
|
||||
my_current_version="$(echo $pkg_current_version | sed 's:\.0::g')"
|
||||
my_src_version="$(echo $WEBI_VERSION | sed 's:\.0::g')"
|
||||
my_canonical_name="$(_webi_canonical_name)"
|
||||
if [ "$my_src_version" == "$my_current_version" ]; then
|
||||
echo "$my_canonical_name already installed at $my_current_cmd"
|
||||
exit 0
|
||||
else
|
||||
if [ "$my_current_cmd" != "$pkg_dst_cmd" ]; then
|
||||
echo "WARN: possible conflict between $my_canonical_name and $pkg_current_version at $my_current_cmd"
|
||||
fi
|
||||
if [ -x "$pkg_src_cmd" ]; then
|
||||
webi_link
|
||||
echo "switched to $my_canonical_name at $pkg_src"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
webi_download() {
|
||||
if [ -n "${1:-}" ]; then
|
||||
my_url="$1"
|
||||
else
|
||||
if [ "error" == "$WEBI_CHANNEL" ]; then
|
||||
# TODO pass back requested OS / Arch / Version
|
||||
echo "Error: no '$WEBI_NAME' release found for the given OS and architecture by that tag or version"
|
||||
echo " (check that the package name and version are correct)"
|
||||
exit 1
|
||||
fi
|
||||
my_url="$WEBI_PKG_URL"
|
||||
fi
|
||||
if [ -n "${2:-}" ]; then
|
||||
my_dl="$2"
|
||||
else
|
||||
my_dl="$HOME/Downloads/$WEBI_PKG_FILE"
|
||||
fi
|
||||
|
||||
if [ -e "$my_dl" ]; then
|
||||
echo "Found $my_dl"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Downloading $WEBI_NAME to $my_dl"
|
||||
|
||||
# It's only 2020, we can't expect to have reliable CLI tools
|
||||
# to tell us the size of a file as part of a base system...
|
||||
if [ -n "$WEBI_WGET" ]; then
|
||||
# wget has resumable downloads
|
||||
# TODO wget -c --content-disposition "$my_url"
|
||||
set +e
|
||||
wget -q --show-progress --user-agent="wget $WEBI_UA" -c "$my_url" -O "$my_dl.part"
|
||||
if ! [ $? -eq 0 ]; then
|
||||
echo "failed to download from $WEBI_PKG_URL"
|
||||
exit 1
|
||||
fi
|
||||
set -e
|
||||
else
|
||||
# Neither GNU nor BSD curl have sane resume download options, hence we don't bother
|
||||
# TODO curl -fsSL --remote-name --remote-header-name --write-out "$my_url"
|
||||
curl -fSL -H "User-Agent: curl $WEBI_UA" "$my_url" -o "$my_dl.part"
|
||||
fi
|
||||
|
||||
mv "$my_dl.part" "$my_dl"
|
||||
}
|
||||
|
||||
webi_extract() {
|
||||
pushd "$WEBI_TMP" 2>&1 >/dev/null
|
||||
if [ "tar" == "$WEBI_EXT" ]; then
|
||||
echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE"
|
||||
tar xf "$HOME/Downloads/$WEBI_PKG_FILE"
|
||||
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"
|
||||
exit 1
|
||||
fi
|
||||
popd 2>&1 >/dev/null
|
||||
}
|
||||
|
||||
webi_path_add() {
|
||||
# make sure that we don't recursively install pathman with webi
|
||||
my_path="$PATH"
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
set +e
|
||||
my_pathman=$(command -v pathman)
|
||||
set -e
|
||||
export PATH="$my_path"
|
||||
|
||||
# install pathman if not already installed
|
||||
if [ -z "$my_pathman" ]; then
|
||||
"$HOME/.local/bin/webi" pathman
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
fi
|
||||
|
||||
# in case pathman was recently installed and the PATH not updated
|
||||
"$HOME/.local/bin/pathman" add "$1"
|
||||
}
|
||||
|
||||
webi_pre_install() {
|
||||
webi_check
|
||||
webi_download
|
||||
webi_extract
|
||||
}
|
||||
|
||||
webi_install() {
|
||||
if [ -n "$WEBI_SINGLE" ] || [ "single" == "${1:-}" ]; then
|
||||
mkdir -p "$(dirname $pkg_src_cmd)"
|
||||
mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
|
||||
chmod a+x "$pkg_src_cmd"
|
||||
else
|
||||
mkdir -p "$(dirname $pkg_src)"
|
||||
if [ -d "$pkg_src" ]; then
|
||||
rm -rf -i "$pkg_src"
|
||||
else
|
||||
rm -f "$pkg_src"
|
||||
fi
|
||||
mv ./"$pkg_cmd_name"* "$pkg_src"
|
||||
fi
|
||||
}
|
||||
|
||||
webi_post_install() {
|
||||
webi_path_add "$pkg_dst_bin"
|
||||
}
|
||||
|
||||
_webi_done_message() {
|
||||
echo "Installed $(_webi_canonical_name) as $pkg_dst_cmd"
|
||||
}
|
||||
|
||||
##
|
||||
##
|
||||
## BEGIN user-submited script
|
||||
##
|
||||
##
|
||||
|
||||
WEBI_SINGLE=
|
||||
|
||||
{
|
||||
|
||||
{{ installer }}
|
||||
|
||||
}
|
||||
|
||||
##
|
||||
##
|
||||
## END user-submitted script
|
||||
##
|
||||
##
|
||||
|
||||
if [ -n "$(command -v pkg_get_current_version)" ]; then
|
||||
pkg_cmd_name="${pkg_cmd_name:-$WEBI_NAME}"
|
||||
|
||||
if [ -n "$WEBI_SINGLE" ]; then
|
||||
pkg_dst_cmd="${pkg_dst_cmd:-$HOME/.local/bin/$pkg_cmd_name}"
|
||||
pkg_dst_bin="$(dirname $pkg_dst_cmd)"
|
||||
pkg_dst="$(dirname $pkg_dst_bin)"
|
||||
|
||||
pkg_src_cmd="${pkg_src_cmd:-$HOME/.local/xbin/$pkg_cmd_name-$WEBI_VERSION}"
|
||||
pkg_src_bin="$(dirname $pkg_src_cmd)"
|
||||
pkg_src="$(dirname $pkg_src_bin)"
|
||||
else
|
||||
pkg_dst="${pkg_dst:-$HOME/.local/opt/$pkg_cmd_name}"
|
||||
pkg_dst_bin="${pkg_dst_bin:-$pkg_dst/bin}"
|
||||
pkg_dst_cmd="${pkg_dst_cmd:-$pkg_dst_bin/$pkg_cmd_name}"
|
||||
|
||||
pkg_src="${pkg_src:-$HOME/.local/opt/$pkg_cmd_name-v$WEBI_VERSION}"
|
||||
pkg_src_bin="${pkg_src_bin:-$pkg_src/bin}"
|
||||
pkg_src_cmd="${pkg_src_cmd:-$pkg_src_bin/$pkg_cmd_name}"
|
||||
fi
|
||||
|
||||
[ -n "$(command -v pkg_pre_install)" ] && pkg_pre_install || webi_pre_install
|
||||
|
||||
pushd "$WEBI_TMP" 2>&1 >/dev/null
|
||||
echo "Installing to $pkg_src_cmd"
|
||||
[ -n "$(command -v pkg_install)" ] && pkg_install || webi_install
|
||||
popd 2>&1 >/dev/null
|
||||
|
||||
webi_link
|
||||
|
||||
pushd "$WEBI_TMP" 2>&1 >/dev/null
|
||||
[ -n "$(command -v pkg_post_install)" ] && pkg_post_install || webi_post_install
|
||||
popd 2>&1 >/dev/null
|
||||
|
||||
pushd "$WEBI_TMP" 2>&1 >/dev/null
|
||||
[ -n "$(command -v pkg_done_message)" ] && pkg_done_message || _webi_done_message
|
||||
popd 2>&1 >/dev/null
|
||||
|
||||
echo ""
|
||||
fi
|
||||
|
||||
rm -rf "$WEBI_TMP"
|
||||
|
||||
}
|
||||
Executable
+107
@@ -0,0 +1,107 @@
|
||||
'use strict';
|
||||
|
||||
//
|
||||
// Print help if there's no pkgdir argument
|
||||
//
|
||||
var usage = [
|
||||
'Usage: node _webi/test.js <path-to-package>',
|
||||
'Example: node _webi/test.js ./node/'
|
||||
].join('\n');
|
||||
|
||||
if (3 !== process.argv.length) {
|
||||
console.error(usage);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (/\b-?-h(elp)?\b/.test(process.argv.join(' '))) {
|
||||
console.info(usage);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for stuff
|
||||
//
|
||||
var os = require('os');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var Releases = require('./releases.js');
|
||||
var uaDetect = require('./ua-detect.js');
|
||||
var pkg = process.argv[2].split('@');
|
||||
var pkgdir = pkg[0];
|
||||
var pkgtag = pkg[1] || '';
|
||||
var nodesMap = {};
|
||||
var nodes = fs.readdirSync(pkgdir);
|
||||
nodes.forEach(function (node) {
|
||||
nodesMap[node] = true;
|
||||
});
|
||||
|
||||
var maxLen = 0;
|
||||
console.info('');
|
||||
console.info('Has the necessary files?');
|
||||
['package.yash', 'releases.js', 'install.sh', 'install.bat']
|
||||
.map(function (node) {
|
||||
maxLen = Math.max(maxLen, node.length);
|
||||
return node;
|
||||
})
|
||||
.forEach(function (node) {
|
||||
var label = node.padStart(maxLen, ' ');
|
||||
var found = nodesMap[node];
|
||||
if (found) {
|
||||
console.info('\t' + label + ': ✅ found');
|
||||
} else {
|
||||
console.info('\t' + label + ': ❌ not found');
|
||||
}
|
||||
});
|
||||
|
||||
console.info('');
|
||||
Releases.get(path.join(process.cwd(), pkgdir)).then(function (all) {
|
||||
var pkgname = path.basename(pkgdir.replace(/\/$/, ''));
|
||||
var osrel = os.platform() + '-' + os.release();
|
||||
var arch = os.arch();
|
||||
var formats = ['xz', 'tar', 'zip'];
|
||||
|
||||
var rel = all.releases.filter(function (rel) {
|
||||
return (
|
||||
formats.filter(function (ext) {
|
||||
return rel.ext.match(ext);
|
||||
})[0] &&
|
||||
'stable' === rel.channel &&
|
||||
rel.os === uaDetect.os(osrel) &&
|
||||
rel.arch === uaDetect.arch(arch) &&
|
||||
(!pkgtag ||
|
||||
rel.tag === pkgtag ||
|
||||
new RegExp('^' + pkgtag).test(rel.version))
|
||||
);
|
||||
})[0];
|
||||
|
||||
if (!rel) {
|
||||
console.error('Error: ❌ no release found for current os, arch, and tag');
|
||||
process.exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
console.info('');
|
||||
console.info('Found release matching current os, arch, and tag:');
|
||||
console.info(rel);
|
||||
console.info('');
|
||||
|
||||
return Releases.renderBash(pkgdir, rel, {
|
||||
baseurl: 'https://webinstall.dev',
|
||||
pkg: pkgname,
|
||||
tag: pkgtag || '',
|
||||
ver: '',
|
||||
os: osrel,
|
||||
arch,
|
||||
formats: formats
|
||||
}).then(function (bashTxt) {
|
||||
var bashFile = 'install-' + pkgname + '.sh';
|
||||
var batFile = 'install-' + pkgname + '.bat';
|
||||
|
||||
bashTxt = bashTxt.replace(/#set -x/g, 'set -x');
|
||||
fs.writeFileSync(bashFile, bashTxt, 'utf-8');
|
||||
console.info('Has the necessary files?');
|
||||
console.info('\tNEEDS MANUAL TEST: %s', bashFile);
|
||||
console.info('\t(todo: ' + batFile + ')');
|
||||
console.info('');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
function getOs(ua) {
|
||||
if ('-' === ua) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
if (/Android/i.test(ua)) {
|
||||
// android must be tested before linux
|
||||
return 'android';
|
||||
} else if (/iOS|iPhone|Macintosh|Darwin|OS\s*X|macOS|mac/i.test(ua)) {
|
||||
return 'macos';
|
||||
} else if (/Microsoft|Windows|win32|win|PowerShell/.test(ua)) {
|
||||
// 'win' must be tested after 'darwin'
|
||||
return 'windows';
|
||||
} else if (/Linux|curl|wget/i.test(ua)) {
|
||||
return 'linux';
|
||||
} else {
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
function getArch(ua) {
|
||||
if ('-' === ua) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
if (/arm64|arm8|armv8/i.test(ua)) {
|
||||
return 'arm64';
|
||||
} else if (/arm7|armv7/i.test(ua)) {
|
||||
return 'armv7l';
|
||||
} else if (/arm6|armv6/i.test(ua)) {
|
||||
return 'armv6l';
|
||||
} else if (/ppc64/i.test(ua)) {
|
||||
return 'ppc64';
|
||||
} else if (/mips64/i.test(ua)) {
|
||||
return 'mips64';
|
||||
} else if (/mips/i.test(ua)) {
|
||||
return 'mips';
|
||||
} else if (/(amd64|x64|_64)\b/i.test(ua)) {
|
||||
// must come after ppc64/mips64
|
||||
return 'amd64';
|
||||
} else if (/(3|6|x|_)86\b/i.test(ua)) {
|
||||
// must come after x86_64
|
||||
return 'x86';
|
||||
} else {
|
||||
// TODO handle explicit invalid different
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.os = getOs;
|
||||
module.exports.arch = getArch;
|
||||
@@ -1,83 +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
|
||||
|
||||
pkg_cmd_name="caddy"
|
||||
pkg_dst="$HOME/.local"
|
||||
|
||||
# the "source" here isn't used, nor very meaningful,
|
||||
# but we'll use the download location as a junk value
|
||||
pkg_src="$HOME/Downloads/$WEBI_PKG_FILE"
|
||||
|
||||
pkg_get_current_version() {
|
||||
# 'caddy version' has output in this format:
|
||||
# v2.1.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
|
||||
# This trims it down to just the version number:
|
||||
# 2.0.0
|
||||
echo "$(caddy version 2>/dev/null | head -n 1 | cut -d' ' -f1 | sed 's:^v::')"
|
||||
}
|
||||
|
||||
pkg_format_cmd_version() {
|
||||
# 'caddy v2.1.0' is the canonical version format for caddy
|
||||
my_version="$1"
|
||||
echo "$pkg_cmd_name v$my_version"
|
||||
}
|
||||
|
||||
pkg_link_src_dst() {
|
||||
# caddy is just a single file, no directory linking to do
|
||||
true
|
||||
}
|
||||
|
||||
pkg_pre_install() {
|
||||
# if selected version is installed, quit
|
||||
webi_check
|
||||
# will save to ~/Downloads/$WEBI_PKG_FILE by default
|
||||
webi_download
|
||||
# supported formats (.xz, .tar.*, .zip) will be extracted to $WEBI_TMP
|
||||
webi_extract
|
||||
}
|
||||
|
||||
pkg_install() {
|
||||
pushd "$WEBI_TMP" 2>&1 >/dev/null
|
||||
|
||||
# ensure the bin dir exists
|
||||
mkdir -p "$pkg_dst_bin"
|
||||
|
||||
# rename the entire extracted folder to the new location
|
||||
# (this will be "$HOME/.local/bin/caddy", as set above)
|
||||
|
||||
# ex (full directory): ./node-v13-linux-amd64/bin/node.exe
|
||||
#mv ./"$pkg_cmd_name"* "$pkg_src"
|
||||
|
||||
# ex (single file): ./caddy-v2.0.0-linux-amd64.exe
|
||||
mv ./"$pkg_cmd_name"* "$pkg_dst_cmd"
|
||||
chmod a+x "$pkg_dst_cmd"
|
||||
|
||||
# ex (single file, nested in directory): ./rg/rg-v13-linux-amd64
|
||||
#mv ./"$pkg_cmd_name"*/"$pkg_cmd_name"* "$pkg_commend_cmd"
|
||||
#chmod a+x "$pkg_dst_cmd"
|
||||
|
||||
popd 2>&1 >/dev/null
|
||||
}
|
||||
|
||||
pkg_post_install() {
|
||||
# just in case we add something in the future
|
||||
pkg_link_src_dst
|
||||
|
||||
# web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
# Adds "$HOME/.local/bin" to PATH
|
||||
webi_path_add "$pkg_dst_bin"
|
||||
}
|
||||
|
||||
pkg_post_install_message() {
|
||||
echo "Installed 'caddy' v$WEBI_VERSION as $pkg_dst_cmd"
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This file only defines custom functions which may be unique to installing Caddy.
|
||||
# For the generic functions (version comparison, downloading, symlinking) which
|
||||
# are used by almost all installers, see `template.bash`:
|
||||
# - https://github.com/webinstall/packages/branches/master/webi/template.bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
pkg_cmd_name="caddy"
|
||||
WEBI_SINGLE=true
|
||||
|
||||
pkg_get_current_version() {
|
||||
# 'caddy version' has output in this format:
|
||||
# v2.1.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
|
||||
# This trims it down to just the version number:
|
||||
# 2.0.0
|
||||
echo "$(caddy version 2>/dev/null | head -n 1 | cut -d' ' -f1 | sed 's:^v::')"
|
||||
}
|
||||
|
||||
pkg_install() {
|
||||
# $HOME/.local/xbin
|
||||
mkdir -p "$pkg_src_bin"
|
||||
|
||||
# mv ./caddy* "$HOME/.local/xbin/caddy-v2.0.0"
|
||||
mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
|
||||
|
||||
# chmod a+x "$HOME/.local/xbin/caddy-v2.0.0"
|
||||
chmod a+x "$pkg_src_cmd"
|
||||
}
|
||||
|
||||
pkg_link() {
|
||||
# rm -f "$HOME/.local/bin/caddy"
|
||||
rm -f "$pkg_dst_cmd"
|
||||
|
||||
# ln -s "$HOME/.local/xbin/caddy-v2.0.0" "$HOME/.local/bin/caddy"
|
||||
ln -s "$pkg_src_cmd" "$pkg_dst_cmd"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
# 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
|
||||
# ```
|
||||
|
||||
This is a comment... because... poor choices I made.
|
||||
|
||||
Don't worry, this will be yaml or markdown in the... sometime... future
|
||||
+1
-1
@@ -16,7 +16,7 @@ module.exports = function (request) {
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_common/normalize.js')(all);
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# title: Flutter
|
||||
# homepage: https://flutter.dev
|
||||
# tagline: UI Toolkit for mobile, web, and desktop
|
||||
# description: |
|
||||
# Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.
|
||||
# examples: |
|
||||
#
|
||||
# ```bash
|
||||
# flutter create my_app
|
||||
# ```
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
# NOTE: pkg_* variables can be defined here
|
||||
# pkg_cmd_name
|
||||
# pkg_src, pkg_src_bin, pkg_src_cmd
|
||||
# pkg_dst, pkg_dst_bin, pkg_dst_cmd
|
||||
#
|
||||
# Their defaults are defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
|
||||
pkg_cmd_name="flutter"
|
||||
|
||||
pkg_get_current_version() {
|
||||
# 'flutter --version' outputs a lot of information:
|
||||
# Flutter 1.19.0-4.1.pre • channel beta • https://github.com/flutter/flutter.git
|
||||
# Framework • revision f994b76974 (4 days ago) • 2020-06-09 15:53:13 -0700
|
||||
# Engine • revision 9a28c3bcf4
|
||||
# Tools • Dart 2.9.0 (build 2.9.0-14.1.beta)
|
||||
# This trims it down to just the version number:
|
||||
# 1.19.0-4.1.pre
|
||||
echo "$(flutter --version 2>/dev/null | head -n 1 | cut -d' ' -f2)"
|
||||
}
|
||||
|
||||
pkg_link_src_dst() {
|
||||
# 'pkg_dst' will default to $HOME/.local/opt/flutter
|
||||
# 'pkg_src' will be the installed version, such as to $HOME/.local/opt/flutter-v1.17.3
|
||||
rm -rf "$pkg_dst"
|
||||
ln -s "$pkg_src" "$pkg_dst"
|
||||
}
|
||||
|
||||
pkg_pre_install() {
|
||||
# web_* are defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
|
||||
# multiple versions may be installed
|
||||
# if one already matches, it will simply be re-linked
|
||||
webi_check
|
||||
|
||||
# the download is quite large - hopefully you have wget installed
|
||||
# will go to ~/Downloads by default
|
||||
webi_download
|
||||
|
||||
# Multiple formats are supported: .xz, .tar.*, and .zip
|
||||
# will be extracted to $WEBI_TMP
|
||||
webi_extract
|
||||
}
|
||||
|
||||
pkg_install() {
|
||||
pushd "$WEBI_TMP" 2>&1 >/dev/null
|
||||
|
||||
# remove the versioned folder, just in case it's there with junk
|
||||
rm -rf "$pkg_src"
|
||||
|
||||
# rename the entire extracted folder to the new location
|
||||
# (this will be "$HOME/.local/opt/flutter-v$WEBI_VERSION" by default)
|
||||
mv ./flutter* "$pkg_src"
|
||||
|
||||
popd 2>&1 >/dev/null
|
||||
}
|
||||
|
||||
pkg_post_install() {
|
||||
pkg_link_src_dst
|
||||
|
||||
# web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
# Adds "$HOME/.local/opt/flutter" to PATH
|
||||
webi_path_add "$pkg_dst_bin"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
# NOTE: pkg_* variables can be defined here
|
||||
# pkg_cmd_name
|
||||
# pkg_src, pkg_src_bin, pkg_src_cmd
|
||||
# pkg_dst, pkg_dst_bin, pkg_dst_cmd
|
||||
#
|
||||
# Their defaults are defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
|
||||
pkg_cmd_name="flutter"
|
||||
|
||||
pkg_get_current_version() {
|
||||
# 'flutter --version' outputs a lot of information:
|
||||
# Flutter 1.19.0-4.1.pre • channel beta • https://github.com/flutter/flutter.git
|
||||
# Framework • revision f994b76974 (4 days ago) • 2020-06-09 15:53:13 -0700
|
||||
# Engine • revision 9a28c3bcf4
|
||||
# Tools • Dart 2.9.0 (build 2.9.0-14.1.beta)
|
||||
# This trims it down to just the version number:
|
||||
# 1.19.0-4.1.pre
|
||||
echo "$(flutter --version 2>/dev/null | head -n 1 | cut -d' ' -f2)"
|
||||
}
|
||||
|
||||
pkg_format_cmd_version() {
|
||||
# 'flutter 1.19.0' is the canonical version format for flutter
|
||||
my_version="$1"
|
||||
echo "$pkg_cmd_name $my_version"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# title: Flutter
|
||||
# homepage: https://flutter.dev
|
||||
# tagline: UI Toolkit for mobile, web, and desktop
|
||||
# description: |
|
||||
# Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.
|
||||
# examples: |
|
||||
#
|
||||
# ```bash
|
||||
# flutter create my_app
|
||||
# ```
|
||||
|
||||
END
|
||||
@@ -1,72 +0,0 @@
|
||||
# title: Gitea
|
||||
# homepage: https://github.com/go-gitea/gitea
|
||||
# tagline: Git with a cup of tea, painless self-hosted git service
|
||||
# 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
|
||||
|
||||
pkg_cmd_name="gitea"
|
||||
pkg_dst="$HOME/.local"
|
||||
|
||||
# pkg_src isn't used in this script,
|
||||
# just setting a junk value for completeness (and possibly debug output)
|
||||
pkg_src="$HOME/Downloads/$WEBI_PKG_FILE"
|
||||
|
||||
pkg_get_current_version() {
|
||||
# 'gitea version' has output in this format:
|
||||
# v2.1.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
|
||||
# This trims it down to just the version number:
|
||||
# 2.0.0
|
||||
echo "$(gitea --version 2>/dev/null | head -n 1 | cut -d' ' -f3)"
|
||||
}
|
||||
|
||||
pkg_format_cmd_version() {
|
||||
# 'gitea v2.1.0' is the canonical version format for gitea
|
||||
my_version="$1"
|
||||
echo "$pkg_cmd_name v$my_version"
|
||||
}
|
||||
|
||||
pkg_link_src_dst() {
|
||||
# gitea is just a single file, no directory linking to do
|
||||
true
|
||||
}
|
||||
|
||||
pkg_pre_install() {
|
||||
# if selected version is installed, quit
|
||||
webi_check
|
||||
# will save to ~/Downloads/$WEBI_PKG_FILE by default
|
||||
webi_download
|
||||
# supported formats (.xz, .tar.*, .zip) will be extracted to $WEBI_TMP
|
||||
webi_extract
|
||||
}
|
||||
|
||||
pkg_install() {
|
||||
pushd "$WEBI_TMP" 2>&1 >/dev/null
|
||||
|
||||
# rename the entire extracted folder to the new location
|
||||
# (this will be "$HOME/.local/bin/gitea" by default)
|
||||
mkdir -p "$pkg_dst_bin"
|
||||
mv ./"$pkg_cmd_name"* "$pkg_dst_cmd"
|
||||
chmod a+x "$pkg_dst_cmd"
|
||||
|
||||
popd 2>&1 >/dev/null
|
||||
}
|
||||
|
||||
pkg_post_install() {
|
||||
# just in case we add something in the future
|
||||
pkg_link_src_dst
|
||||
|
||||
# web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
# Adds "$HOME/.local/bin" to PATH
|
||||
webi_path_add "$pkg_dst_bin"
|
||||
}
|
||||
|
||||
pkg_post_install_message() {
|
||||
echo "Installed 'gitea' v$WEBI_VERSION as $pkg_dst_cmd"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
set -e
|
||||
set -u
|
||||
|
||||
pkg_cmd_name="gitea"
|
||||
|
||||
pkg_get_current_version() {
|
||||
# 'gitea version' has output in this format:
|
||||
# v2.1.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
|
||||
# This trims it down to just the version number:
|
||||
# 2.0.0
|
||||
echo "$(gitea --version 2>/dev/null | head -n 1 | cut -d' ' -f3)"
|
||||
}
|
||||
|
||||
pkg_format_cmd_version() {
|
||||
# 'gitea v2.1.0' is the canonical version format for gitea
|
||||
my_version="$1"
|
||||
echo "$pkg_cmd_name v$my_version"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# title: Gitea
|
||||
# homepage: https://github.com/go-gitea/gitea
|
||||
# tagline: Git with a cup of tea, painless self-hosted git service
|
||||
# description: |
|
||||
# `gitea` is a clean, lightweight self-hosted Github alternative, forked from Gogs. Lighter and more user-friendly than Gitlab.
|
||||
# examples: |
|
||||
# ```bash
|
||||
# gitea --version
|
||||
# ```
|
||||
|
||||
END
|
||||
+1
-1
@@ -16,7 +16,7 @@ module.exports = function (request) {
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_common/normalize.js')(all);
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,37 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
# title: Go
|
||||
# homepage: https://golang.org
|
||||
# tagline: The Go Programming Language tools
|
||||
# description: |
|
||||
# Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
|
||||
# examples: |
|
||||
# ```bash
|
||||
# mkdir -p hello/
|
||||
# pushd hello/
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# cat << EOF >> main.go
|
||||
# package main
|
||||
#
|
||||
# import (
|
||||
# "fmt"
|
||||
# )
|
||||
#
|
||||
# func main () {
|
||||
# fmt.Println("Hello, World!")
|
||||
# }
|
||||
# EOF
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# go fmt ./...
|
||||
# go build .
|
||||
# ./hello
|
||||
# > Hello, World!
|
||||
# ```
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
@@ -62,7 +28,7 @@ pkg_format_cmd_version() {
|
||||
echo "${pkg_cmd_name}${my_version}"
|
||||
}
|
||||
|
||||
pkg_link_src_dst() {
|
||||
pkg_link() {
|
||||
# 'pkg_dst' will default to $HOME/.local/opt/go
|
||||
# 'pkg_src' will be the installed version, such as to $HOME/.local/opt/go-v1.14.2
|
||||
rm -rf "$pkg_dst"
|
||||
@@ -77,37 +43,8 @@ pkg_link_src_dst() {
|
||||
ln -s "$GOBIN_REAL" "$GOBIN"
|
||||
}
|
||||
|
||||
pkg_pre_install() {
|
||||
# web_* are defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
|
||||
# multiple versions may be installed
|
||||
# if one already matches, it will simply be re-linked
|
||||
webi_check
|
||||
|
||||
# the download is quite large - hopefully you have wget installed
|
||||
# will go to ~/Downloads by default
|
||||
webi_download
|
||||
|
||||
# Multiple formats are supported: .xz, .tar.*, and .zip
|
||||
# will be extracted to $WEBI_TMP
|
||||
webi_extract
|
||||
}
|
||||
|
||||
pkg_install() {
|
||||
pushd "$WEBI_TMP" 2>&1 >/dev/null
|
||||
|
||||
# remove the versioned folder, just in case it's there with junk
|
||||
rm -rf "$pkg_src"
|
||||
|
||||
# rename the entire extracted folder to the new location
|
||||
# (this will be "$HOME/.local/opt/go-v$WEBI_VERSION" by default)
|
||||
mv ./"$pkg_cmd_name"* "$pkg_src"
|
||||
|
||||
popd 2>&1 >/dev/null
|
||||
}
|
||||
|
||||
pkg_post_install() {
|
||||
pkg_link_src_dst
|
||||
webi_link
|
||||
|
||||
# web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
# Updates PATH with
|
||||
@@ -116,13 +53,14 @@ pkg_post_install() {
|
||||
webi_path_add "$GOBIN/bin"
|
||||
|
||||
# Install x go
|
||||
echo "Installing go extended tools (goimports, gorename, etc)"
|
||||
echo "Building go extended tools (goimports, gorename, gotype, and stringer)"
|
||||
"$pkg_dst_cmd" get golang.org/x/tools/cmd/goimports > /dev/null 2>/dev/null
|
||||
"$pkg_dst_cmd" get golang.org/x/tools/cmd/gorename > /dev/null 2>/dev/null
|
||||
"$pkg_dst_cmd" get golang.org/x/tools/cmd/gotype > /dev/null 2>/dev/null
|
||||
"$pkg_dst_cmd" get golang.org/x/tools/cmd/stringer > /dev/null 2>/dev/null
|
||||
}
|
||||
|
||||
pkg_post_install_message() {
|
||||
echo "Installed 'go' (and go tools)"
|
||||
pkg_done_message() {
|
||||
echo "Installed 'go' v$WEBI_VERSION to ~/.local/opt/go"
|
||||
echo "Installed go 'x' tools to GOBIN=\$HOME/go/bin"
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
# title: Go
|
||||
# homepage: https://golang.org
|
||||
# tagline: The Go Programming Language tools
|
||||
# description: |
|
||||
# Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
|
||||
# examples: |
|
||||
# ```bash
|
||||
# mkdir -p hello/
|
||||
# pushd hello/
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# cat << EOF >> main.go
|
||||
# package main
|
||||
#
|
||||
# import (
|
||||
# "fmt"
|
||||
# )
|
||||
#
|
||||
# func main () {
|
||||
# fmt.Println("Hello, World!")
|
||||
# }
|
||||
# EOF
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# go fmt ./...
|
||||
# go build .
|
||||
# ./hello
|
||||
# > Hello, World!
|
||||
# ```
|
||||
|
||||
END
|
||||
+1
-1
@@ -71,7 +71,7 @@ module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
getAllReleases(require('@root/request')).then(function (all) {
|
||||
all = require('../_common/normalize.js')(all);
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
all.releases = all.releases.slice(0, 10);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
# title: Hugo
|
||||
# homepage: https://github.com/gohugoio/hugo
|
||||
# tagline: The world’s fastest framework for building websites
|
||||
# description: |
|
||||
# Hugo is one of the most popular open-source static site generators. With its amazing speed and flexibility, Hugo makes building websites fun again.
|
||||
# examples: |
|
||||
# ```bash
|
||||
# hugo
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# hugo server -D
|
||||
# ```
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
@@ -36,7 +22,7 @@ pkg_format_cmd_version() {
|
||||
echo "$pkg_cmd_name v$my_version"
|
||||
}
|
||||
|
||||
pkg_link_src_dst() {
|
||||
pkg_link() {
|
||||
# hugo is just a single file, no directory linking to do
|
||||
true
|
||||
}
|
||||
@@ -64,7 +50,7 @@ pkg_install() {
|
||||
|
||||
pkg_post_install() {
|
||||
# just in case we add something in the future
|
||||
pkg_link_src_dst
|
||||
pkg_link
|
||||
|
||||
# web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
# Adds "$HOME/.local/opt/node" to PATH
|
||||
@@ -0,0 +1,15 @@
|
||||
# title: Hugo
|
||||
# homepage: https://github.com/gohugoio/hugo
|
||||
# tagline: The world’s fastest framework for building websites
|
||||
# description: |
|
||||
# Hugo is one of the most popular open-source static site generators. With its amazing speed and flexibility, Hugo makes building websites fun again.
|
||||
# examples: |
|
||||
# ```bash
|
||||
# hugo
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# hugo server -D
|
||||
# ```
|
||||
|
||||
END
|
||||
+1
-1
@@ -16,7 +16,7 @@ module.exports = function (request) {
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_common/normalize.js')(all);
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# title: Node.js
|
||||
# homepage: https://nodejs.org
|
||||
# tagline: JavaScript V8 runtime
|
||||
# description: |
|
||||
# Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine
|
||||
# examples: |
|
||||
#
|
||||
# ### Hello World
|
||||
#
|
||||
# ```bash
|
||||
# node -e 'console.log("Hello, World!")'
|
||||
# > Hello, World!
|
||||
# ```
|
||||
#
|
||||
# ### A Simple Web Server
|
||||
#
|
||||
# `server.js`:
|
||||
#
|
||||
# ```bash
|
||||
# var http = require('http');
|
||||
# var app = function (req, res) {
|
||||
# res.end('Hello, World!');
|
||||
# };
|
||||
# http.createServer(app).listen(8080, function () {
|
||||
# console.info('Listening on', this.address());
|
||||
# });
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# node server.js
|
||||
# ```
|
||||
#
|
||||
# ### An Express App
|
||||
#
|
||||
# ```bash
|
||||
# mkdir my-server
|
||||
# pushd my-server
|
||||
# npm init
|
||||
# npm install --save express
|
||||
# ```
|
||||
#
|
||||
# `app.js`:
|
||||
#
|
||||
# ```js
|
||||
# 'use strict';
|
||||
#
|
||||
# var express = require('express');
|
||||
# var app = express();
|
||||
#
|
||||
# app.use('/', function (req, res, next) {
|
||||
# res.end("Hello, World!");
|
||||
# });
|
||||
#
|
||||
# module.exports = app;</code></pre>
|
||||
# ```
|
||||
#
|
||||
# `server.js`:
|
||||
#
|
||||
# ```js
|
||||
# 'use strict';
|
||||
#
|
||||
# var http = require('http');
|
||||
# var app = require('./app.js');
|
||||
#
|
||||
# http.createServer(app).listen(8080, function () {
|
||||
# console.info('Listening on', this.address());
|
||||
# });
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# npm start
|
||||
# ```
|
||||
#
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
pkg_cmd_name="node"
|
||||
|
||||
pkg_get_current_version() {
|
||||
# 'node --version' has output in this format:
|
||||
# v12.8.0
|
||||
# This trims it down to just the version number:
|
||||
# 12.8.0
|
||||
echo "$(node --version 2>/dev/null | head -n 1 | cut -d' ' -f1 | sed 's:^v::')"
|
||||
}
|
||||
|
||||
pkg_format_cmd_version() {
|
||||
# 'node v12.8.0' is the canonical version format for node
|
||||
my_version="$1"
|
||||
echo "$pkg_cmd_name v$my_version"
|
||||
}
|
||||
|
||||
pkg_link_src_dst() {
|
||||
# 'pkg_dst' will default to $HOME/.local/opt/node
|
||||
# 'pkg_src' will be the installed version, such as to $HOME/.local/opt/node-v12.8.0
|
||||
rm -rf "$pkg_dst"
|
||||
ln -s "$pkg_src" "$pkg_dst"
|
||||
}
|
||||
|
||||
pkg_pre_install() {
|
||||
# web_* are defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
|
||||
# if selected version is installed, re-link it and quit
|
||||
webi_check
|
||||
|
||||
# will save to ~/Downloads/$WEBI_PKG_FILE by default
|
||||
webi_download
|
||||
|
||||
# supported formats (.xz, .tar.*, .zip) will be extracted to $WEBI_TMP
|
||||
webi_extract
|
||||
}
|
||||
|
||||
pkg_install() {
|
||||
pushd "$WEBI_TMP" 2>&1 >/dev/null
|
||||
|
||||
# remove the versioned folder, just in case it's there with junk
|
||||
rm -rf "$pkg_src"
|
||||
|
||||
# rename the entire extracted folder to the new location
|
||||
# (this will be "$HOME/.local/opt/node-v$WEBI_VERSION" by default)
|
||||
|
||||
# ex (full directory): ./node-v13-linux-amd64/bin/node.exe
|
||||
mv ./"$pkg_cmd_name"* "$pkg_src"
|
||||
|
||||
# ex (single file): ./caddy-v13-linux-amd64.exe
|
||||
#mv ./"$pkg_cmd_name"* "$pkg_dst_cmd"
|
||||
#chmod a+x "$pkg_dst_cmd"
|
||||
|
||||
# ex (single file, nested in directory): ./rg/rg-v13-linux-amd64
|
||||
#mv ./"$pkg_cmd_name"*/"$pkg_cmd_name"* "$pkg_commend_cmd"
|
||||
#chmod a+x "$pkg_dst_cmd"
|
||||
|
||||
popd 2>&1 >/dev/null
|
||||
}
|
||||
|
||||
pkg_post_install() {
|
||||
pkg_link_src_dst
|
||||
|
||||
# web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
|
||||
# Adds "$HOME/.local/opt/node/bin" to PATH
|
||||
webi_path_add "$pkg_dst_bin"
|
||||
}
|
||||
|
||||
pkg_post_install_message() {
|
||||
echo "Installed 'node' and 'npm'"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
pkg_cmd_name="node"
|
||||
|
||||
pkg_get_current_version() {
|
||||
# 'node --version' has output in this format:
|
||||
# v12.8.0
|
||||
# This trims it down to just the version number:
|
||||
# 12.8.0
|
||||
echo "$(node --version 2>/dev/null | head -n 1 | cut -d' ' -f1 | sed 's:^v::')"
|
||||
}
|
||||
|
||||
pkg_install() {
|
||||
# mkdir -p $HOME/.local/opt
|
||||
mkdir -p "$(dirname $pkg_src)"
|
||||
|
||||
# mv ./node* "$HOME/.local/opt/node-v14.4.0"
|
||||
mv ./"$pkg_cmd_name"* "$pkg_src"
|
||||
}
|
||||
|
||||
pkg_link() {
|
||||
# rm -f "$HOME/.local/opt/node"
|
||||
rm -f "$pkg_dst"
|
||||
|
||||
# ln -s "$HOME/.local/opt/node-v14.4.0" "$HOME/.local/opt/node"
|
||||
ln -s "$pkg_src" "$pkg_dst"
|
||||
}
|
||||
|
||||
pkg_done_message() {
|
||||
echo "Installed 'node' and 'npm' at $pkg_dst"
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
#
|
||||
# title: Node.js
|
||||
# homepage: https://nodejs.org
|
||||
# tagline: JavaScript V8 runtime
|
||||
# description: |
|
||||
# Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine
|
||||
# examples: |
|
||||
#
|
||||
# ### Hello World
|
||||
#
|
||||
# ```bash
|
||||
# node -e 'console.log("Hello, World!")'
|
||||
# > Hello, World!
|
||||
# ```
|
||||
#
|
||||
# ### A Simple Web Server
|
||||
#
|
||||
# `server.js`:
|
||||
#
|
||||
# ```bash
|
||||
# var http = require('http');
|
||||
# var app = function (req, res) {
|
||||
# res.end('Hello, World!');
|
||||
# };
|
||||
# http.createServer(app).listen(8080, function () {
|
||||
# console.info('Listening on', this.address());
|
||||
# });
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# node server.js
|
||||
# ```
|
||||
#
|
||||
# ### An Express App
|
||||
#
|
||||
# ```bash
|
||||
# mkdir my-server
|
||||
# pushd my-server
|
||||
# npm init
|
||||
# npm install --save express
|
||||
# ```
|
||||
#
|
||||
# `app.js`:
|
||||
#
|
||||
# ```js
|
||||
# 'use strict';
|
||||
#
|
||||
# var express = require('express');
|
||||
# var app = express();
|
||||
#
|
||||
# app.use('/', function (req, res, next) {
|
||||
# res.end("Hello, World!");
|
||||
# });
|
||||
#
|
||||
# module.exports = app;</code></pre>
|
||||
# ```
|
||||
#
|
||||
# `server.js`:
|
||||
#
|
||||
# ```js
|
||||
# 'use strict';
|
||||
#
|
||||
# var http = require('http');
|
||||
# var app = require('./app.js');
|
||||
#
|
||||
# http.createServer(app).listen(8080, function () {
|
||||
# console.info('Listening on', this.address());
|
||||
# });
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# npm start
|
||||
# ```
|
||||
#
|
||||
|
||||
This is a comment... because... poor choices I made.
|
||||
|
||||
Don't worry, this will be yaml or markdown in the... sometime... future
|
||||
+1
-1
@@ -140,7 +140,7 @@ module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
getAllReleases(require('@root/request')).then(function (all) {
|
||||
all = require('../_common/normalize.js')(all);
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
//console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# title: Pathman
|
||||
# homepage: https://git.rootprojects.org/root/pathman
|
||||
# tagline: cross-platform PATH management for bash, zsh, fish, cmd.exe, and PowerShell
|
||||
# description: |
|
||||
# Manages PATH on various OSes and shells
|
||||
# - Mac, Windows, Linux
|
||||
# - Bash, Zsh, Fish
|
||||
# - Command, Powershell
|
||||
# examples: |
|
||||
# ```bash
|
||||
# pathman add ~/.local/bin
|
||||
# ```
|
||||
# <br/>
|
||||
#
|
||||
# ```bash
|
||||
# pathman remove ~/.local/bin
|
||||
# ```
|
||||
# <br/>
|
||||
#
|
||||
# ```bash
|
||||
# pathman list
|
||||
# ```
|
||||
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
# Test if in PATH
|
||||
set +e
|
||||
my_pathman=$(command -v pathman)
|
||||
set -e
|
||||
if [ -n "$my_pathman" ]; then
|
||||
# TODO test pathman version
|
||||
# if [ "$WEBI_VERSION" == "$(pathman version | cut -d ' ' -f2)" ]; then
|
||||
if [ "$my_pathman" != "$HOME/.local/bin/pathman" ]; then
|
||||
echo "a pathman installation (which make take precedence) exists at:"
|
||||
echo " $my_pathman"
|
||||
echo ""
|
||||
fi
|
||||
echo "pathman already installed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# TODO use webi_download via releases.js
|
||||
webi_download "https://rootprojects.org/pathman/dist/$(uname -s)/$(uname -m)/pathman" "$HOME/.local/bin/pathman"
|
||||
|
||||
# TODO use webi_extract
|
||||
chmod +x "$HOME/.local/bin/pathman"
|
||||
|
||||
# add to ~/.local/bin to PATH even if pathman is elsewhere
|
||||
# TODO pathman needs silent option and debug output (quiet "already exists" output)
|
||||
"$HOME/.local/bin/pathman" add ~/.local/bin # > /dev/null 2> /dev/null
|
||||
# TODO inform user to add to path, apart from pathman?
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
|
||||
# title: Pathman
|
||||
# homepage: https://git.rootprojects.org/root/pathman
|
||||
# tagline: cross-platform PATH management for bash, zsh, fish, cmd.exe, and PowerShell
|
||||
# description: |
|
||||
# Manages PATH on various OSes and shells
|
||||
# - Mac, Windows, Linux
|
||||
# - Bash, Zsh, Fish
|
||||
# - Command, Powershell
|
||||
# examples: |
|
||||
# ```bash
|
||||
# pathman add ~/.local/bin
|
||||
# ```
|
||||
# <br/>
|
||||
#
|
||||
# ```bash
|
||||
# pathman remove ~/.local/bin
|
||||
# ```
|
||||
# <br/>
|
||||
#
|
||||
# ```bash
|
||||
# pathman list
|
||||
# ```
|
||||
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
pkg_cmd_name="pathman"
|
||||
WEBI_SINGLE=true
|
||||
|
||||
pkg_get_current_version() {
|
||||
echo $(pathman version 2>/dev/null | head -n 1 | cut -d ' ' -f2 | sed 's:^v::')
|
||||
}
|
||||
|
||||
x_pkg_pre_install() {
|
||||
# Test if in PATH
|
||||
set +e
|
||||
my_pathman=$(command -v pathman)
|
||||
set -e
|
||||
if [ -n "$my_pathman" ]; then
|
||||
# TODO test pathman version
|
||||
# if [ "$WEBI_VERSION" == "$(pathman version | cut -d ' ' -f2)" ]; then
|
||||
if [ "$my_pathman" != "$HOME/.local/bin/pathman" ]; then
|
||||
echo "a pathman installation (which make take precedence) exists at:"
|
||||
echo " $my_pathman"
|
||||
echo ""
|
||||
fi
|
||||
echo "pathman already installed"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
x_pkg_install() {
|
||||
# TODO use webi_download via releases.js
|
||||
mkdir -p "$HOME/.local/bin/"
|
||||
webi_check
|
||||
webi_download
|
||||
webi_download
|
||||
# webi_download "https://rootprojects.org/pathman/dist/$(uname -s)/$(uname -m)/pathman"
|
||||
mv "$HOME/Downloads/pathman-v0.5.2" "$HOME/.local/bin/pathman"
|
||||
chmod +x "$HOME/.local/bin/pathman"
|
||||
}
|
||||
|
||||
x_pkg_link() {
|
||||
true
|
||||
}
|
||||
|
||||
pkg_post_install() {
|
||||
# add to ~/.local/bin to PATH even if pathman is elsewhere
|
||||
# TODO pathman needs silent option and debug output (quiet "already exists" output)
|
||||
# TODO inform user to add to path, apart from pathman?
|
||||
"$HOME/.local/bin/pathman" add "$HOME/.local/bin"
|
||||
}
|
||||
|
||||
pkg_done_message() {
|
||||
true
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
# title: Ripgrep
|
||||
# homepage: https://github.com/BurntSushi/ripgrep
|
||||
# tagline: a modern drop-in grep replacement
|
||||
# alias: rg
|
||||
# description: |
|
||||
# `rg` is a drop-in replacement for `grep`, that respects `.gitignore` and `.ignore`, has all of the sensible default options you want (colors, numbers, etc) turned on by default, is written in Rust, and simply outperforms grep in every imaginable way. R.I.P. grep.
|
||||
# examples: |
|
||||
#
|
||||
# ```bash
|
||||
# rg <search-term> # searches recursively, ignoing .git, node_modules, etc
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# rg 'function doStuff'
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# rg 'doStuff\(.*\)'
|
||||
# ```
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
###################
|
||||
# Install ripgrep #
|
||||
###################
|
||||
|
||||
new_rg="${HOME}/.local/bin/rg"
|
||||
|
||||
# Test for existing version
|
||||
set +e
|
||||
cur_rg="$(command -v rg)"
|
||||
set -e
|
||||
if [ -n "$cur_rg" ]; then
|
||||
cur_ver=$(rg --version | head -n 1 | cut -d ' ' -f 2)
|
||||
if [ "$cur_ver" == "$WEBI_VERSION" ]; then
|
||||
echo "ripgrep v$WEBI_VERSION already installed at $cur_rg"
|
||||
exit 0
|
||||
elif [ "$cur_rg" != "$new_rg" ]; then
|
||||
echo "WARN: possible conflict with ripgrep v$WEBI_VERSION at $cur_rg"
|
||||
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 ripgrep 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 ripgrep v${WEBI_VERSION} as "$new_rg"
|
||||
mv ./ripgrep-*/rg "$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 'rg'"
|
||||
echo ""
|
||||
@@ -0,0 +1,24 @@
|
||||
set -e
|
||||
set -u
|
||||
|
||||
###################
|
||||
# Install ripgrep #
|
||||
###################
|
||||
|
||||
new_rg="${HOME}/.local/bin/rg"
|
||||
WEBI_SINGLE=true
|
||||
|
||||
pkg_get_current_version() {
|
||||
echo $(rg --version 2>/dev/null | head -n 1 | cut -d ' ' -f 2)
|
||||
}
|
||||
|
||||
pkg_install() {
|
||||
# $HOME/.local/xbin
|
||||
mkdir -p "$pkg_src_bin"
|
||||
|
||||
# mv ./ripgrep-*/rg "$HOME/.local/xbin/rg-v11.1.0"
|
||||
mv ./ripgrep-*/rg "$pkg_src_cmd"
|
||||
|
||||
# chmod a+x "$HOME/.local/xbin/rg-v11.1.0"
|
||||
chmod a+x "$pkg_src_cmd"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# title: Ripgrep
|
||||
# homepage: https://github.com/BurntSushi/ripgrep
|
||||
# tagline: a modern drop-in grep replacement
|
||||
# alias: rg
|
||||
# description: |
|
||||
# `rg` is a drop-in replacement for `grep`, that respects `.gitignore` and `.ignore`, has all of the sensible default options you want (colors, numbers, etc) turned on by default, is written in Rust, and simply outperforms grep in every imaginable way. R.I.P. grep.
|
||||
# examples: |
|
||||
#
|
||||
# ```bash
|
||||
# rg <search-term> # searches recursively, ignoing .git, node_modules, etc
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# rg 'function doStuff'
|
||||
# ```
|
||||
#
|
||||
# ```bash
|
||||
# rg 'doStuff\(.*\)'
|
||||
# ```
|
||||
|
||||
END
|
||||
@@ -20,6 +20,8 @@
|
||||
# webi rustlang
|
||||
# ```
|
||||
|
||||
{
|
||||
|
||||
if [ -f "$HOME/.local/bin/webi" ]; then
|
||||
set +e
|
||||
cur_webi="$(command -v webi)"
|
||||
@@ -32,3 +34,5 @@ else
|
||||
# for when this file is run on its own, not from webinstall.dev
|
||||
echo "Install any other package via https://webinstall.dev and webi will be installed as part of the bootstrap process"
|
||||
fi
|
||||
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
{
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
#WEBI_PKG=
|
||||
#WEBI_NAME=
|
||||
# TODO should this be BASEURL instead?
|
||||
#WEBI_HOST=
|
||||
#WEBI_RELEASES=
|
||||
#WEBI_CSV=
|
||||
#WEBI_TAG=
|
||||
#WEBI_VERSION=
|
||||
#WEBI_MAJOR=
|
||||
#WEBI_MINOR=
|
||||
#WEBI_PATCH=
|
||||
# TODO not sure if BUILD is the best name for this
|
||||
#WEBI_BUILD=
|
||||
#WEBI_LTS=
|
||||
#WEBI_CHANNEL=
|
||||
#WEBI_EXT=
|
||||
#WEBI_PKG_URL=
|
||||
#WEBI_PKG_FILE=
|
||||
export WEBI_HOST
|
||||
|
||||
##
|
||||
## Set up tmp, download, and install directories
|
||||
##
|
||||
|
||||
WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-${WEBI_PKG:-}.XXXXXXXX)"}
|
||||
|
||||
mkdir -p "$HOME/Downloads"
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
mkdir -p "$HOME/.local/opt"
|
||||
|
||||
##
|
||||
## Detect http client
|
||||
##
|
||||
set +e
|
||||
export WEBI_CURL="$(command -v curl)"
|
||||
export WEBI_WGET="$(command -v wget)"
|
||||
set -e
|
||||
|
||||
webi_check() {
|
||||
# Test for existing version
|
||||
set +e
|
||||
my_current_cmd="$(command -v "$pkg_cmd_name")"
|
||||
set -e
|
||||
if [ -n "$my_current_cmd" ]; then
|
||||
pkg_current_version="$(pkg_get_current_version)"
|
||||
# remove trailing '.0's for golang's sake
|
||||
my_current_version="$(echo $pkg_current_version | sed 's:\.0::g')"
|
||||
my_src_version="$(echo $WEBI_VERSION | sed 's:\.0::g')"
|
||||
if [ -n "$(command -v pkg_format_cmd_version)" ]; then
|
||||
my_canonical_name="$(pkg_format_cmd_version "$WEBI_VERSION")"
|
||||
else
|
||||
#my_canonical_name="$WEBI_NAME $WEBI_VERSION"
|
||||
my_canonical_name="$pkg_cmd_name v$WEBI_VERSION"
|
||||
fi
|
||||
if [ "$my_src_version" == "$my_current_version" ]; then
|
||||
echo "$my_canonical_name already installed at $my_current_cmd"
|
||||
exit 0
|
||||
else
|
||||
if [ "$my_current_cmd" != "$pkg_dst_cmd" ]; then
|
||||
echo "WARN: possible conflict between $my_canonical_name and $pkg_current_version at $my_current_cmd"
|
||||
fi
|
||||
if [ -x "$pkg_src_cmd" ]; then
|
||||
pkg_link_src_dst
|
||||
echo "switched to $my_canonical_name at $pkg_src"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
webi_download() {
|
||||
if [ -n "${1:-}" ]; then
|
||||
my_url="$1"
|
||||
else
|
||||
if [ "error" == "$WEBI_CHANNEL" ]; then
|
||||
echo "Could not find $WEBI_NAME v$WEBI_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
my_url="$WEBI_PKG_URL"
|
||||
echo "Downloading $WEBI_NAME v$WEBI_VERSION"
|
||||
fi
|
||||
if [ -n "${2:-}" ]; then
|
||||
my_dl="$2"
|
||||
else
|
||||
my_dl="$HOME/Downloads/$WEBI_PKG_FILE"
|
||||
fi
|
||||
|
||||
if [ -n "$WEBI_WGET" ]; then
|
||||
# wget has resumable downloads
|
||||
# TODO wget -c --content-disposition "$my_url"
|
||||
set +e
|
||||
wget -q --show-progress -c "$my_url" --user-agent="wget $WEBI_UA" -O "$my_dl"
|
||||
if ! [ $? -eq 0 ]; then
|
||||
echo "failed to download from $WEBI_PKG_URL"
|
||||
exit 1
|
||||
fi
|
||||
set -e
|
||||
else
|
||||
# BSD curl is non-resumable, hence we don't bother
|
||||
# TODO curl -fsSL --remote-name --remote-header-name --write-out "$my_url"
|
||||
curl -fSL "$my_url" -H "User-Agent: curl $WEBI_UA" -o "$my_dl"
|
||||
fi
|
||||
}
|
||||
|
||||
webi_extract() {
|
||||
pushd "$WEBI_TMP" 2>&1 >/dev/null
|
||||
if [ "tar" == "$WEBI_EXT" ]; then
|
||||
echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE"
|
||||
tar xf "$HOME/Downloads/$WEBI_PKG_FILE"
|
||||
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"
|
||||
exit 1
|
||||
fi
|
||||
popd 2>&1 >/dev/null
|
||||
}
|
||||
|
||||
webi_path_add() {
|
||||
# make sure that we don't recursively install pathman with webi
|
||||
my_path="$PATH"
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
set +e
|
||||
my_pathman=$(command -v pathman)
|
||||
set -e
|
||||
export PATH="$my_path"
|
||||
|
||||
# install pathman if not already installed
|
||||
if [ -z "$my_pathman" ]; then
|
||||
"$HOME/.local/bin/webi" pathman
|
||||
"$HOME/.local/bin/pathman" add "$HOME/.local/bin"
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
fi
|
||||
|
||||
# in case pathman was recently installed and the PATH not updated
|
||||
"$HOME/.local/bin/pathman" add "$1"
|
||||
}
|
||||
|
||||
##
|
||||
##
|
||||
## BEGIN user-submited script
|
||||
##
|
||||
##
|
||||
|
||||
{{ installer }}
|
||||
|
||||
##
|
||||
##
|
||||
## END user-submitted script
|
||||
##
|
||||
##
|
||||
|
||||
if [ -n "$(command -v pkg_install)" ]; then
|
||||
pkg_cmd_name="${pkg_cmd_name:-$WEBI_NAME}"
|
||||
|
||||
pkg_dst="${pkg_dst:-$HOME/.local/opt/$pkg_cmd_name}"
|
||||
pkg_dst_bin="${pkg_dst_bin:-$pkg_dst/bin}"
|
||||
pkg_dst_cmd="${pkg_dst_cmd:-$pkg_dst_bin/$pkg_cmd_name}"
|
||||
|
||||
pkg_src="${pkg_src:-$HOME/.local/opt/$pkg_cmd_name-v$WEBI_VERSION}"
|
||||
pkg_src_bin="${pkg_src_bin:-$pkg_src/bin}"
|
||||
pkg_src_cmd="${pkg_src_cmd:-$pkg_src_bin/$pkg_cmd_name}"
|
||||
|
||||
[ -n "$(command -v pkg_pre_install)" ] && pkg_pre_install
|
||||
|
||||
echo "Installing '$pkg_cmd_name' v$WEBI_VERSION as $pkg_src_cmd"
|
||||
pkg_install
|
||||
|
||||
[ -n "$(command -v pkg_post_install)" ] && pkg_post_install
|
||||
|
||||
if [ -n "$(command -v pkg_post_install_message)" ]; then
|
||||
pkg_post_install_message
|
||||
else
|
||||
echo "Installed '$pkg_cmd_name' v$WEBI_VERSION as $pkg_src_cmd"
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
|
||||
rm -rf "$WEBI_TMP"
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user