Sample Header Ad - 728x90

Guix patching is different than doing it manually

0 votes
0 answers
110 views
I'm trying to build wine-staging from a custom Guix package definition (wine-10.scm) that I've created, based on the official Guix package definitions for Wine. My goal is to build a newer version of Wine (specifically 10.0-rc5) with the Wine-Staging patches applied. I'm using the following command:
guix build -L . wine-staging
With a custom .scm in current directory called wine-10.scm. My wine-10.scm file (simplified for brevity):
(define-module (wine-10)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix gexp)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix utils)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system meson)
  #:use-module (guix build-system trivial)
  #:use-module (gnu packages)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages audio)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages base)
  #:use-module (gnu packages bash)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages cups)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages freedesktop)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages image)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages ghostscript)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gstreamer)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages kerberos)
  #:use-module (gnu packages libusb)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages mingw)
  #:use-module (gnu packages openldap)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages pulseaudio)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages python)
  #:use-module (gnu packages mp3)
  #:use-module (gnu packages photo)
  #:use-module (gnu packages samba)
  #:use-module (gnu packages scanner)
  #:use-module (gnu packages sdl)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages video)
  #:use-module (gnu packages vulkan)
  #:use-module (gnu packages xdisorg)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages xorg)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-1)

