]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
flatpak: cleanup pack
authortobtoht <tob@featherwallet.org>
Wed, 28 Jun 2023 15:30:29 +0000 (17:30 +0200)
committertobtoht <tob@featherwallet.org>
Wed, 28 Jun 2023 17:02:36 +0000 (19:02 +0200)
.github/workflows/guix.yml
contrib/flatpak/flatpak.scm [deleted file]
contrib/flatpak/make_flatpak.sh
contrib/flatpak/metadata
contrib/flatpak/share/applications/org.featherwallet.Feather.desktop
contrib/guix/guix-build
contrib/guix/libexec/build.sh
contrib/guix/pack.scm [new file with mode: 0644]

index 1e2e20242cdb8cfd6600a67a1a135226c6c8780d..900607fe17e47beacc68ef3488d0c62195e28118 100644 (file)
@@ -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/flatpak/flatpak.scm b/contrib/flatpak/flatpak.scm
deleted file mode 100644 (file)
index ce34e07..0000000
+++ /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
index 0fb4c0a447ae9cb5538b145fba62d9d1341a07e2..eeee508f73eaf6ccc32ed4137cfd44debcc19a5f 100644 (file)
@@ -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
@@ -23,6 +24,9 @@ cp /feather/contrib/flatpak/metadata .
 mkdir files
 cd files
 
+# Extract feather binary
+unzip /feather-zip
+
 # Copy metadata
 cp -a /feather/contrib/flatpak/share .
 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 .
 
 # 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_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 ln
-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}"
+# Patch Feather binary
+patchelf --set-interpreter "/${GUIX_GLIBC}/lib/ld-linux-x86-64.so.2" feather
+patchelf --set-rpath "/${GUIX_GLIBC}/lib:/${GUIX_FONTCONFIG}/lib:/${GUIX_GCC}/lib" feather
 
 # 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/dbus-1" share/dbus-1
 ln -s "/${GUIX_PROFILE}/share/xml" share/xml
 
-chmod 555 "${LN_PATH}"
-
-# create startup.sh
-cat << EOF > startup.sh
-#!/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
+# Setup profile symlink
+ln -s "/${GUIX_PROFILE}" profile
 
-chmod 555 startup.sh
\ No newline at end of file
+# Setup startup symlink
+ln -s "/app/${LN_GUIX_STORE}" startup
\ No newline at end of file
index 297a327db1ea7489153e5c36a48d29cedd75c239..9df03231a682ebd5263dc527f49f06c2ec47bc97 100644 (file)
@@ -2,7 +2,7 @@
 name=org.featherwallet.Feather
 runtime=org.featherwallet.Empty/x86_64/stable
 sdk=org.featherwallet.Empty/x86_64/stable
-command=/app/startup.sh
+command=/app/startup
 
 [Context]
 shared=network;ipc;
index f0af2863534e254901a3f9605926548fb08551f0..bdfeaff0aafcc82141585302b08ce627f34690be 100644 (file)
@@ -4,7 +4,7 @@ Name=Feather Wallet
 GenericName=Monero Wallet
 Comment=A free Monero desktop wallet
 Icon=org.featherwallet.Feather
-Exec=/app/startup.sh
+Exec=/app/startup
 Terminal=false
 Categories=Network;Qt;Finance
 StartupNotify=false
index f353b518a33f41be1f7d34e39483131df665fb58..a977977e81f9e6d29ee367aa9dbd83523de90484 100755 (executable)
@@ -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,29 @@ EOF
 
 
         case "$OPTIONS" in
-            flatpak)
-                export FILE="$(outdir_for_host "$host")/${DISTNAME}-flatpak.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 \
+            pack)
+                FEATHER_ZIP="$(outdir_for_host "$host")/${DISTNAME}-pack.zip"
+                time-machine pack -S /profile=. --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 unzip 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 \
+                                         --share="$FEATHER_ZIP"=/feather-zip \
                                          --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"
+                                         bash -c "cd /feather && \
+                                                  bash contrib/flatpak/make_flatpak.sh"
                 ;;
         esac
     )
index d931216e295d1586802a9710cc8eb38041f16b2d..631495e78030dad6018178d8482501d5acab9f26 100755 (executable)
@@ -292,7 +292,7 @@ mkdir -p "$DISTSRC"
                     CMAKEVARS+=" -DTOR_DIR=Off -DTOR_VERSION=Off"
                     ANONDIST+="-a"
                     ;;
-                flatpak)
+                pack)
                     CMAKEVARS+=" -DCHECK_UPDATES=Off -DSELF_CONTAINED=Off"
                     ;;
             esac
@@ -337,7 +337,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}"
@@ -413,7 +413,7 @@ mkdir -p "$DISTSRC"
                 esac
                 ;;
             *linux*)
-                if [ "$OPTIONS" != "flatpak" ]; then
+                if [ "$OPTIONS" != "pack" ]; then
                     mv feather "${DISTNAME}"
                     case "$OPTIONS" in
                         "")
@@ -436,8 +436,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 (file)
index 0000000..1bfbf79
--- /dev/null
@@ -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)))
\ No newline at end of file