diff options
author | EuAndreh <eu@euandre.org> | 2021-06-17 00:26:27 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-06-17 00:26:27 -0300 |
commit | 830a2ff0a0fd0fb17828794f36eca77e5246ae31 (patch) | |
tree | 1725500ebbe3badd29e8bf2a05fb17139b15363f /scripts | |
parent | Update paku.json, refresh Nix and Guix dependencies (diff) | |
download | package-repository-830a2ff0a0fd0fb17828794f36eca77e5246ae31.tar.gz package-repository-830a2ff0a0fd0fb17828794f36eca77e5246ae31.tar.xz |
scripts/paku: spaces -> tabs
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/paku | 246 |
1 files changed, 121 insertions, 125 deletions
diff --git a/scripts/paku b/scripts/paku index 69b225a..c94a659 100755 --- a/scripts/paku +++ b/scripts/paku @@ -4,17 +4,17 @@ set -eu TARBALL_TEMPLATE='https://git.euandreh.xyz/@NAME@/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" + NAME="$1" + VERSION="$2" + echo "$TARBALL_TEMPLATE" | \ + sed -e "s/@NAME@/$NAME/g" \ + -e "s/@VERSION@/$VERSION/g" } gen_guix() { - GUIX_OUT="$(mktemp)" + GUIX_OUT="$(mktemp)" - cat <<EOF >>"$GUIX_OUT" + cat <<EOF >>"$GUIX_OUT" (define-module (xyz euandreh packages) #:use-module (json) #:use-module ((ice-9 textual-ports) #:prefix textual-ports:) @@ -30,34 +30,32 @@ gen_guix() { #: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 + 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 + fi + done - CHECK_INPUTS=" + CHECK_INPUTS=" (inputs \`($INPUTS))" - fi + fi - cat <<EOF >>"$GUIX_OUT" + cat <<EOF >>"$GUIX_OUT" (define-public $NAME$SUFFIX (package @@ -84,50 +82,50 @@ EOF (home-page (string-append "https://" name ".euandreh.xyz")) (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 + 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)" + NIX_OUT="$(mktemp)" - cat <<EOF >>"$NIX_OUT" + 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=" + 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 + fi - cat <<EOF >>"$NIX_OUT" + cat <<EOF >>"$NIX_OUT" $NAME$SUFFIX = pkgs.stdenv.mkDerivation rec { name = "$NAME"; version = "$VERSION"; @@ -153,55 +151,53 @@ $CHECK_INPUTS }; }; EOF - done + done - cat <<EOF >>"$NIX_OUT" + cat <<EOF >>"$NIX_OUT" }; } EOF - mv "$NIX_OUT" default.nix + mv "$NIX_OUT" default.nix } 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" | tr '[:lower:]' '[:upper:]')" - SUFFIX="$(echo "$p" | base64 --decode | jq -r '.suffix')" - SUFFIX_UC="$(echo "$SUFFIX" | cut -c2- | tr '[:lower:]' '[:upper:]')" - 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 + 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" | tr '[:lower:]' '[:upper:]')" + SUFFIX="$(echo "$p" | base64 --decode | jq -r '.suffix')" + SUFFIX_UC="$(echo "$SUFFIX" | tr '[:lower:]' '[:upper:]')" + 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 + done + CHECK_INPUTS="$CHECK_INPUTS " - fi + fi - TEST_SECTION='' - if [ "$TYPE" = 'bin' ]; then - TEST_SECTION=" + TEST_SECTION='' + if [ "$TYPE" = 'bin' ]; then + TEST_SECTION=" test do system \"#{bin}/$NAME\", '-V' end" - fi + fi - cat <<EOF >>"$HOMEBREW_OUT" + cat <<EOF >>"$HOMEBREW_OUT" class ${NAME_UC}$SUFFIX_UC < Formula desc '$DESCRIPTION' homepage 'https://$NAME.euandreh.xyz' @@ -216,39 +212,39 @@ $CHECK_INPUTS end$TEST_SECTION end EOF - mv "$HOMEBREW_OUT" "Formula/$NAME$SUFFIX.rb" - done + 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 "../$NAME/" - if [ "$SUFFIX" = '-latest' ]; then - NEW_VERSION="$(git rev-parse HEAD)" - else - NEW_VERSION="$(git describe --tags --abbrev=0 | cut -c2-)" - fi - cd - >/dev/null - jq -r ".packages[$N].version = \"$NEW_VERSION\"" paku.json | sponge paku.json - done + 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 "../$NAME/" + if [ "$SUFFIX" = '-latest' ]; then + NEW_VERSION="$(git rev-parse HEAD)" + else + NEW_VERSION="$(git describe --tags --abbrev=0 | cut -c2-)" + fi + cd - >/dev/null + jq -r ".packages[$N].version = \"$NEW_VERSION\"" paku.json | sponge paku.json + done } while getopts 'gr' flag; do - case "$flag" in - g) - gen_guix - gen_nix - gen_homebrew - ;; - r) - refresh_packages - ;; - *) - printf 'Unrecognized flag "%s".\n' "$flag" >&2 - ;; - esac + case "$flag" in + g) + gen_guix + gen_nix + gen_homebrew + ;; + r) + refresh_packages + ;; + *) + printf 'Unrecognized flag "%s".\n' "$flag" >&2 + ;; + esac done |