(define-public wine-minimal
  (package
    (name "wine-minimal")
    (version "10.0-rc5")
    (source
     (origin
       (method url-fetch)
       (uri (let ((dir "10.0/"))
              (string-append "https://dl.winehq.org/wine/source/ " dir
                             "wine-" version ".tar.xz")))
       (sha256
        (base32 "1lkfjx6sfscq50hhxqq7g3r8wyv6ji1pykak3p1d9lh7bixlz2gc"))))
    (properties '((upstream-name . "wine")))
    (build-system gnu-build-system)
    (native-inputs (list bison flex))
    (inputs `())
    (arguments
     (list
      #:system (match (%current-system)
                 ((or "armhf-linux" "aarch64-linux") "armhf-linux")
                 (_ "i686-linux"))
       #:tests? #f
       #:make-flags
       #~(list "SHELL=bash"
               (string-append "libdir=" #$output "/lib/wine32"))
       #:phases
       #~(modify-phases %standard-phases
           (add-after 'unpack 'patch-SHELL
             (lambda _
               (substitute* "configure"
                 (("/bin/sh")
                  (which "bash")))))
           (add-after 'configure 'patch-dlopen-paths
             (lambda _
               (let* ((library-path (search-path-as-string->list
                                     (getenv "LIBRARY_PATH")))
                      (find-so (lambda (soname)
                                 (search-path library-path soname))))
                 (substitute* "include/config.h"
                   (("(#define SONAME_.* )\"(.*)\"" _ defso soname)
                    (format #f "~a\"~a\"" defso (find-so soname)))))))
           (add-after 'patch-generated-file-shebangs 'patch-makedep
             (lambda* (#:key outputs #:allow-other-keys)
               (substitute* "tools/makedep.c"
                 (("output_filenames\\( unix_libs \\);" all)
                  (string-append all
                   "output ( \" -Wl,-rpath=%s \", arch_install_dirs[arch] );")))))
           (add-before 'build 'set-widl-time-override
             (lambda _
               (setenv "WIDL_TIME_OVERRIDE" "315532800"))))
       #:configure-flags
       #~(list "--without-freetype"
               "--without-x")))
    (home-page "https://www.winehq.org/ ")
    (synopsis "Implementation of the Windows API (32-bit only)")
    (description
     "Wine (originally an acronym for \"Wine Is Not an Emulator\") is a
compatibility layer capable of running Windows applications. Instead of
simulating internal Windows logic like a virtual machine or emulator, Wine
translates Windows API calls into POSIX calls on-the-fly, eliminating the
performance and memory penalties of other methods and allowing you to cleanly
integrate Windows applications into your desktop.")
    (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))
    (license license:lgpl2.1+)))

(define-public wine
  (package
    (inherit wine-minimal)
    (name "wine")
    (native-inputs
     (modify-inputs (package-native-inputs wine-minimal)
       (prepend gettext-minimal perl pkg-config)))
    (inputs
     (list alsa-lib
           bash-minimal
           cups
           dbus
           eudev
           fontconfig
           freetype
           gnutls
           gst-plugins-base
           libgphoto2
           openldap
           samba
           sane-backends
           libpcap
           libusb
           libice
           libx11
           libxi
           libxext
           libxcursor
           libxkbcommon
           libxrender
           libxrandr
           libxinerama
           libxxf86vm
           libxcomposite
           mesa
           mit-krb5
           openal
           pulseaudio
           sdl2
           unixodbc
           v4l-utils
           vkd3d
           vulkan-loader
           wayland
           wayland-protocols))
    (arguments
     (substitute-keyword-arguments (package-arguments wine-minimal)
       ((#:phases phases)
        #~(modify-phases #$phases
           #$@(match (%current-system)
                ((or "i686-linux" "x86_64-linux")
                 `((add-after 'install 'wrap-executable
                     (lambda* (#:key inputs outputs #:allow-other-keys)
                       (let* ((out (assoc-ref outputs "out"))
                              (icd (string-append out "/share/vulkan/icd.d")))
                         (mkdir-p icd)
                         (copy-file (search-input-file
                                     inputs
                                     "/share/vulkan/icd.d/radeon_icd.i686.json")
                                    (string-append icd "/radeon_icd.i686.json"))
                         (copy-file (search-input-file
                                     inputs
                                     "/share/vulkan/icd.d/intel_icd.i686.json")
                                    (string-append icd "/intel_icd.i686.json"))
                         (wrap-program (string-append out "/bin/wine-preloader")
                           `("VK_ICD_FILENAMES" ":" =
                             (,(string-append icd
                                              "/radeon_icd.i686.json" ":"
                                              icd "/intel_icd.i686.json")))))))))
                (_
                 `()))))
       ((#:configure-flags _ '()) #~'())))))

(define-public wine64
  (package
    (inherit wine)
    (name "wine64")
    (inputs (modify-inputs (package-inputs wine)
              (prepend wine)))
    (arguments
     (substitute-keyword-arguments
         (strip-keyword-arguments '(#:system) (package-arguments wine))
       ((#:make-flags _)
        #~(list "SHELL=bash"
                (string-append "libdir=" #$output "/lib/wine64"))
        )
       ((#:phases phases)
        #~(modify-phases #$phases
            (add-after 'install 'copy-wine32-binaries
              (lambda* (#:key inputs outputs #:allow-other-keys)
                (let ((out (assoc-ref %outputs "out")))
                  (copy-file (search-input-file inputs "/bin/wine")
                             (string-append out "/bin/wine"))
                  (copy-file (search-input-file inputs "/bin/.wine-preloader-real")
                             (string-append out "/bin/wine-preloader")))))
            (add-after 'install 'copy-wine32-libraries
              (lambda* (#:key inputs outputs #:allow-other-keys)
                (let* ((out (assoc-ref %outputs "out")))
                  (copy-recursively (search-input-directory inputs "/lib/wine32")
                                    (string-append out "/lib/wine32")))))
            #$@(match (%current-system)
                 ((or "x86_64-linux")
                  `((delete 'wrap-executable)
                    (add-after 'copy-wine32-binaries 'wrap-executable
                      (lambda* (#:key inputs outputs #:allow-other-keys)
                        (let* ((out (assoc-ref outputs "out"))
                               (icd-files (map
                                           (lambda (basename)
                                             (search-input-file
                                              inputs
                                              (string-append "/share/vulkan/icd.d/"
                                                             basename)))
                                           '("radeon_icd.x86_64.json"
                                             "intel_icd.x86_64.json"
                                             "radeon_icd.i686.json"
                                             "intel_icd.i686.json"))))
                          (wrap-program (string-append out "/bin/wine-preloader")
                            `("VK_ICD_FILENAMES" ":" = ,icd-files))
                          (wrap-program (string-append out "/bin/wine64-preloader")
                            `("VK_ICD_FILENAMES" ":" = ,icd-files)))))))
                 (_
                  `()))
            (add-after 'compress-documentation 'copy-wine32-manpage
              (lambda* (#:key inputs outputs #:allow-other-keys)
                (let* ((out (assoc-ref %outputs "out")))
                  (copy-file (search-input-file inputs "/share/man/man1/wine.1.zst")
                             (string-append out "/share/man/man1/wine.1.zst")))))))
       ((#:configure-flags configure-flags '())
        #~(cons "--enable-win64" #$configure-flags))))
    (synopsis "Implementation of the Windows API (WoW64 version)")
    (supported-systems '("x86_64-linux" "aarch64-linux"))))

(define-public wine-staging-patchset-data
  (package
    (name "wine-staging-patchset-data")
    (version "10.0-rc5")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/wine-staging/wine-staging ")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1bphg408avr5kf1d4bkx90s4kfjiykm3ssph8lj2v1zibxhb53wy"))))
    (build-system trivial-build-system)
    (native-inputs
     (list coreutils))
    (arguments
     `(#:modules ((guix build utils))
       #:builder
       (begin
         (use-modules (guix build utils))
         (let* ((build-directory ,(string-append name "-" version))
                (source (assoc-ref %build-inputs "source"))
                (coreutils (assoc-ref %build-inputs "coreutils"))
                (out (assoc-ref %outputs "out"))
                (wine-staging (string-append out "/share/wine-staging")))
           (copy-recursively source build-directory)
           (with-directory-excursion build-directory
             (substitute* '("patches/gitapply.sh" "staging/patchinstall.py")
               (("/usr/bin/env")
                (string-append coreutils "/bin/env"))))
           (copy-recursively build-directory wine-staging)
           #t))))
    (home-page "https://github.com/wine-staging ")
    (synopsis "Patchset for Wine")
    (description
     "wine-staging-patchset-data contains the patchset to build Wine-Staging.")
    (license license:lgpl2.1+)))

(define-public wine-staging
  (package
    (inherit wine)
    (name "wine-staging")
    (version "10.0-rc5")
    (source
     (let* ((wine-version "10.0-rc5")
            (subdirectory "10.0"))
       (origin
         (method url-fetch)
         (uri (string-append "https://dl.winehq.org/wine/source/ "
                             subdirectory "/"
                             "wine-" wine-version ".tar.xz"))
         (file-name (string-append name "-" wine-version ".tar.xz"))
         (sha256
          (base32 "1lkfjx6sfscq50hhxqq7g3r8wyv6ji1pykak3p1d9lh7bixlz2gc")))))
    (inputs (modify-inputs (package-inputs wine)
              (prepend autoconf
                       ffmpeg
                       gtk+
                       libva
                       mesa
                       python
                       util-linux
                       wine-staging-patchset-data)))
    (native-inputs
     (modify-inputs (package-native-inputs wine)
       (prepend python-3)))
    (arguments
     (substitute-keyword-arguments (package-arguments wine)
       ((#:phases phases)
        #~(modify-phases #$phases
            (delete 'patch-SHELL)
            (add-before 'configure 'apply-wine-staging-patches
              (lambda* (#:key inputs #:allow-other-keys)
                 (invoke "bash" "-c" "\"echo hello\"")
                ;(invoke (search-input-file
                ;         inputs
                ;         "/share/wine-staging/staging/patchinstall.py")
                ;        "DESTDIR=."
                 ;       "--all")
                ))
            (add-after 'apply-wine-staging-patches 'patch-SHELL
              (assoc-ref #$phases 'patch-SHELL))))))
    (synopsis "Implementation of the Windows API (staging branch, 32-bit only)")
    (description "Wine-Staging is the testing area of Wine. It
contains bug fixes and features, which have not been integrated into
the development branch yet. The idea of Wine-Staging is to provide
experimental features faster to end users and to give developers the
possibility to discuss and improve their patches before they are
integrated into the main branch.")
    (home-page "https://github.com/wine-staging ")
    (license
     (list license:lgpl2.1+ license:silofl1.1 license:gpl3+ license:asl2.0))))

(define-public wine64-staging
  (package
    (inherit wine-staging)
    (name "wine64-staging")
    (inputs (modify-inputs (package-inputs wine-staging)
              (prepend wine-staging)))
    (arguments
     (substitute-keyword-arguments (package-arguments wine64)
       ((#:phases phases)
        #~(modify-phases #$phases
            (delete 'patch-SHELL)
            (add-before 'configure 'apply-wine-staging-patches
              (lambda* (#:key inputs #:allow-other-keys)
                (invoke (search-input-file
                         inputs
                         "/share/wine-staging/staging/patchinstall.py")
                        "DESTDIR=."
                        "--all")))
            (add-after 'apply-wine-staging-patches 'patch-SHELL
              (assoc-ref #$phases 'patch-SHELL))))))
    (synopsis "Implementation of the Windows API (staging branch, WoW64
version)")
    (supported-systems '("x86_64-linux" "aarch64-linux"))))
The build process fails with the following error:
... (Many successful patch applications) ...
patching dlls/advapi32/tests/security.c
1 out of 4 hunks FAILED -- saving rejects to file dlls/advapi32/tests/security.c.rej
[PATCH] ERR: Textual patch did not apply, aborting.
/gnu/store/0fsw4g8zql5c6kvrk44f3w551xamca17-wine-staging-patchset-data-10.0-rc5/share/wine-staging/staging/../patches/server-Stored_ACLs/0004-server-Temporarily-store-the-full-security-descripto.patch
Failed to apply patch server-Stored_ACLs/0004-server-Temporarily-store-the-full-security-descripto.patch
However when I untar the same source from the store, and apply it. Directly it works. Furthermore it seems guix writes something like:
patching dlls/ntdll/loader.c
patching configure.ac
patching dlls/advapi32/lsa.c
patching dlls/advapi32/tests/lsa.c
patching dlls/comctl32/rebar.c
which does NOT happen when I patch manually, there is something going on, not sure what. When patching manually I only get:
/gnu/store/0fsw4g8zql5c6kvrk44f3w551xamca17-wine-staging-patchset-data-10.0-rc5/share/wine-staging/staging/../patches/gitapply.sh -d . < /gnu/store/0fsw4g8zql5c6kvrk44f3w551xamca17-wine-staging-patchset-data-10.0-rc5/share/wine-staging/staging/../patches/Staging/0001-ntdll-Print-a-warning-message-specifying-the-wine-st.patch
How I manually patch:
tar -xvf /gnu/store/x46d8vfy507g9i8hrnfc3lwl5vq79xi2-wine-staging-10.0-rc5.tar.xz # must have already been retrieved by guix
cd wine-10.0-rc5
/gnu/store/0fsw4g8zql5c6kvrk44f3w551xamca17-wine-staging-patchset-data-10.0-rc5/share/wine-staging/staging/patchinstall.py DESTDIR=. --all
As you can see I am using the exact same sources from guix store!
Asked by Rainb (123 rep)
Jan 19, 2025, 10:45 PM