X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=README.md;h=376623e462d43529322e40c49669c03e5d839f0b;hb=4edf137e5d6b65f9ac847db6694ac387c7e91f3e;hp=c082b0f62141597a3fb027898bffb7b21de4bd91;hpb=9469f29e2f6e6584dcedf269976eaf726a378fea;p=webi-installers%2F.git diff --git a/README.md b/README.md index c082b0f..376623e 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,80 @@ -# packages +# [webi-installers](https://github.com/webinstall/webi-installers) -Primary and community-submitted packages for -[webinstall.dev](https://webinstall.dev) +> [webi](https://webinstall.dev) is how developers install their tools -# Guidelines +[![webinstall-dev-ogimage-github](https://user-images.githubusercontent.com/122831/129465590-136b5a8a-f8f5-4e8d-a010-784eaa9f21bb.png)](https://webinstall.dev) -- Should install to `./local/opt/-` +- no `sudo` +- no package manager +- no messing with system permissions +- in short: no nonsense + +```bash +curl https://webinstall.dev/webi | bash +``` + +This repository contains the primary and community-submitted packages for +[webinstall.dev](https://webinstall.dev). + +# How webi works + +- Contacts official release APIs for download URLs +- Selects the appropriate package version and archive format +- Installs to `$HOME/.local/opt` or `$HOME/.local/bin`, as appropriate. +- Updates `PATH` via `$HOME/.config/envman/PATH.env` +- Symlinks or copies current selected version + +More technically: + +1. `/releases.js` transforms the package's release API into a common + format + - (i.e. HTML, CSV, TAB, or JSON into a specific JSON format) + - common release APIs are in `_common/` (i.e. `_common/github.js`) +2. `_webi/bootstrap.sh` is a template that exchanges system information for a + correct installer + - contructs a user agent with os, cpu, and utility info (i.e. `macos`, + `amd64`, can unpack `tar,zip,xz`) +3. `_webi/template.sh` is the base installer template with common functions for + - checking versions + - downloading & unpacking + - updating PATH + - (re-)linking directories +4. `/install.sh` may provide functions to override `_webi/template.sh` +5. Recap: + - `curl https://webinstall.dev/` => `bootstrap-.sh` + - `bash bootstrap-.sh` => + `https://webinstall.dev/api/installers/@.sh?formats=zip,tar` + - `bash install-.sh` => download, unpack, move, link, update PATH + +# Philosophy (for package authors / maintainers publishing with webi) + +- Should install to `$HOME/.local/opt/-` or `$HOME/.local/bin` - Should not need `sudo` (except perhaps for a one-time `setcap`, etc) -- Follow the example of - , - , or - +- Examples: + - Full Packages: + - Node.js: + - Golang: + - PostgreSQL: + - Single-Binary Installers: + - Caddy: + - Ripgrep: + - Gitea: + - Convenience Scripts: + - Prettier: + - Rust-lang: + - vim-sensible: + ## Creating an Installer -An install consists of 5 parts in two files: +An install consists of 5 parts in 4 files: ``` my-new-package/ + - README.md (package info in frontmatter) - releases.js - - my-new-package.bash + - install.sh (bash) + - install.ps1 (PowerShell) ``` 1. Create Description @@ -38,23 +93,40 @@ 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 +git clone git@github.com:webinstall/packages.git +pushd packages +npm install +``` + +```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`: +`README.md`: -```` -# 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: | -# ```bash -# node -e 'console.log("Hello, World!")' -# > Hello, World! -# ``` +````md +--- +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 +--- + +```bash +node -e 'console.log("Hello, World!")' +> Hello, World! +``` ```` ### 1. Fetch Releases @@ -94,13 +166,13 @@ pkg_cmd_name="foobar" # These are used for symlinks, PATH, and test commands pkg_dst="$HOME/.local/opt/foobar" -pkg_dst_bin="$HOME/.local/opt/foobar/bin" pkg_dst_cmd="$HOME/.local/opt/foobar/bin/foobar" +#pkg_dst_bin="$(dirname "$pkg_dst_cmd")" # These are the _real_ locations for the above pkg_src="$HOME/.local/opt/foobar-v$WEBI_VERSION" -pkg_src_bin="$HOME/.local/opt/foobar-v$WEBI_VERSION/bin" pkg_src_cmd="$HOME/.local/opt/foobar-v$WEBI_VERSION/bin/foobar" +#pkg_src_bin="$(dirname "$pkg_src_cmd")" ``` (required) A version check function that strips all non-version junk @@ -115,36 +187,34 @@ 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 -See `webi/template.bash` +See `webi/template.sh` These variables will be set by the server: -``` +```bash WEBI_PKG=example@v1 -WEBI_NAME=example WEBI_TAG=v1 WEBI_HOST=https://webinstall.dev WEBI_RELEASES=https://webinstall.dev/api/releases/example@v1?os=macos&arch=amd64&pretty=true @@ -160,30 +230,66 @@ WEBI_PKG_URL=https://cdn.example.com/example-macos-amd64.tar.gz WEBI_PKG_FILE=example-macos-amd64.tar.gz ``` +```bash +PKG_NAME=example +PKG_OSES=macos,linux,windows +PKG_ARCHES=amd64,arm64,x86 +PKG_FORMATS=zip,xz +``` + ```bash WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-foobar.XXXXXXXX)"} +WEBI_SINGLE="" ``` ```bash webi_check # Checks to see if the selected version is already installed (and re-links if so) -webi_download # Downloads the selected release to $HOME/Downloads/.tar.gz +webi_download # Downloads the selected release to $HOME/Downloads/webi/.tar.gz webi_extract # Extracts the download to /tmp/-/ 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_path_add $pkg_dst_bin` ``` # Roadmap - Wrap release APIs to unify and expose - - [x] Golang - - [x] Node - - [x] Flutter - - - Started at - - - [ ] git - - Note: do all platforms expose tar/zip releases with the same URLs? - - [ ] npm - - [x] github (see ripgrep) - - [x] gitea (see serviceman) -- [ ] Support git urls (i.e. `@github.com/node/node`) +- [ ] Support more Windows packages +- [ ] Support arbitrary git urls (i.e. `@github.com/node/node`) - (maybe `ghi node/node` for github specifically) +- [ ] Support git as an archive format + +