Subject: [bug#40084] [PATCH] gnu: Add v86d.

From: Jakub Kądziołka <[email-masked]>
Date: Thu, 19 Mar 2020 15:49:08 +0100

On Sun, Mar 15, 2020 at 10:48:51PM +0100, Florian Pelz wrote:
> +         ;; Replace the bundled x86emu with its upstream copy from Xorg-server:
> +         (add-after 'unpack 'unpack-x86emu-sources
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (begin
> +               (format #t "decompressing x86emu source code~%")
> +               (with-directory-excursion "libs"
> +                 (call-with-output-file "xorg-server.tar"
> +                   (lambda (out)
> +                     (let* ((xz (assoc-ref inputs "xz"))
> +                            (srcs (assoc-ref inputs "xorg-server-sources"))
> +                            (pipe (open-pipe* OPEN_READ
> +                                              (string-append xz "/bin/xz")
> +                                              "-cd" srcs)))
> +                       (dump-port pipe out)
> +                       (unless (= (status:exit-val (close-pipe pipe)) 0)
> +                         (error "xz decompress failed")))))
> +                 (invoke (string-append (assoc-ref inputs "tar") "/bin/tar")
> +                         "xvf" "xorg-server.tar" "--strip-components=3"
> +                         "--wildcards" "*/hw/xfree86/x86emu/")
> +                 ;; extract license:
> +                 (with-directory-excursion "x86emu"
> +                   (invoke (string-append (assoc-ref inputs "tar") "/bin/tar")
> +                           "xvf" "../xorg-server.tar" "--strip-components=1"
> +                           "--wildcards" "*/COPYING"))
> +                 (delete-file "xorg-server.tar")
> +                 #t))))

I don't see why you're decompressing the tarball manually, this seems to
work just as well:

 (add-after 'unpack 'unpack-x86emu-sources
   (lambda* (#:key inputs #:allow-other-keys)
     (begin
       (format #t "decompressing x86emu source code~%")
       (with-directory-excursion "libs"
         (invoke (string-append (assoc-ref inputs "tar") "/bin/tar")
                 "xvf" (assoc-ref inputs "xorg-server-sources")
                 "--strip-components=3"
                 "--wildcards" "*/hw/xfree86/x86emu/")
         ;; extract license:
         (with-directory-excursion "x86emu"
           (invoke (string-append (assoc-ref inputs "tar") "/bin/tar")
                   "xvf" (assoc-ref inputs "xorg-server-sources")
                   "--strip-components=1"
                   "--wildcards" "*/COPYING"))
         #t))))

If it's about efficiency or robustness in some way, I'd suggest leaving
a comment detailing the reason. Either way, I'd bind the path to tar in
a `let', as well as the path to "xorg-server-sources" if we decide to
not decompress separately.

> +         (replace 'configure
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let ((out (assoc-ref outputs "out")))
> +               (setenv "CC" (which "gcc"))
> +               (setenv "DESTDIR" out)
> +               (invoke "./configure" "--with-x86emu"))))
> +         (add-after 'build 'build-testvbe
> +           (lambda _
> +             (invoke "make" "testvbe")))
> +         (add-after 'install 'install-testvbe
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let ((testvbe (assoc-ref outputs "testvbe"))
> +                   (olddest (getenv "DESTDIR")))
> +               (setenv "DESTDIR" testvbe)
> +               (invoke "make" "install_testvbe")
> +               (setenv "DESTDIR" olddest))))

These phases are missing the trailing #t.

I don't know how to test the package, but it passes lint & build,
including --rounds=2 to check for reproducibility.

Regards,
Jakub Kądziołka