flatpak: cleanup pack

This commit is contained in:
tobtoht 2023-06-28 17:30:29 +02:00
parent f439cda9eb
commit 4c9b30fea0
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
8 changed files with 93 additions and 169 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"

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
@ -23,6 +24,9 @@ cp /feather/contrib/flatpak/metadata .
mkdir files mkdir files
cd files cd files
# Extract feather binary
unzip /feather-zip
# Copy metadata # Copy metadata
cp -a /feather/contrib/flatpak/share . cp -a /feather/contrib/flatpak/share .
touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" share/metainfo/${APP_ID}.metainfo.xml touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" share/metainfo/${APP_ID}.metainfo.xml
@ -32,44 +36,26 @@ gzip -c share/metainfo/${APP_ID}.metainfo.xml > share/app-info/xmls/${APP_ID}.xm
tar xf /pack . tar xf /pack .
# Get store paths # Get store paths
GUIX_BASH_STATIC=$(get_store_path "bash-static")
GUIX_COREUTILS=$(get_store_path "coreutils-minimal")
GUIX_GLIBC=$(get_store_path "glibc")
GUIX_PROFILE=$(get_store_path "profile") GUIX_PROFILE=$(get_store_path "profile")
GUIX_GLIBC=$(get_store_path "glibc")
GUIX_FONTCONFIG=$(get_store_path "fontconfig")
GUIX_GCC=$(get_store_path "gcc")
LN_GUIX_STORE="$(get_store_path "ln-guix-store")/bin/ln-guix-store"
GLIBC_VERSION="${GUIX_GLIBC##*-}" # Patch Feather binary
patchelf --set-interpreter "/${GUIX_GLIBC}/lib/ld-linux-x86-64.so.2" feather
# Patch ln patchelf --set-rpath "/${GUIX_GLIBC}/lib:/${GUIX_FONTCONFIG}/lib:/${GUIX_GCC}/lib" feather
LN_PATH="${GUIX_COREUTILS}/bin/ln"
chmod 655 "${LN_PATH}"
patchelf --set-rpath "/app/${GUIX_GLIBC}/lib" "${LN_PATH}"
patchelf --set-interpreter "/app/${GUIX_GLIBC}/lib/ld-linux-x86-64.so.2" "${LN_PATH}"
# Fonts # Fonts
# fontconfig looks in /app/share/fonts # fontconfig looks in /app/share/fonts
ln -s "/${GUIX_PROFILE}/share/fonts" share/fonts ln -s "/run/host/fonts" share/fonts
ln -s "/run/host/fonts-cache" share/fonts-cache
ln -s "/${GUIX_PROFILE}/share/locale" share/locale ln -s "/${GUIX_PROFILE}/share/locale" share/locale
ln -s "/${GUIX_PROFILE}/share/dbus-1" share/dbus-1 ln -s "/${GUIX_PROFILE}/share/dbus-1" share/dbus-1
ln -s "/${GUIX_PROFILE}/share/xml" share/xml ln -s "/${GUIX_PROFILE}/share/xml" share/xml
chmod 555 "${LN_PATH}" # Setup profile symlink
ln -s "/${GUIX_PROFILE}" profile
# create startup.sh # Setup startup symlink
cat << EOF > startup.sh ln -s "/app/${LN_GUIX_STORE}" startup
#!/app/${GUIX_BASH_STATIC}/bin/bash
/app/${LN_PATH} -s /app/gnu /gnu
export PATH="/${GUIX_PROFILE}/bin"
mkdir -p /etc/ssl
# Qt expects certs to be here, see: qtbase/src/network/ssl/qsslsocket.cpp
ln -s /${GUIX_PROFILE}/etc/ssl/certs /etc/ssl/certs
mkdir -p /run/current-system/locale/${GLIBC_VERSION}
ln -s /${GUIX_PROFILE}/lib/locale/${GLIBC_VERSION}/en_US.UTF-8 /run/current-system/locale/${GLIBC_VERSION}
# Feather interpreter is set to /lib64/ld-linux-x86-64.so.2
# Guix pack includes glibc twice if we add glibc to the inputs in flatpak.scm, so this is an alternative to patching
ln -s /${GUIX_GLIBC}/lib /lib64
feather
EOF
chmod 555 startup.sh

