From 5b03b1be3695f61488e0706a05ae382adfba3886 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 1 Dec 2022 19:35:31 -0300 Subject: git mv scripts/paku src/bin/ --- scripts/paku | 369 ----------------------------------------------------------- 1 file changed, 369 deletions(-) delete mode 100755 scripts/paku (limited to 'scripts/paku') diff --git a/scripts/paku b/scripts/paku deleted file mode 100755 index 8d5a967..0000000 --- a/scripts/paku +++ /dev/null @@ -1,369 +0,0 @@ -#!/bin/sh -set -eu - -TARBALL_TEMPLATE='https://euandreh.xyz/@NAME@.git/snapshot/@NAME@-@VERSION@.tar.gz' - -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 <>"$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 <>"$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 -} - -gen_nix() { - NIX_OUT="$(mktemp)" - - cat <>"$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 <>"$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 <>"$NIX_OUT" - }; -} -EOF - - mv "$NIX_OUT" default.nix -} - -pascalize() { - awk '{printf "%s", toupper(substr($1,1,1)) substr($1,2)}' -} - -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 <>"$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 -} - -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 -} - -report_index() { - HTML_OUT='public/paku.html' - cat < "$HTML_OUT" - - - - - - - Package index - - - - -

- Package index -

-
    -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 <> "$HTML_OUT" -
  • -
    - $NAME ($VERSION) - $DESCRIPTION -

    - Homepage. -

    - -
    -

    Guix

    -

    - After following the - Guix instructions to include this - channel, now you can create an environment that includes this - package: -

    -
    $ guix environment --ad-hoc $NAME$SUFFIX
    -

    - Alternatively, you can install it imperatively: -

    -
    $ guix install $NAME$SUFFIX
    -
    -
    -

    Nix

    -

    - After following the - Nix instructions to include this - repository as an overlay, now you can create a new Nix shell that - includes this package: -

    -
    $ nix-shell -p $NAME$SUFFIX
    -

    - Alternatively, you can install it imperatively: -

    -
    $ nix-env -i $NAME$SUFFIX
    -
    -
    -
  • -EOF - done - - cat <> "$HTML_OUT" -
-
-

Guix instructions

-

- Add this channel to your ~/.config/guix/channels.scm: -

-
(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)
-
- -
-

Nix instructions

-

- Add the overlay to your /etc/nixox/configuration.nix: -

-
nixpkgs = {
-  overlays = [
-    (import (fetchTarball {
-      url = "https://euandreh.xyz/package-repository.git/snapshot/package-repository-main.tar.gz";
-    }) { inherit pkgs; })
-  ];
-};
-
- - -EOF -} - -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 -- cgit v1.2.3