From 9434d53324dfb73598bf464038ed1354054fbbf5 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Fri, 16 Jun 2023 00:34:08 +0200 Subject: [PATCH] Bootstrappable Debian package --- .github/workflows/guix.yml | 4 +- contrib/debian/control | 7 ++ contrib/debian/make_deb.sh | 41 +++++++++++ contrib/flatpak/flatpak.scm | 118 ------------------------------- contrib/flatpak/make_flatpak.sh | 3 +- contrib/guix/guix-build | 22 +++--- contrib/guix/libexec/build.sh | 10 +-- contrib/guix/pack.scm | 121 ++++++++++++++++++++++++++++++++ 8 files changed, 192 insertions(+), 134 deletions(-) create mode 100644 contrib/debian/control create mode 100644 contrib/debian/make_deb.sh delete mode 100644 contrib/flatpak/flatpak.scm create mode 100644 contrib/guix/pack.scm diff --git a/.github/workflows/guix.yml b/.github/workflows/guix.yml index 1e2e202..900607f 100644 --- a/.github/workflows/guix.yml +++ b/.github/workflows/guix.yml @@ -86,8 +86,8 @@ jobs: host: "x86_64-linux-gnu" - name: "x86_64-linux-gnu.no-tor-bundle" host: "x86_64-linux-gnu.no-tor-bundle" - - name: "x86_64-linux-gnu.flatpak" - host: "x86_64-linux-gnu.flatpak" + - name: "x86_64-linux-gnu.pack" + host: "x86_64-linux-gnu.pack" - name: "aarch64-linux-gnu" host: "aarch64-linux-gnu" - name: "arm-linux-gnueabihf" diff --git a/contrib/debian/control b/contrib/debian/control new file mode 100644 index 0000000..f89824f --- /dev/null +++ b/contrib/debian/control @@ -0,0 +1,7 @@ +Package: feather +Version: VERSION +Description: Monero desktop wallet +Maintainer: tobtoht +Architecture: amd64 +Priority: optional +Section: misc diff --git a/contrib/debian/make_deb.sh b/contrib/debian/make_deb.sh new file mode 100644 index 0000000..2901ac2 --- /dev/null +++ b/contrib/debian/make_deb.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -ex + +get_store_path() { + find gnu/store -maxdepth 1 -type d -name "*$1*" | sort | head -n 1 +} + +mkdir -p /output/debian +cd /output/debian + +#. +#├── control.tar.gz +cp /feather/contrib/debian/control . +sed -i "s/VERSION/${VERSION}/" control +tar -czvf control.tar.gz control +rm control + +#├── data.tar.gz +mkdir data +cd data +tar xf /rpack . + +GUIX_PROFILE=$(get_store_path "profile") + +mkdir -p opt/deb-packs/feather +mv gnu opt/deb-packs/feather/ + +mkdir -p usr/bin +ln -s "/opt/deb-packs/feather/${GUIX_PROFILE}/bin/feather" usr/bin/feather + +tar -czvf ../data.tar.gz . + +cd /output/debian +chmod -R 755 data +rm -rf data + +#└── debian-binary +echo "2.0" > debian-binary + +ar r "feather_${VERSION}-1_amd64.deb" debian-binary control.tar.gz data.tar.gz +rm debian-binary control.tar.gz data.tar.gz \ No newline at end of file diff --git a/contrib/flatpak/flatpak.scm b/contrib/flatpak/flatpak.scm deleted file mode 100644 index ce34e07..0000000 --- a/contrib/flatpak/flatpak.scm +++ /dev/null @@ -1,118 +0,0 @@ -(use-modules (gnu) - (gnu packages) - (gnu packages base) - (gnu packages bash) - (gnu packages certs) - (gnu packages check) - (gnu packages compression) - (gnu packages elf) - (gnu packages fonts) - (gnu packages fontutils) - (gnu packages gcc) - (gnu packages gettext) - (gnu packages glib) - (gnu packages libusb) - (gnu packages linux) - (gnu packages moreutils) - (gnu packages shells) - (gnu packages tls) - (gnu packages xorg) - (gnu packages xdisorg) - (guix build-system gnu) - (guix download) - ((guix licenses) #:prefix license:) - (guix packages) - (guix profiles) - (guix utils)) - -(define-public feather-binary - (package - (name "feather-binary") - (version (getenv "VERSION")) - (source (origin - (method url-fetch) - (uri (getenv "FILE")) - (sha256 (base32 (getenv "HASH"))))) - (build-system gnu-build-system) - (propagated-inputs - (list nss-certs - dbus - coreutils-minimal)) - (inputs (list fontconfig - (list gcc "lib") - libxkbcommon - libxcb - xcb-util-cursor - xcb-util-wm - xcb-util-image - xcb-util-keysyms - xcb-util-renderutil)) - (arguments - (list - #:strip-binaries? #f - #:phases - #~(modify-phases %standard-phases - (delete 'bootstrap) - (delete 'configure) - (delete 'build) - (delete 'check) - (delete 'validate-runpath) - (add-before 'install 'patchelff - (lambda* (#:key inputs outputs propagated-inputs #:allow-other-keys) - (let ((binary "feather") - (runpath '("gcc" - "dbus" - "fontconfig-minimal" - "libxkbcommon" - "libxcb" - "xcb-util-cursor" - "xcb-util-wm" - "xcb-util-image" - "xcb-util-keysyms" - "xcb-util-renderutil"))) - - (define* (maybe-make-rpath entries name) - (let ((entry (assoc-ref entries name))) - (if entry - (string-append entry "/lib") - #f))) - - (define* (make-rpath name) - (or - (maybe-make-rpath inputs name) - (maybe-make-rpath propagated-inputs name) - (error (format #f "`~a' not found among the inputs nor the outputs." name)))) - - (let ((rpath (string-join - (map make-rpath runpath) - ":"))) - (invoke "patchelf" "--set-rpath" rpath binary)) - - #t))) - (replace 'install - (lambda* (#:key outputs #:allow-other-keys) - (let ((target (string-append (assoc-ref outputs "out") "/bin/feather"))) - (mkdir-p (string-append (assoc-ref outputs "out") "/bin/")) - (copy-file "./feather" target))))))) - (native-inputs (list - patchelf - unzip)) - (home-page "https://featherwallet.org/") - (synopsis "A free, open-source Monero wallet") - (description - "Feather is a free, open-source Monero wallet for Linux, Tails, Windows and macOS.") - (license license:bsd-3))) - -(define utf8-locales - (make-glibc-utf8-locales - glibc - #:locales (list "en_US") - #:name "utf8-locales")) - -(packages->manifest - (append - (list feather-binary - strace - utf8-locales - font-wqy-zenhei - font-gnu-unifont))) \ No newline at end of file diff --git a/contrib/flatpak/make_flatpak.sh b/contrib/flatpak/make_flatpak.sh index 0fb4c0a..defa315 100644 --- a/contrib/flatpak/make_flatpak.sh +++ b/contrib/flatpak/make_flatpak.sh @@ -7,7 +7,8 @@ get_store_path() { find gnu/store -maxdepth 1 -type d -name "*$1*" | sort | head -n 1 } -cd /flatpak +mkdir -p /output/flatpak +cd /output/flatpak # Create build dir mkdir build diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index f353b51..e12ac5c 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -81,7 +81,7 @@ mkdir -p "$VERSION_BASE" # Default to building for all supported HOSTs (overridable by environment) export HOSTS="${HOSTS:-x86_64-linux-gnu aarch64-linux-gnu arm-linux-gnueabihf x86_64-linux-gnu.no-tor-bundle - x86_64-linux-gnu.flatpak + x86_64-linux-gnu.pack riscv64-linux-gnu x86_64-w64-mingw32 x86_64-w64-mingw32.installer x86_64-apple-darwin arm64-apple-darwin}" @@ -446,26 +446,32 @@ EOF case "$OPTIONS" in - flatpak) - export FILE="$(outdir_for_host "$host")/${DISTNAME}-flatpak.zip" + pack) + export FILE="$(outdir_for_host "$host")/${DISTNAME}-pack.zip" export HASH=$(guix hash "${FILE}") export VERSION=${VERSION} - time-machine pack -S /opt/gnu/bin=bin --manifest="${PWD}/contrib/flatpak/flatpak.scm" - PACK=$(time-machine pack --manifest="${PWD}/contrib/flatpak/flatpak.scm") - time-machine environment --ad-hoc tar gzip findutils grep patchelf coreutils-minimal bash \ + time-machine pack --manifest="${PWD}/contrib/guix/pack.scm" + PACK=$(time-machine pack --manifest="${PWD}/contrib/guix/pack.scm") + time-machine pack -R --manifest="${PWD}/contrib/guix/pack.scm" + RPACK=$(time-machine pack -R --manifest="${PWD}/contrib/guix/pack.scm") + time-machine environment --ad-hoc tar gzip findutils grep patchelf coreutils-minimal bash binutils sed \ --container \ --pure \ --no-cwd \ --share="$PWD"=/feather \ --share="$PACK"=/pack \ - --share="$(outdir_for_host "$host")"=/flatpak \ + --share="$RPACK"=/rpack \ + --share="$(outdir_for_host "$host")"=/output \ --keep-failed \ --fallback \ --user="user" \ ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \ ${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \ -- env SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \ - bash -c "cd /feather && bash contrib/flatpak/make_flatpak.sh" + VERSION="$VERSION" \ + bash -c "cd /feather && \ + bash contrib/debian/make_deb.sh && \ + bash contrib/flatpak/make_flatpak.sh" ;; esac ) diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index fb3562d..5e5b36f 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -293,7 +293,7 @@ mkdir -p "$DISTSRC" CMAKEVARS+=" -DTOR_DIR=Off -DTOR_VERSION=Off" ANONDIST+="-a" ;; - flatpak) + pack) CMAKEVARS+=" -DCHECK_UPDATES=Off -DSELF_CONTAINED=Off" ;; esac @@ -338,7 +338,7 @@ mkdir -p "$DISTSRC" case "$HOST" in *linux*) - if [ "$OPTIONS" != "flatpak" ]; then + if [ "$OPTIONS" != "pack" ]; then bash contrib/AppImage/build-appimage.sh APPIMAGENAME=${DISTNAME}${ANONDIST}${LINUX_ARCH}.AppImage mv feather.AppImage "${APPIMAGENAME}" @@ -414,7 +414,7 @@ mkdir -p "$DISTSRC" esac ;; *linux*) - if [ "$OPTIONS" != "flatpak" ]; then + if [ "$OPTIONS" != "pack" ]; then mv feather "${DISTNAME}" case "$OPTIONS" in "") @@ -437,8 +437,8 @@ mkdir -p "$DISTSRC" | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" find . \ | sort \ - | zip -X@ "${OUTDIR}/${DISTNAME}-flatpak.zip" \ - || ( rm -f "${OUTDIR}/${DISTNAME}-flatpak.zip" && exit 1 ) + | zip -X@ "${OUTDIR}/${DISTNAME}-pack.zip" \ + || ( rm -f "${OUTDIR}/${DISTNAME}-pack.zip" && exit 1 ) fi ;; *darwin*) diff --git a/contrib/guix/pack.scm b/contrib/guix/pack.scm new file mode 100644 index 0000000..08165ac --- /dev/null +++ b/contrib/guix/pack.scm @@ -0,0 +1,121 @@ +(use-modules (gnu) + (gnu packages) + (gnu packages base) + (gnu packages bash) + (gnu packages certs) + (gnu packages check) + (gnu packages compression) + (gnu packages elf) + (gnu packages fonts) + (gnu packages fontutils) + (gnu packages gcc) + (gnu packages gettext) + (gnu packages glib) + (gnu packages libusb) + (gnu packages linux) + (gnu packages moreutils) + (gnu packages shells) + (gnu packages tls) + (gnu packages xorg) + (gnu packages xdisorg) + (guix build-system gnu) + (guix download) + ((guix licenses) #:prefix license:) + (guix packages) + (guix profiles) + (guix utils)) + +(define-public feather-binary + (package + (name "feather-binary") + (version (getenv "VERSION")) + (source (origin + (method url-fetch) + (uri (getenv "FILE")) + (sha256 (base32 (getenv "HASH"))))) + (build-system gnu-build-system) + (propagated-inputs + (list nss-certs + dbus + coreutils-minimal)) + (inputs (list fontconfig + (list gcc "lib") + glibc + libxkbcommon + libxcb + xcb-util-cursor + xcb-util-wm + xcb-util-image + xcb-util-keysyms + xcb-util-renderutil)) + (arguments + (list + #:strip-binaries? #f + #:phases + #~(modify-phases %standard-phases + (delete 'bootstrap) + (delete 'configure) + (delete 'build) + (delete 'check) + (add-before 'install 'patchelff + (lambda* (#:key inputs outputs propagated-inputs #:allow-other-keys) + (let ((interpreter (string-append (assoc-ref inputs "glibc") "/lib/ld-linux-x86-64.so.2")) + (binary "feather") + (runpath '("gcc" + "glibc" + "dbus" + "fontconfig-minimal" + "libxkbcommon" + "libxcb" + "xcb-util-cursor" + "xcb-util-wm" + "xcb-util-image" + "xcb-util-keysyms" + "xcb-util-renderutil"))) + + (define* (maybe-make-rpath entries name) + (let ((entry (assoc-ref entries name))) + (if entry + (string-append entry "/lib") + #f))) + + (define* (make-rpath name) + (or + (maybe-make-rpath inputs name) + (maybe-make-rpath propagated-inputs name) + (error (format #f "`~a' not found among the inputs nor the outputs." name)))) + + (system* "patchelf" "--set-interpreter" interpreter binary) + (let ((rpath (string-join + (map make-rpath runpath) + ":"))) + (invoke "patchelf" "--set-rpath" rpath binary)) + + #t))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let ((target (string-append (assoc-ref outputs "out") "/bin/feather"))) + (mkdir-p (string-append (assoc-ref outputs "out") "/bin/")) + (copy-file "./feather" target))))))) + (native-inputs (list + patchelf + unzip)) + (home-page "https://featherwallet.org/") + (synopsis "A free, open-source Monero wallet") + (description + "Feather is a free, open-source Monero wallet for Linux, Tails, Windows and macOS.") + (license license:bsd-3))) + +(define utf8-locales + (make-glibc-utf8-locales + glibc + #:locales (list "en_US") + #:name "utf8-locales")) + +(packages->manifest + (append + (list feather-binary + strace + utf8-locales + font-wqy-zenhei + font-gnu-unifont))) \ No newline at end of file