View file

@ -2,7 +2,7 @@
name=org.featherwallet.Feather name=org.featherwallet.Feather
runtime=org.featherwallet.Empty/x86_64/stable runtime=org.featherwallet.Empty/x86_64/stable
sdk=org.featherwallet.Empty/x86_64/stable sdk=org.featherwallet.Empty/x86_64/stable
command=/app/startup.sh command=/app/startup
[Context] [Context]
shared=network;ipc; shared=network;ipc;

View file

@ -4,7 +4,7 @@ Name=Feather Wallet
GenericName=Monero Wallet GenericName=Monero Wallet
Comment=A free Monero desktop wallet Comment=A free Monero desktop wallet
Icon=org.featherwallet.Feather Icon=org.featherwallet.Feather
Exec=/app/startup.sh Exec=/app/startup
Terminal=false Terminal=false
Categories=Network;Qt;Finance Categories=Network;Qt;Finance
StartupNotify=false StartupNotify=false

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,29 @@ EOF
case "$OPTIONS" in case "$OPTIONS" in
flatpak) pack)
export FILE="$(outdir_for_host "$host")/${DISTNAME}-flatpak.zip" FEATHER_ZIP="$(outdir_for_host "$host")/${DISTNAME}-pack.zip"
export HASH=$(guix hash "${FILE}") time-machine pack -S /profile=. --manifest="${PWD}/contrib/guix/pack.scm"
export VERSION=${VERSION} PACK=$(time-machine pack --manifest="${PWD}/contrib/guix/pack.scm")
time-machine pack -S /opt/gnu/bin=bin --manifest="${PWD}/contrib/flatpak/flatpak.scm" time-machine pack -R --manifest="${PWD}/contrib/guix/pack.scm"
PACK=$(time-machine pack --manifest="${PWD}/contrib/flatpak/flatpak.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 \ time-machine environment --ad-hoc unzip 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 \
--share="$FEATHER_ZIP"=/feather-zip \
--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" bash -c "cd /feather && \
bash contrib/flatpak/make_flatpak.sh"
;; ;;
esac esac
) )

View file

@ -292,7 +292,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
@ -337,7 +337,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}"
@ -413,7 +413,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
"") "")
@ -436,8 +436,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*)

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

@ -0,0 +1,53 @@
(use-modules
(gnu packages)
(gnu packages certs)
(gnu packages fontutils)
(gnu packages zig)
(guix build-system gnu)
(guix download)
((guix licenses) #:prefix license:)
(guix packages)
(guix utils))
(define-public ln-guix-store
(package
(name "ln-guix-store")
(version "a148fb86c30968eeb30dc6ac3384ad2a16690520")
(source (origin
(method url-fetch)
(uri (string-append
"https://github.com/tobtoht/ln-guix-store/archive/" version ".tar.gz"))
(sha256 (base32 "0nrncjix2c18px2cm67acz7c15hji2dl6ynsfh1v1z7rlk6lysg9"))))
(build-system gnu-build-system)
(arguments
(list
#:make-flags
#~(list (string-append "PREFIX=" #$output)
(string-append "CC=" #$(cc-for-target)))
#:phases
#~(modify-phases %standard-phases
(delete 'configure) ; No configure script.
(add-before 'build 'pre-build
(lambda _
(setenv "ZIG_GLOBAL_CACHE_DIR"
(mkdtemp "/tmp/zig-cache-XXXXXX"))))
(delete 'check))))
(native-inputs
(list zig))
(synopsis "Symlink /app/gnu to /gnu")
(description "Tiny program to symlink /app/gnu to /gnu inside a Flatpak")
(license license:bsd-3)
(home-page "https://featherwallet.org/")))
(define utf8-locales
(make-glibc-utf8-locales
glibc
#:locales (list "en_US")
#:name "utf8-locales"))
(packages->manifest
(append
(list nss-certs
fontconfig
ln-guix-store
utf8-locales)))