Bootstrappable Debian package

This commit is contained in:
tobtoht 2023-06-16 00:34:08 +02:00
parent 871a998e51
commit 9434d53324
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
8 changed files with 192 additions and 134 deletions

View file

@ -86,8 +86,8 @@ jobs:
host: "x86_64-linux-gnu" host: "x86_64-linux-gnu"
- name: "x86_64-linux-gnu.no-tor-bundle" - name: "x86_64-linux-gnu.no-tor-bundle"
host: "x86_64-linux-gnu.no-tor-bundle" host: "x86_64-linux-gnu.no-tor-bundle"
- name: "x86_64-linux-gnu.flatpak" - name: "x86_64-linux-gnu.pack"
host: "x86_64-linux-gnu.flatpak" host: "x86_64-linux-gnu.pack"
- name: "aarch64-linux-gnu" - name: "aarch64-linux-gnu"
host: "aarch64-linux-gnu" host: "aarch64-linux-gnu"
- name: "arm-linux-gnueabihf" - name: "arm-linux-gnueabihf"

7
contrib/debian/control Normal file
View file

@ -0,0 +1,7 @@
Package: feather
Version: VERSION
Description: Monero desktop wallet
Maintainer: tobtoht <tob@featherwallet.org>
Architecture: amd64
Priority: optional
Section: misc

View file

@ -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

View file

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

View file

@ -7,7 +7,8 @@ get_store_path() {
find gnu/store -maxdepth 1 -type d -name "*$1*" | sort | head -n 1 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 # Create build dir
mkdir build mkdir build

View file

@ -81,7 +81,7 @@ mkdir -p "$VERSION_BASE"
# Default to building for all supported HOSTs (overridable by environment) # Default to building for all supported HOSTs (overridable by environment)
export HOSTS="${HOSTS:-x86_64-linux-gnu aarch64-linux-gnu arm-linux-gnueabihf export HOSTS="${HOSTS:-x86_64-linux-gnu aarch64-linux-gnu arm-linux-gnueabihf
x86_64-linux-gnu.no-tor-bundle x86_64-linux-gnu.no-tor-bundle
x86_64-linux-gnu.flatpak x86_64-linux-gnu.pack
riscv64-linux-gnu riscv64-linux-gnu
x86_64-w64-mingw32 x86_64-w64-mingw32.installer x86_64-w64-mingw32 x86_64-w64-mingw32.installer
x86_64-apple-darwin arm64-apple-darwin}" x86_64-apple-darwin arm64-apple-darwin}"
@ -446,26 +446,32 @@ EOF
case "$OPTIONS" in case "$OPTIONS" in
flatpak) pack)
export FILE="$(outdir_for_host "$host")/${DISTNAME}-flatpak.zip" export FILE="$(outdir_for_host "$host")/${DISTNAME}-pack.zip"
export HASH=$(guix hash "${FILE}") export HASH=$(guix hash "${FILE}")
export VERSION=${VERSION} export VERSION=${VERSION}
time-machine pack -S /opt/gnu/bin=bin --manifest="${PWD}/contrib/flatpak/flatpak.scm" time-machine pack --manifest="${PWD}/contrib/guix/pack.scm"
PACK=$(time-machine pack --manifest="${PWD}/contrib/flatpak/flatpak.scm") PACK=$(time-machine pack --manifest="${PWD}/contrib/guix/pack.scm")
time-machine environment --ad-hoc tar gzip findutils grep patchelf coreutils-minimal bash \ 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 \ --container \
--pure \ --pure \
--no-cwd \ --no-cwd \
--share="$PWD"=/feather \ --share="$PWD"=/feather \
--share="$PACK"=/pack \ --share="$PACK"=/pack \
--share="$(outdir_for_host "$host")"=/flatpak \ --share="$RPACK"=/rpack \
--share="$(outdir_for_host "$host")"=/output \
--keep-failed \ --keep-failed \
--fallback \ --fallback \
--user="user" \ --user="user" \
${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \ ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \
${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \ ${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \
-- env SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \ -- 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 esac
) )

View file

@ -293,7 +293,7 @@ mkdir -p "$DISTSRC"
CMAKEVARS+=" -DTOR_DIR=Off -DTOR_VERSION=Off" CMAKEVARS+=" -DTOR_DIR=Off -DTOR_VERSION=Off"
ANONDIST+="-a" ANONDIST+="-a"
;; ;;
flatpak) pack)
CMAKEVARS+=" -DCHECK_UPDATES=Off -DSELF_CONTAINED=Off" CMAKEVARS+=" -DCHECK_UPDATES=Off -DSELF_CONTAINED=Off"
;; ;;
esac esac
@ -338,7 +338,7 @@ mkdir -p "$DISTSRC"
case "$HOST" in case "$HOST" in
*linux*) *linux*)
if [ "$OPTIONS" != "flatpak" ]; then if [ "$OPTIONS" != "pack" ]; then
bash contrib/AppImage/build-appimage.sh bash contrib/AppImage/build-appimage.sh
APPIMAGENAME=${DISTNAME}${ANONDIST}${LINUX_ARCH}.AppImage APPIMAGENAME=${DISTNAME}${ANONDIST}${LINUX_ARCH}.AppImage
mv feather.AppImage "${APPIMAGENAME}" mv feather.AppImage "${APPIMAGENAME}"
@ -414,7 +414,7 @@ mkdir -p "$DISTSRC"
esac esac
;; ;;
*linux*) *linux*)
if [ "$OPTIONS" != "flatpak" ]; then if [ "$OPTIONS" != "pack" ]; then
mv feather "${DISTNAME}" mv feather "${DISTNAME}"
case "$OPTIONS" in case "$OPTIONS" in
"") "")
@ -437,8 +437,8 @@ mkdir -p "$DISTSRC"
| xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"
find . \ find . \
| sort \ | sort \
| zip -X@ "${OUTDIR}/${DISTNAME}-flatpak.zip" \ | zip -X@ "${OUTDIR}/${DISTNAME}-pack.zip" \
|| ( rm -f "${OUTDIR}/${DISTNAME}-flatpak.zip" && exit 1 ) || ( rm -f "${OUTDIR}/${DISTNAME}-pack.zip" && exit 1 )
fi fi
;; ;;
*darwin*) *darwin*)

121
contrib/guix/pack.scm Normal file
View file

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