diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | Makefile | 66 | ||||
-rw-r--r-- | README.md | 30 | ||||
-rw-r--r-- | default.nix | 160 | ||||
-rw-r--r-- | paku.json | 41 | ||||
-rw-r--r-- | paku.lock | 115 | ||||
-rwxr-xr-x | src/bin/paku | 813 | ||||
-rw-r--r-- | src/org/euandre/packages.scm | 155 | ||||
-rwxr-xr-x | tests/checks/deb.sh | 23 | ||||
-rwxr-xr-x | tests/vm-check.sh | 86 |
11 files changed, 1073 insertions, 421 deletions
@@ -2,3 +2,6 @@ /tests/internet/etc/postfix/main.cf /tests/internet/etc/dkimproxyout.conf /tests/internet/etc/dovecot/dovecot.conf +/.paku/ +/debian.mk +/public/ diff --git a/CHANGELOG.md b/CHANGELOG.md index ff5715d..cdbc3cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,4 +9,4 @@ ## Security --> -Changelog for [package-repository](https://euandreh.xyz/package-repository/en/). +Changelog for [package-repository](https://euandre.org/s/package-repository/en/). @@ -12,7 +12,8 @@ -all: EuAndreh.key guix nix +all: EuAndreh.key guix nix debian + test-config-files = \ @@ -23,10 +24,11 @@ test-config-files = \ derived-assets = \ $(test-config-files) \ -guix: guix-packages guix-services +guix: result-packages result-services -guix-packages: - guix build -v3 -Lsrc/ -K \ +result-packages: + perl src/bin/paku guix > src/org/euandre/packages.scm + guix build -r $@ -v3 -Lsrc/ -K \ -f src/org/euandre/packages.scm \ -f src/org/euandre/queue.scm \ @@ -40,36 +42,62 @@ internet-files = \ /etc/dkimproxyout.conf \ /etc/dovecot/dovecot.conf \ -guix-services-local: guix-packages - rm -f result-local - guix system -v3 -Lsrc/ -K -r result-local build tests/local/system.scm +result-local: result-packages + guix system -v3 -Lsrc/ -K -r $@ build tests/local/system.scm for f in $(local-files); do \ diff -U5 --color=always result-local$$f tests/local$$f; \ done -guix-services-internet: guix-packages $(test-config-files) - rm -f result-internet - guix system -v3 -Lsrc/ -K -r result-internet build tests/internet/system.scm +result-internet: result-packages + $(MAKE) $(test-config-files) + guix system -v3 -Lsrc/ -K -r $@ build tests/internet/system.scm for f in $(internet-files); do \ diff -U5 --color=always result-internet$$f tests/internet$$f; \ done -guix-services: guix-services-local guix-services-internet +result-services: result-local result-internet + + +nix: result + +default.nix: paku.lock + perl src/bin/paku nix > $@ -nix: +result: nix-build build.nix -refresh: - sh scripts/paku -rg +debian.mk: paku.lock + perl src/bin/paku makefile > $@ + +debian: debian.mk + $(MAKE) -f debian.mk + + +public/debian: debian.mk + mkdir -p $(@D) + rsync -avzP --delete `$(MAKE) -s -f debian.mk public-dir`/ $@/ + +public/paku.html: paku.lock src/bin/paku + mkdir -p $(@D) + perl src/bin/paku html > $@ + +public: public/debian public/paku.html + + +upload: public + rsync -avzP --delete public/ euandre.org:/srv/www/s/package-repository/ + +HTTP-REMOTE = 'https://euandre.org/s/package-repository' +check-ubuntu: + sh tests/vm-check.sh -x -t deb -H ubuntu-x86_64-headless -r $(HTTP-REMOTE) + +check: check-ubuntu -check: clean: rm -rf \ - $(derived-assets) result* .paku/ deb/ - -public: + $(derived-assets) result* .paku/ public/ debian.mk -EuAndreh.key: +EuAndreh.key: paku.lock gpg --armour --export eu@euandre.org > $@ @@ -6,7 +6,7 @@ packagers. See the list of packages [online]. -[online]: https://euandreh.xyz/package-repository/paku.html +[online]: https://euandre.org/s/package-repository/paku.html ## How to add this to different OSes @@ -18,8 +18,8 @@ Add this channel to your `~/.config/guix/channels.scm`: ```scheme (cons* (channel - (name 'xyz-euandreh) - (url "git://euandreh.xyz/package-repository") + (name 'org-euandre) + (url "git://euandre.org/package-repository") (branch "main") (introduction (make-channel-introduction @@ -39,20 +39,22 @@ Adding the overlay to your `/etc/nixos/configuration.nix`: nixpkgs = { overlays = [ (import (fetchTarball { - url = "https://euandreh.xyz/package-repository.git/snapshot/package-repository-main.tar.gz"; + url = "https://euandre.org/git/package-repository/snapshot/package-repository-main.tar.gz"; }) { inherit pkgs; }) ]; }; ``` -<!-- ### Debian ```shell -$ wget -O- https://package-repository.euandreh.xyz/EuAndreh.key | sudo apt-key add - -$ sudo apt-add-repository 'deb https://package-repository.euandreh.xyz/debian/ stable main' +$ wget -qO- https://euandre.org/s/package-repository/debian/public-key.asc | sudo tee /etc/apt/trusted.gpg.d/euandre.org.asc +$ sudo apt-add-repository 'deb https://euandre.org/s/package-repository/debian ./' ``` ---> + +### Homebrew + + ## Contributing @@ -75,12 +77,12 @@ Send contributions to the [mailing list] via ## Links -- [homepage](https://euandreh.xyz/package-repository/en/) -- [source code](https://euandreh.xyz/package-repository.git/) -- [bug tracking](https://euandreh.xyz/package-repository/TODOs.html) +- [homepage](https://euandre.org/s/package-repository/en/) +- [source code](https://euandre.org/git/package-repository/) +- [bug tracking](https://euandre.org/s/package-repository/TODOs.html) - [mailing list] -- [CI logs](https://euandreh.xyz/package-repository/ci.html) -- [CHANGELOG](https://euandreh.xyz/package-repository/en/CHANGELOG.html) +- [CI logs](https://euandre.org/s/package-repository/ci.html) +- [CHANGELOG](https://euandre.org/s/package-repository/en/CHANGELOG.html) [mailing list]: https://lists.sr.ht/~euandreh/public-inbox?search=%5Bpackage-repository%5D @@ -91,4 +93,4 @@ The code is licensed under [GNU Affero General Public License v3.0 or later][AGPL-3.0-or-later] (AGPL-3.0-or-later). -[AGPL-3.0-or-later]: https://euandreh.xyz/package-repository.git/tree/COPYING +[AGPL-3.0-or-later]: https://euandre.org/git/package-repository/tree/COPYING diff --git a/default.nix b/default.nix index 016f4d6..54dd0ff 100644 --- a/default.nix +++ b/default.nix @@ -1,33 +1,179 @@ { pkgs }: self: super: { - org-euandre = { + org-euandre = rec { + git-permalink-0-1-0 = pkgs.stdenv.mkDerivation rec { + name = "git-permalink"; + version = "v0.1.0"; + + src = fetchTarball { + url = + "https://euandre.org/git/git-permalink/snapshot/git-permalink-v0.1.0.tar.xz"; + sha256 = "1jb0rgcj5b4bkm5gds3l0dymf3gd644r2njmirs9345vf54if45y"; + }; + + nativeBuildInputs = with pkgs; [ + ]; + + buildInputs = with pkgs; [ + ]; + + makeFlags = [ "PREFIX=$(out)" ]; + + doCheck = true; + enableParallelBuilding = true; + + meta = with pkgs.lib; { + description = "Git extension to generate web permalinks of files in a repository"; + longDescription = '' + It knows about many of the existing code forges, but allows for URL + template overrides to be used on custom domains or deployments via git + config. + ''; + homepage = "https://euandre.org/s/git-permalink/"; + changelog = "https://euandre.org/s/git-permalink/CHANGELOG.html"; + downloadPage = "https://euandre.org/s/git-permalink/#releases"; + license = licenses.agpl3; + platforms = platforms.unix; + }; + }; + git-permalink-0-2-0 = pkgs.stdenv.mkDerivation rec { + name = "git-permalink"; + version = "v0.2.0"; + + src = fetchTarball { + url = + "https://euandre.org/git/git-permalink/snapshot/git-permalink-v0.2.0.tar.xz"; + sha256 = "1bzx4gdfc87jfshaqifxpc3llp2j98wkzjjslzwbrqn59jzakxc9"; + }; + + nativeBuildInputs = with pkgs; [ + ]; + + buildInputs = with pkgs; [ + ]; + + makeFlags = [ "PREFIX=$(out)" ]; + + doCheck = true; + enableParallelBuilding = true; + + meta = with pkgs.lib; { + description = "Git extension to generate web permalinks of files in a repository"; + longDescription = '' + It knows about many of the existing code forges, but allows for URL + template overrides to be used on custom domains or deployments via git + config. + ''; + homepage = "https://euandre.org/s/git-permalink/"; + changelog = "https://euandre.org/s/git-permalink/CHANGELOG.html"; + downloadPage = "https://euandre.org/s/git-permalink/#releases"; + license = licenses.agpl3; + platforms = platforms.unix; + }; + }; + remembering-0-1-2 = pkgs.stdenv.mkDerivation rec { + name = "remembering"; + version = "v0.1.2"; + + src = fetchTarball { + url = + "https://euandre.org/git/remembering/snapshot/remembering-v0.1.2.tar.xz"; + sha256 = "1mrkyfcgz77hw7mpgqrnsaws9qng2awf8flslzf1s1gikk3zljns"; + }; + + nativeBuildInputs = with pkgs; [ + ]; + + buildInputs = with pkgs; [ + ]; + + makeFlags = [ "PREFIX=$(out)" ]; + + doCheck = true; + enableParallelBuilding = true; + + meta = with pkgs.lib; { + description = "Add memory to dmenu, fzf and similar tools"; + longDescription = '' + It can wrap such tools to accumulate preferences over time, and + re-arrange the input according to common picks. + ''; + homepage = "https://euandre.org/s/remembering/"; + changelog = "https://euandre.org/s/remembering/CHANGELOG.html"; + downloadPage = "https://euandre.org/s/remembering/#releases"; + license = licenses.agpl3; + platforms = platforms.unix; + }; + }; + td = td-latest; + td-latest = pkgs.stdenv.mkDerivation rec { + name = "td"; + version = "4a8a7a2662c94b2581f587e9a4b81feba4f5e7d8"; + + src = fetchTarball { + url = + "https://euandre.org/git/td/snapshot/td-4a8a7a2662c94b2581f587e9a4b81feba4f5e7d8.tar.xz"; + sha256 = "1xqr2vc270jydk508pbkhcchmbg74w4bf83ch2d85nqja14r64n9"; + }; + + nativeBuildInputs = with pkgs; [ + ]; + + buildInputs = with pkgs; [ + ]; + + makeFlags = [ "PREFIX=$(out)" ]; + + doCheck = true; + enableParallelBuilding = true; + + meta = with pkgs.lib; { + description = "Minimalistic bug tracker CLI"; + longDescription = '' + Create and maintain a TODOs.md files as a bug database. + + It is a tool for distributed, offline issue tracking, reified as a simple text + file in the repository. + ''; + homepage = "https://euandre.org/s/td/"; + changelog = "https://euandre.org/s/td/CHANGELOG.html"; + downloadPage = "https://euandre.org/s/td/#releases"; + license = licenses.agpl3; + platforms = platforms.unix; + }; + }; + guile-heredoc = guile-heredoc-latest; guile-heredoc-latest = pkgs.stdenv.mkDerivation rec { name = "guile-heredoc"; version = "065435cdce609604e33b879b9be3e81ab89f3e7b"; src = fetchTarball { url = - "https://euandre.org/git/${name}/snapshot/${name}-${version}.tar.gz"; + "https://euandre.org/git/guile-heredoc/snapshot/guile-heredoc-065435cdce609604e33b879b9be3e81ab89f3e7b.tar.xz"; sha256 = "179qq17mgi4kakhj9w1dk26afljh5yad4j9ih9d8wms70x6h211m"; }; nativeBuildInputs = with pkgs; [ texinfo ]; + buildInputs = with pkgs; [ guile ]; + makeFlags = [ "PREFIX=$(out)" ]; doCheck = true; enableParallelBuilding = true; meta = with pkgs.lib; { - description = readFile "${src}/description"; # FIXME - longDescription = readFile "${src}/long-description"; - homepage = "https://euandre.org/projects/guile-heredoc/"; - changelog = "https://euandre.org/projects/guile-heredoc/CHANGELOG.html"; - downloadPage = "https://euandre.org/projects/guile-heredoc/#releases"; + description = "Guile heredoc syntax"; + longDescription = '' + Guile heredoc syntax long. + ''; + homepage = "https://euandre.org/s/guile-heredoc/"; + changelog = "https://euandre.org/s/guile-heredoc/CHANGELOG.html"; + downloadPage = "https://euandre.org/s/guile-heredoc/#releases"; license = licenses.agpl3; platforms = platforms.unix; }; @@ -1,18 +1,29 @@ { - "packages": [ - { - "name": "git-permalink", - "suffix": "", - "version": "0.3.1", - "type": "bin", - "description": "Git extension to generate web permalinks of files in a repository" + "tarball-template": "https://euandre.org/git/@name@/snapshot/@name@-@version@.tar.xz", + "repository-template": "https://euandre.org/git/@name@/", + "defaults": { + "format": ".tar.xz", + "maintainer": "EuAndreh <eu@euandre.org>", + "versions": { + "branches": [], + "tags": "all", + "latest": "main" }, - { - "name": "remembering", - "suffix": "", - "version": "0.2.1", - "type": "bin", - "description": "Add memory to dmenu, fzf and similar tools." - } - ] + "architectures": [ + "i386", + "x86_64", + "arm", + "aarch64" + ] + }, + "packages": { + "any": [ + "git-permalink", + "remembering", + "td" + ], + "all": [ + "guile-heredoc" + ] + } } diff --git a/paku.lock b/paku.lock new file mode 100644 index 0000000..186d3a2 --- /dev/null +++ b/paku.lock @@ -0,0 +1,115 @@ +{ + "guix": { + "module-use": [ + "guile", + "texinfo" + ] + }, + "mappings": { + "guile": { + "guix": "guile-3.0" + } + }, + "packages": [ + { + "name": "git-permalink", + "versions": [ + { + "native-inputs": [], + "inputs": [], + "name": "v0.1.0", + "sha256": "1jb0rgcj5b4bkm5gds3l0dymf3gd644r2njmirs9345vf54if45y", + "sha256FIXME": "07waci3y0xdlbr8gl1lzdbsiz0csnrshcm6f18cdzn7y97irhb15", + "url": "https://euandre.org/git/git-permalink/snapshot/git-permalink-v0.1.0.tar.xz", + "fname": "git-permalink-v0.1.0.tar.xz", + "maintainer": "EuAndreh <eu@euandre.org>", + "architectures": "any", + "type": "tag", + "description": "Git extension to generate web permalinks of files in a repository", + "long-description": "It knows about many of the existing code forges, but allows for URL\ntemplate overrides to be used on custom domains or deployments via git\nconfig." + }, + { + "native-inputs": [], + "inputs": [], + "name": "v0.2.0", + "sha256": "1bzx4gdfc87jfshaqifxpc3llp2j98wkzjjslzwbrqn59jzakxc9", + "sha256FIXME": "10qiigp29jamb23mdrf1yp0gqmihlsg931ibpiqpf4pn28l5d9ly", + "url": "https://euandre.org/git/git-permalink/snapshot/git-permalink-v0.2.0.tar.xz", + "fname": "git-permalink-v0.2.0.tar.xz", + "maintainer": "EuAndreh <eu@euandre.org>", + "architectures": "any", + "type": "tag", + "description": "Git extension to generate web permalinks of files in a repository", + "long-description": "It knows about many of the existing code forges, but allows for URL\ntemplate overrides to be used on custom domains or deployments via git\nconfig." + } + ] + }, + { + "name": "remembering", + "versions": [ + { + "native-inputs": [], + "inputs": [], + "name": "v0.1.2", + "sha256": "1mrkyfcgz77hw7mpgqrnsaws9qng2awf8flslzf1s1gikk3zljns", + "sha256FIXME": "1syzn41w4f754ihblwxcv3wn653lh92cgg6g06db1qrx3m2zvw5v", + "url": "https://euandre.org/git/remembering/snapshot/remembering-v0.1.2.tar.xz", + "fname": "remembering-v0.1.2.tar.xz", + "maintainer": "EuAndreh <eu@euandre.org>", + "architectures": "any", + "type": "tag", + "description": "Add memory to dmenu, fzf and similar tools", + "long-description": "It can wrap such tools to accumulate preferences over time, and\nre-arrange the input according to common picks." + } + ] + }, + { + "name": "td", + "architectures": "any", + "versions": [ + { + "native-inputs": [], + "inputs": [], + "name": "4a8a7a2662c94b2581f587e9a4b81feba4f5e7d8", + "sha256": "1xqr2vc270jydk508pbkhcchmbg74w4bf83ch2d85nqja14r64n9", + "sha256FIXME": "01g1vnlz1kch8j9zzaxyixih04azdvrfabfzg7xqny32h2p62md2", + "url": "https://euandre.org/git/td/snapshot/td-4a8a7a2662c94b2581f587e9a4b81feba4f5e7d8.tar.xz", + "fname": "td-4a8a7a2662c94b2581f587e9a4b81feba4f5e7d8.tar.xz", + "maintainer": "EuAndreh <eu@euandre.org>", + "architectures": "any", + "type": "latest", + "description": "Minimalistic bug tracker CLI", + "long-description": "Create and maintain a TODOs.md files as a bug database.\n\nIt is a tool for distributed, offline issue tracking, reified as a simple text\nfile in the repository." + } + ] + }, + { + "name": "guile-heredoc", + "versions": [ + { + "architectures": [ + "i386", + "x86_64", + "arm", + "aarch64" + ], + "native-inputs": [ + "texinfo" + ], + "inputs": [ + "guile" + ], + "type": "latest", + "name": "065435cdce609604e33b879b9be3e81ab89f3e7b", + "sha256": "179qq17mgi4kakhj9w1dk26afljh5yad4j9ih9d8wms70x6h211m", + "sha256FIXME": "1y1110bg4ki0dvn8hggxy34wg7ig4r3377nc84isnj3dydqm2vjd", + "url": "https://euandre.org/git/guile-heredoc/snapshot/guile-heredoc-065435cdce609604e33b879b9be3e81ab89f3e7b.tar.xz", + "fname": "guile-heredoc-065435cdce609604e33b879b9be3e81ab89f3e7b.tar.xz", + "maintainer": "EuAndreh <eu@euandre.org>", + "description": "Guile heredoc syntax", + "long-description": "Guile heredoc syntax long." + } + ] + } + ] +} diff --git a/src/bin/paku b/src/bin/paku index 8d5a967..eb89c47 100755 --- a/src/bin/paku +++ b/src/bin/paku @@ -1,369 +1,482 @@ -#!/bin/sh -set -eu +#!/usr/bin/env perl + +# FIXME: add html output + +use v5.34; +use warnings; +use feature 'signatures'; +no warnings ('experimental::signatures'); +use Getopt::Std (); +use JSON (); +use MIME::Base64 (); +use open IN => ':encoding(UTF-8)'; + +sub usage($fh) { + print $fh <<~'EOF' + Usage: + paku [-f FILE] FIXME + paku -h + EOF +} -TARBALL_TEMPLATE='https://euandreh.xyz/@NAME@.git/snapshot/@NAME@-@VERSION@.tar.gz' +sub help($fh) { + print $fh <<~'EOF' + + + Options: + -f FILE use data from FILE (default: paku.json) + -h, --help show this message + + + Generate package definitions for different package managers. -tarball_url() { - NAME="$1" - VERSION="$2" - echo "$TARBALL_TEMPLATE" | \ - sed -e "s/@NAME@/$NAME/g" \ - -e "s/@VERSION@/$VERSION/g" -} -gen_guix() { - GUIX_OUT="$(mktemp)" - - cat <<EOF >>"$GUIX_OUT" -(define-module (xyz euandreh packages) - #:use-module ((guix licenses) #:prefix license:) - #:use-module (guix gexp) - #:use-module (guix packages) - #:use-module (guix download) - #:use-module (guix build-system gnu)) -EOF - - for p in $(jq -r '.packages[] | @base64' < paku.json); do - NAME="$(echo "$p" | base64 --decode | jq -r '.name')" - SUFFIX="$(echo "$p" | base64 --decode | jq -r '.suffix')" - VERSION="$(echo "$p" | base64 --decode | jq -r '.version')" - TARBALL="$(tarball_url "$NAME" "$VERSION")" - SHA256="$(guix download "$TARBALL" | tail -n 1)" - JSON_CHECK_INPUTS="$(echo "$p" | base64 --decode | jq -r '.check_inputs')" - if [ "$JSON_CHECK_INPUTS" = 'null' ]; then - CHECK_INPUTS='' - else - INPUTS='' - for check_input in $(echo "$JSON_CHECK_INPUTS" | jq -r '.[]'); do - if [ "$INPUTS" = '' ]; then - INPUTS="(\"$check_input\" ,(specification->package \"$check_input\"))" - else - INPUTS="$INPUTS - (\"$check_input\" ,(specification->package \"$check_input\"))" - fi - done - - CHECK_INPUTS=" - (inputs - \`($INPUTS))" - fi - - cat <<EOF >>"$GUIX_OUT" - -(define-public $NAME$SUFFIX - (package - (name "$NAME$SUFFIX") - (version "$VERSION") - (source (origin - (method url-fetch) - (uri (string-append - "https://euandreh.xyz/$NAME.git/snapshot/$NAME-" - version - ".tar.gz")) - (sha256 - (base32 - "$SHA256")))) - (build-system gnu-build-system)$CHECK_INPUTS - (arguments \`(#:make-flags - (list (string-append "PREFIX=" %output)) - #:phases - (modify-phases %standard-phases - (delete 'configure)))) - (synopsis (file-append source "/description")) - (description (file-append source "/long-description")) - (home-page "https://euandreh.xyz/$NAME/") - (license license:agpl3+))) -EOF - done - - printf '\n(list' >>"$GUIX_OUT" - for p in $(jq -r '.packages[] | @base64' < paku.json); do - NAME="$(echo "$p" | base64 --decode | jq -r '.name')" - SUFFIX="$(echo "$p" | base64 --decode | jq -r '.suffix')" - - printf '\n %s%s' "$NAME" "$SUFFIX" >>"$GUIX_OUT" - done - printf ')\n' >>"$GUIX_OUT" - - mv "$GUIX_OUT" src/xyz/euandreh/packages.scm + Examples: + + FIXME: + + $ FIXME + EOF } -gen_nix() { - NIX_OUT="$(mktemp)" - - cat <<EOF >>"$NIX_OUT" -{ pkgs }: -self: super: { - xyz-euandreh = { -EOF - - for p in $(jq -r '.packages[] | @base64' < paku.json); do - NAME="$(echo "$p" | base64 --decode | jq -r '.name')" - SUFFIX="$(echo "$p" | base64 --decode | jq -r '.suffix')" - VERSION="$(echo "$p" | base64 --decode | jq -r '.version')" - TARBALL="$(tarball_url "$NAME" "$VERSION")" - SHA256="$(nix-prefetch-url --unpack "$TARBALL")" - JSON_CHECK_INPUTS="$(echo "$p" | base64 --decode | jq -r '.check_inputs')" - if [ "$JSON_CHECK_INPUTS" = 'null' ]; then - CHECK_INPUTS='' - else - INPUTS='[' - for check_input in $(echo "$JSON_CHECK_INPUTS" | jq -r '.[]'); do - INPUTS="$INPUTS $check_input" - done - INPUTS="$INPUTS ]" - - CHECK_INPUTS=" - checkInputs = with pkgs; $INPUTS;" - fi - - cat <<EOF >>"$NIX_OUT" - $NAME$SUFFIX = pkgs.stdenv.mkDerivation rec { - name = "$NAME"; - version = "$VERSION"; - - src = fetchTarball { - url = - "https://euandreh.xyz/\${name}.git/snapshot/\${name}-\${version}.tar.gz"; - sha256 = "$SHA256"; - }; - - makeFlags = [ "PREFIX=\$(out)" ]; -$CHECK_INPUTS - doCheck = true; - - meta = with pkgs.lib; { - description = readFile "\${src}/description"; - longDescription = readFile "\${src}/long-description"; - homepage = "https://euandreh.xyz/$NAME/"; - changelog = "https://euandreh.xyz/$NAME/CHANGELOG.html"; - downloadPage = "https://euandreh.xyz/$NAME/#releases"; - license = licenses.agpl3; - platforms = platforms.unix; - }; - }; -EOF - done - - cat <<EOF >>"$NIX_OUT" - }; + +for (@ARGV) { + last if $_ eq '--'; + if ($_ eq '--help') { + usage *STDOUT; + help *STDOUT; + exit; + } } -EOF - mv "$NIX_OUT" default.nix +my %opts; +if (!Getopt::Std::getopts('f:h', \%opts)) { + usage *STDERR; + exit 2; } -pascalize() { - awk '{printf "%s", toupper(substr($1,1,1)) substr($1,2)}' +if ($opts{h}) { + usage *STDOUT; + help *STDOUT; + exit; } -gen_homebrew() { - for p in $(jq -r '.packages[] | @base64' < paku.json); do - HOMEBREW_OUT="$(mktemp)" - NAME="$(echo "$p" | base64 --decode | jq -r '.name')" - NAME_UC="$(echo "$NAME" | pascalize)" - SUFFIX="$(echo "$p" | base64 --decode | jq -r '.suffix')" - SUFFIX_UC="$(echo "$SUFFIX" | cut -c2- | pascalize)" - VERSION="$(echo "$p" | base64 --decode | jq -r '.version')" - TYPE="$(echo "$p" | base64 --decode | jq -r '.type')" - TARBALL_URL="$(tarball_url "$NAME" "$VERSION")" - TARBALL="$(mktemp)" - wget -O "$TARBALL" "$TARBALL_URL" - SHA256="$(sha256sum "$TARBALL" | cut -d\ -f 1)" - DESCRIPTION="$(tar xvf "$TARBALL" -O "$NAME-$VERSION/description")" - JSON_CHECK_INPUTS="$(echo "$p" | base64 --decode | jq -r '.check_inputs')" - if [ "$JSON_CHECK_INPUTS" = 'null' ]; then - CHECK_INPUTS='' - else - CHECK_INPUTS='' - for check_input in $(echo "$JSON_CHECK_INPUTS" | jq -r '.[]'); do - CHECK_INPUTS="$CHECK_INPUTS - depends_on '$check_input' => :build" - done - CHECK_INPUTS="$CHECK_INPUTS -" - fi - - TEST_SECTION='' - if [ "$TYPE" = 'bin' ]; then - TEST_SECTION=" - - test do - system \"#{bin}/$NAME\", '-V' - end" - fi - - cat <<EOF >>"$HOMEBREW_OUT" -class ${NAME_UC}$SUFFIX_UC < Formula - desc '$DESCRIPTION' - homepage 'https://euandreh.xyz/$NAME/' - url '$TARBALL_URL' - sha256 '$SHA256' - license 'AGPL-3.0-or-later' -$CHECK_INPUTS - def install - system 'make' - system 'make', 'check' - system 'make', 'install', "PREFIX=#{prefix}" - end$TEST_SECTION -end -EOF - mv "$HOMEBREW_OUT" "Formula/$NAME$SUFFIX.rb" - done + +my $dir = '.paku'; # FIXME: parameterize +my $fname = $opts{f} || 'paku.lock'; +my $json_str = do { + open my $fh, $fname or die "Failed opening \"$fname\""; + local $/; + <$fh>; +}; +my $json = JSON::decode_json($json_str); + +my $action = $ARGV[0]; + + + +use Data::Dumper; +use POSIX qw(); +use File::Basename (); +use Digest::MD5 (); +use Digest::SHA (); + + +# FIXME +my $base_url_prefix = 'https://euandre.org/s'; + +if ($action eq 'release') { + my $f = $ARGV[1]; + my $name = File::Basename::basename $f; + my $size = (stat($f))[7]; + + my $now = `env LANG=POSIX.UTF-8 date -u '+%a, %d %b %Y %H:%M:%S +0000'`; + chomp $now; + + my $fh; + + open ($fh, '<', $f) or die "Can't open \"$f\": $!"; + my $md5 = Digest::MD5->new->addfile($fh)->hexdigest; + close $fh; + + open ($fh, '<', $f) or die "Can't open \"$f\": $!"; + my $sha1 = Digest::SHA->new(1)->addfile($fh)->hexdigest; + close $fh; + + open ($fh, '<', $f) or die "Can't open \"$f\": $!"; + my $sha256 = Digest::SHA->new(256)->addfile($fh)->hexdigest; + close $fh; + + open ($fh, '<', $f) or die "Can't open \"$f\": $!"; + my $sha512 = Digest::SHA->new(512)->addfile($fh)->hexdigest; + close $fh; + + print <<~EOF; + Date: $now + MD5Sum: + $md5 $size $name + SHA1: + $sha1 $size $name + SHA256: + $sha256 $size $name + SHA512: + $sha512 $size $name + EOF + exit; } -refresh_packages() { - COUNT="$(jq -r '.packages[].name' < paku.json | wc -l)" - INDEXES="$(seq 0 "$((COUNT - 1))")" - for N in $INDEXES; do - NAME="$(jq -r ".packages[$N].name" < paku.json)" - SUFFIX="$(jq -r ".packages[$N].suffix" < paku.json)" - cd "../../published/$NAME/" - if [ "$SUFFIX" = '-latest' ]; then - NEW_VERSION="$(git rev-parse HEAD)" - else - NEW_VERSION="$(git describe --tags --abbrev=0 | cut -c2-)" - fi - DESCRIPTION="$(cat description)" - cd - >/dev/null - jq -r ".packages[$N].version = \"$NEW_VERSION\"" paku.json | sponge paku.json - jq -r ".packages[$N].description = \"$DESCRIPTION\"" paku.json | sponge paku.json - done +if ($action eq 'nix') { + my $ns = 'org-euandre'; # FIXME + print <<~EOF; + { pkgs }: + self: super: { + $ns = rec { + EOF + for my $package (@{$json->{packages}}) { + for my $version (@{$package->{versions}}) { + my $ver = $version->{name}; + $ver =~ s/^v//; + $ver =~ s/\./-/g; + if ($version->{type} eq 'latest') { + $ver = 'latest'; + print <<~EOF; + $package->{name} = $package->{name}-latest; + EOF + } + + my $long = $version->{'long-description'}; + $long =~ s/^(.)/ $1/gm; + + my $base_url = $base_url_prefix . '/' . $package->{name}; + + print <<~EOF; + $package->{name}-$ver = pkgs.stdenv.mkDerivation rec { + name = "$package->{name}"; + version = "$version->{name}"; + + src = fetchTarball { + url = + "$version->{url}"; + sha256 = "$version->{sha256}"; + }; + + nativeBuildInputs = with pkgs; [ + EOF + + for my $input (@{$version->{'native-inputs'}}) { + print <<~EOF; + $input + EOF + } + print <<~EOF; + ]; + + buildInputs = with pkgs; [ + EOF + for my $input (@{$version->{inputs}}) { + print <<~EOF; + $input + EOF + } + print <<~EOF; + ]; + + makeFlags = [ "PREFIX=\$(out)" ]; + + doCheck = true; + enableParallelBuilding = true; + + meta = with pkgs.lib; { + description = "$version->{description}"; + longDescription = '' + $long + ''; + homepage = "$base_url/"; + changelog = "$base_url/CHANGELOG.html"; + downloadPage = "$base_url/#releases"; + license = licenses.agpl3; + platforms = platforms.unix; + }; + }; + EOF + # FIXME: escape quotes in description + # FIXME: parameterize license + } + } + print <<~EOF; + }; + } + EOF + exit; } -report_index() { - HTML_OUT='public/paku.html' - cat <<EOF > "$HTML_OUT" -<!DOCTYPE html> -<html lang="en"> - <head> - <meta charset="UTF-8" /> - <meta name="viewport" content="width=device-width, initial-scale=" /> - <link rel="icon" type="image/svg+html" href="favicon.svg" /> - <title>Package index</title> - - <style> - ul { - list-style: none; + +if ($action eq 'guix') { + my @pkgs = (); + my $ns = 'org euandre'; # FIXME + print <<~EOF; + (define-module ($ns packages) + EOF + for my $module (@{$json->{guix}{'module-use'}}) { + print <<~EOF; + #:use-module (gnu packages $module) + EOF + } + # FIXME: rename to 'licenses:' + print <<~EOF; + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix gexp) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix build-system gnu)) + + EOF + + for my $package (@{$json->{packages}}) { + for my $version (@{$package->{versions}}) { + my $ver = $version->{name}; + $ver =~ s/^v//; + $ver =~ s/\./-/g; + if ($version->{type} eq 'latest') { + push @pkgs, "$package->{name}"; + $ver = 'latest'; + } + + my $long = $version->{'long-description'}; + $long =~ s/^(.)/ $1/gm; + + my $base_url = $base_url_prefix . '/' . $package->{name}; + + push @pkgs, "$package->{name}-$ver"; + # FIXME: indentation of (source ...) + print <<~EOF; + (define-public $package->{name}-$ver + (package + (name "$package->{name}-$ver") + (version "$version->{name}") + (source (origin + (method url-fetch) + (uri "$version->{url}") + (sha256 + (base32 "$version->{sha256FIXME}")))) + (build-system gnu-build-system) + (native-inputs + EOF + + print ' (list'; + for my $input (@{$version->{'native-inputs'}}) { + my $name = $json->{mappings}{$input}{guix} || $input; + print "\n $name"; + } + print "))\n"; + + print " (inputs\n"; + print ' (list'; + for my $input (@{$version->{inputs}}) { + my $name = $json->{mappings}{$input}{guix} || $input; + print "\n $name"; } - li { - margin-top: 30px; + print "))\n"; + + print <<~EOF; + (arguments + (list + #:make-flags '(list (string-append "PREFIX=" %output)) + #:phases + #~(modify-phases %standard-phases + (delete 'configure)))) + (synopsis "$version->{description}") + (description + "$version->{'long-description'}") + (home-page "$base_url/") + (license license:agpl3+))) + + EOF + # FIXME: escape quotes in description + # FIXME: parameterize license + if ($version->{type} eq 'latest') { + print <<~EOF; + (define-public $package->{name} $package->{name}-latest) + + + EOF } - </style> - </head> - <body> - <h1> - Package index - </h1> - <ul> -EOF - - for p in $(jq -r '.packages[] | @base64' < paku.json); do - NAME="$(echo "$p" | base64 --decode | jq -r '.name')" - DESCRIPTION="$(echo "$p" | base64 --decode | jq -r '.description')" - SUFFIX="$(echo "$p" | base64 --decode | jq -r '.suffix')" - if [ -z "$SUFFIX" ]; then - VERSION="$(echo "$p" | base64 --decode | jq -r '.version')" - ID='released' - else - VERSION='latest' - ID='latest' - fi - - cat <<EOF >> "$HTML_OUT" - <li id="$NAME-$ID"> - <details> - <summary><a href="#$NAME-$ID">$NAME</a> ($VERSION) - $DESCRIPTION</summary> - <p> - <a href="https://euandreh.xyz/$NAME/">Homepage</a>. - </p> - - <section> - <h2>Guix</h2> - <p> - After following the - <a href="#guix-instructions">Guix instructions</a> to include this - channel, now you can create an environment that includes this - package: - </p> - <pre><code>$ guix environment --ad-hoc $NAME$SUFFIX</code></pre> - <p> - Alternatively, you can install it imperatively: - </p> - <pre><code>$ guix install $NAME$SUFFIX</code></pre> - </section> - <section> - <h2>Nix</h2> - <p> - After following the - <a href="#nix-instructions">Nix instructions</a> to include this - repository as an overlay, now you can create a new Nix shell that - includes this package: - </p> - <pre><code>$ nix-shell -p $NAME$SUFFIX</code></pre> - <p> - Alternatively, you can install it imperatively: - </p> - <pre><code>$ nix-env -i $NAME$SUFFIX</code></pre> - </section> - </details> - </li> -EOF - done - - cat <<EOF >> "$HTML_OUT" - </ul> - <article id="guix-instructions"> - <h2>Guix instructions</h2> - <p> - Add this channel to your <code>~/.config/guix/channels.scm</code>: - </p> - <pre><code>(cons* - (channel - (name 'xyz-euandreh) - (url "git://euandreh.xyz/package-repository") - (branch "main") - (introduction - (make-channel-introduction - "d749e053e6db365069cb9b2ef47a78b06f9e7361" - (openpgp-fingerprint - "5BDA E9B8 B2F6 C6BC BB0D 6CE5 81F9 0EC3 CD35 6060")))) - %default-channels)</code></pre> - </article> - - <article id="nix-instructions"> - <h2>Nix instructions</h2> - <p> - Add the overlay to your <code>/etc/nixox/configuration.nix</code>: - </p> - <pre></code>nixpkgs = { - overlays = [ - (import (fetchTarball { - url = "https://euandreh.xyz/package-repository.git/snapshot/package-repository-main.tar.gz"; - }) { inherit pkgs; }) - ]; -};</code></pre> - </article> - </body> -</html> -EOF + } + } + print '(list'; + for (@pkgs) { + print "\n $_"; + } + print ")\n"; + exit; } -while getopts 'grl' flag; do - case "$flag" in - g) - gen_guix - # gen_nix - # gen_homebrew - ;; - r) - refresh_packages - ;; - l) - report_index - ;; - *) - printf 'Unrecognized flag "%s".\n' "$flag" >&2 - ;; - esac -done + +print <<~EOF; + tarballs = \\ + EOF +for my $package (@{$json->{packages}}) { + for my $version (@{$package->{versions}}) { + print "\t$dir/tarballs/$version->{fname} \\\n"; + } +} +print "\n"; + + +print <<~EOF; + checkouts = \\ + EOF +for my $package (@{$json->{packages}}) { + for my $version (@{$package->{versions}}) { + print "\t$dir/checkouts/$package->{name}-$version->{name} \\\n"; + } +} +print "\n"; + + +print <<~EOF; + debian-destdirs = \\ + EOF +for my $package (@{$json->{packages}}) { + for my $version (@{$package->{versions}}) { + next if $version->{architectures} ne 'any'; + print "\t$dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN \\\n"; + } +} +print "\n"; + + +print <<~EOF; + control-files = \\ + EOF +for my $package (@{$json->{packages}}) { + for my $version (@{$package->{versions}}) { + next if $version->{architectures} ne 'any'; + print "\t$dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN/control \\\n"; + } +} +print "\n"; + + +print <<~EOF; + destdir-debs = \\ + EOF +for my $package (@{$json->{packages}}) { + for my $version (@{$package->{versions}}) { + next if $version->{architectures} ne 'any'; + print "\t$dir/debian-destdir/$package->{name}-$version->{name}.deb \\\n"; + } +} +print "\n"; + + +print <<~EOF; + debs = \\ + EOF +for my $package (@{$json->{packages}}) { + for my $version (@{$package->{versions}}) { + next if $version->{architectures} ne 'any'; + print "\t$dir/debian/$package->{name}_$version->{name}_all.deb \\\n"; + } +} +print "\n"; + + +print <<~EOF; + FIXME = eu\@euandre.org + + + all: $dir/debian/InRelease $dir/debian/Release.gpg $dir/debian/public-key.asc + + public-dir: + \@printf '$dir/debian' + + + $dir/debian/Packages: \$(debs) + cd \$(\@D) && dpkg-scanpackages -m . > \$(\@F) + + $dir/debian/Release: $dir/debian/Packages + perl src/bin/paku release $dir/debian/Packages > \$\@ + + $dir/debian/Release.gpg: $dir/debian/Release + gpg -abs -o \$\@ $dir/debian/Release + + $dir/debian/InRelease: $dir/debian/Release + gpg --default-key \$(FIXME) -a --clear-sign -o \$\@ $dir/debian/Release + + $dir/debian/public-key.asc: $dir/debian/Release + gpg --armour --export \$(FIXME) > \$\@ + + + EOF + + + +for my $package (@{$json->{packages}}) { + for my $version (@{$package->{versions}}) { + print <<~EOF; + $dir/tarballs/$version->{fname}: + mkdir -p \$(\@D) + wget -O \$\@ \\ + '$version->{url}' + + $dir/checkouts/$package->{name}-$version->{name}: $dir/tarballs/$version->{fname} + mkdir -p \$(\@D) + tar -C $dir/checkouts/ -xf $dir/tarballs/$version->{fname} + touch \$\@ + + EOF + + next if $version->{architectures} ne 'any'; + my $ver = $version->{type} eq 'latest' ? '0.' . $version->{name} . '.latest' : $version->{name}; + $ver =~ s/^v//; + my $maintainer_b64 = MIME::Base64::encode_base64 $version->{maintainer}, ''; + my $desc_b64 = MIME::Base64::encode_base64 $version->{description}, ''; + my $long_desc_b64 = MIME::Base64::encode_base64 $version->{'long-description'}, ''; + + + print <<~EOF; + $dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN: $dir/checkouts/$package->{name}-$version->{name} + \$(MAKE) \\ + -C $dir/checkouts/$package->{name}-$version->{name} \\ + install \\ + PREFIX=/usr \\ + DESTDIR="\$\$PWD"/$dir/debian-destdir/$package->{name}-$version->{name} + mkdir -p \$\@ + touch \$\@ + + $dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN/control: $dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN + printf '' > \$\@ + printf 'Package: $package->{name}\\n' >> \$\@ + printf 'Version: $ver\\n' >> \$\@ + printf 'Section: custom\\n' >> \$\@ + printf 'Depends:\\n' >> \$\@ + printf 'Priority: optional\\n' >> \$\@ + printf 'Architecture: all\\n' >> \$\@ + printf 'Essential: no\\n' >> \$\@ + + printf 'Maintainer: ' >> \$\@ + printf '$maintainer_b64' | base64 -d >> \$\@ + printf '\\n' >> \$\@ + + printf 'Description: ' >> \$\@ + printf '$desc_b64' | base64 -d >> \$\@ + printf '\\n' >> \$\@ + + printf '$long_desc_b64' | \\ + base64 -d | \\ + sed 's|^\$\$|.|' | \\ + sed 's|^| |' >> \$\@ + printf '\\n' >> \$\@ + + $dir/debian-destdir/$package->{name}-$version->{name}.deb: $dir/debian-destdir/$package->{name}-$version->{name}/DEBIAN/control + dpkg-deb --build $dir/debian-destdir/$package->{name}-$version->{name} + + $dir/debian/$package->{name}_$version->{name}_all.deb: $dir/debian-destdir/$package->{name}-$version->{name}.deb + mkdir -p \$(\@D) + cp $dir/debian-destdir/$package->{name}-$version->{name}.deb \$\@ + + + EOF + } +} diff --git a/src/org/euandre/packages.scm b/src/org/euandre/packages.scm index 4cd3ca0..be54ceb 100644 --- a/src/org/euandre/packages.scm +++ b/src/org/euandre/packages.scm @@ -7,32 +7,157 @@ #:use-module (guix download) #:use-module (guix build-system gnu)) +(define-public git-permalink-0-1-0 + (package + (name "git-permalink-0-1-0") + (version "v0.1.0") + (source (origin + (method url-fetch) + (uri "https://euandre.org/git/git-permalink/snapshot/git-permalink-v0.1.0.tar.xz") + (sha256 + (base32 "07waci3y0xdlbr8gl1lzdbsiz0csnrshcm6f18cdzn7y97irhb15")))) + (build-system gnu-build-system) + (native-inputs + (list)) + (inputs + (list)) + (arguments + (list + #:make-flags '(list (string-append "PREFIX=" %output)) + #:phases + #~(modify-phases %standard-phases + (delete 'configure)))) + (synopsis "Git extension to generate web permalinks of files in a repository") + (description + "It knows about many of the existing code forges, but allows for URL +template overrides to be used on custom domains or deployments via git +config.") + (home-page "https://euandre.org/s/git-permalink/") + (license license:agpl3+))) + +(define-public git-permalink-0-2-0 + (package + (name "git-permalink-0-2-0") + (version "v0.2.0") + (source (origin + (method url-fetch) + (uri "https://euandre.org/git/git-permalink/snapshot/git-permalink-v0.2.0.tar.xz") + (sha256 + (base32 "10qiigp29jamb23mdrf1yp0gqmihlsg931ibpiqpf4pn28l5d9ly")))) + (build-system gnu-build-system) + (native-inputs + (list)) + (inputs + (list)) + (arguments + (list + #:make-flags '(list (string-append "PREFIX=" %output)) + #:phases + #~(modify-phases %standard-phases + (delete 'configure)))) + (synopsis "Git extension to generate web permalinks of files in a repository") + (description + "It knows about many of the existing code forges, but allows for URL +template overrides to be used on custom domains or deployments via git +config.") + (home-page "https://euandre.org/s/git-permalink/") + (license license:agpl3+))) + +(define-public remembering-0-1-2 + (package + (name "remembering-0-1-2") + (version "v0.1.2") + (source (origin + (method url-fetch) + (uri "https://euandre.org/git/remembering/snapshot/remembering-v0.1.2.tar.xz") + (sha256 + (base32 "1syzn41w4f754ihblwxcv3wn653lh92cgg6g06db1qrx3m2zvw5v")))) + (build-system gnu-build-system) + (native-inputs + (list)) + (inputs + (list)) + (arguments + (list + #:make-flags '(list (string-append "PREFIX=" %output)) + #:phases + #~(modify-phases %standard-phases + (delete 'configure)))) + (synopsis "Add memory to dmenu, fzf and similar tools") + (description + "It can wrap such tools to accumulate preferences over time, and +re-arrange the input according to common picks.") + (home-page "https://euandre.org/s/remembering/") + (license license:agpl3+))) + +(define-public td-latest + (package + (name "td-latest") + (version "4a8a7a2662c94b2581f587e9a4b81feba4f5e7d8") + (source (origin + (method url-fetch) + (uri "https://euandre.org/git/td/snapshot/td-4a8a7a2662c94b2581f587e9a4b81feba4f5e7d8.tar.xz") + (sha256 + (base32 "01g1vnlz1kch8j9zzaxyixih04azdvrfabfzg7xqny32h2p62md2")))) + (build-system gnu-build-system) + (native-inputs + (list)) + (inputs + (list)) + (arguments + (list + #:make-flags '(list (string-append "PREFIX=" %output)) + #:phases + #~(modify-phases %standard-phases + (delete 'configure)))) + (synopsis "Minimalistic bug tracker CLI") + (description + "Create and maintain a TODOs.md files as a bug database. + +It is a tool for distributed, offline issue tracking, reified as a simple text +file in the repository.") + (home-page "https://euandre.org/s/td/") + (license license:agpl3+))) + +(define-public td td-latest) + + (define-public guile-heredoc-latest (package (name "guile-heredoc-latest") (version "065435cdce609604e33b879b9be3e81ab89f3e7b") (source (origin (method url-fetch) - (uri (string-append - "https://euandre.org/git/guile-heredoc/snapshot/guile-heredoc-" - version - ".tar.gz")) + (uri "https://euandre.org/git/guile-heredoc/snapshot/guile-heredoc-065435cdce609604e33b879b9be3e81ab89f3e7b.tar.xz") (sha256 - (base32 - "0cmfg7rj3malc2dplhdibcsj5kx41lfv5i3dxnwq203fd7xy50v5")))) + (base32 "1y1110bg4ki0dvn8hggxy34wg7ig4r3377nc84isnj3dydqm2vjd")))) (build-system gnu-build-system) + (native-inputs + (list + texinfo)) (inputs - (list guile-3.0 - texinfo)) + (list + guile-3.0)) (arguments - `(#:make-flags (list (string-append "PREFIX=" %output)) - #:phases - (modify-phases %standard-phases - (delete 'configure)))) - (synopsis "FIXME: (file-append source \"/description\")") - (description "FIXME: (file-append source \"/long-description\")") - (home-page "https://euandre.org/git/guile-heredoc/") + (list + #:make-flags '(list (string-append "PREFIX=" %output)) + #:phases + #~(modify-phases %standard-phases + (delete 'configure)))) + (synopsis "Guile heredoc syntax") + (description + "Guile heredoc syntax long.") + (home-page "https://euandre.org/s/guile-heredoc/") (license license:agpl3+))) +(define-public guile-heredoc guile-heredoc-latest) + + (list + git-permalink-0-1-0 + git-permalink-0-2-0 + remembering-0-1-2 + td + td-latest + guile-heredoc guile-heredoc-latest) diff --git a/tests/checks/deb.sh b/tests/checks/deb.sh new file mode 100755 index 0000000..04bfcd1 --- /dev/null +++ b/tests/checks/deb.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -eu + + +REPO="$1/debian" +KEY="$(printf '%s' "${REPO#https://}" | sed 's|/|-|g').asc" + +if command -v remembering; then + echo 'remembering(1) is already installed.' >&2 + exit 1 +fi + +if apt info remembering; then + echo 'remembering(1) is already in apt(8) list.' >&2 + exit 1 +fi + +wget -qO- "$REPO"/public-key.asc | sudo tee /etc/apt/trusted.gpg.d/"$KEY" +sudo apt-add-repository "deb $REPO ./" +sudo apt install remembering + +remembering --help +remembering -V diff --git a/tests/vm-check.sh b/tests/vm-check.sh new file mode 100755 index 0000000..d6684ed --- /dev/null +++ b/tests/vm-check.sh @@ -0,0 +1,86 @@ +#!/bin/sh +set -eu + +usage() { + cat <<-'EOF' + Usage: + vm-check.sh [-x] -t TYPE -H HOST -r REMOTE + vm-check.sh -h + EOF +} + +help() { + cat <<-'EOF' + + + Options: + -x shutdown the VM before running checks + -t TYPE the type of VM being tested + -H HOST the name of the host to SSH into + -r REMOTE the base address of the remote package-repository + -h, --help show this message + + + + Run end-to-end tests of the package repository. + EOF +} + + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +SHUTDOWN=false +while getopts 'xt:H:r:h' flag; do + case "$flag" in + x) + SHUTDOWN=true + ;; + t) + TYPE="$OPTARG" + ;; + H) + HOST="$OPTARG" + ;; + r) + REMOTE="$OPTARG" + ;; + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + +eval "$(assert-arg -- "${TYPE:-}" '-t TYPE')" +eval "$(assert-arg -- "${HOST:-}" '-H HOST')" +eval "$(assert-arg -- "${REMOTE:-}" '-r REMOTE')" + + + +if [ "$SHUTDOWN" = true ]; then + vm down "$HOST" +fi +vm up "$HOST" + +untill -m5 -n5 ssh "$HOST" uptime +scp tests/checks/"$TYPE".sh "$HOST":check.sh +ssh "$HOST" sh check.sh "$REMOTE" |