[bug#73522,games-team,06/14] gnu: retroarch: Clean-up source from extraneous bundled libraries.

Message ID fb2302832453e4c56054fa02235ee01373a785f8.1728192708.git.maxim.cournoyer@gmail.com
State New
Headers
Series Package and use RetroArch assets, plus other improvements. |

Commit Message

Maxim Cournoyer Oct. 6, 2024, 5:32 a.m. UTC
  * gnu/packages/emulators.scm (retroarch) [source]: Add snippet removing
unnecessary sources.
[license]: Add licenses of bundled sources.

Change-Id: I824391424bf0fa2ec3888f02535b94dea3021378
---

 gnu/packages/emulators.scm | 45 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)
  

Comments

Liliana Marie Prikler Oct. 6, 2024, 6:55 a.m. UTC | #1
Am Sonntag, dem 06.10.2024 um 14:32 +0900 schrieb Maxim Cournoyer:
> * gnu/packages/emulators.scm (retroarch) [source]: Add snippet
> removing
> unnecessary sources.
> [license]: Add licenses of bundled sources.
> 
> Change-Id: I824391424bf0fa2ec3888f02535b94dea3021378
> ---
> 
>  gnu/packages/emulators.scm | 45
> +++++++++++++++++++++++++++++++++++++-
>  1 file changed, 44 insertions(+), 1 deletion(-)
> 
> diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
> index afe11caf7f..e6cf365e26 100644
> --- a/gnu/packages/emulators.scm
> +++ b/gnu/packages/emulators.scm
> @@ -1587,6 +1587,43 @@ (define-public retroarch
>         (uri (git-reference
>               (url "https://github.com/libretro/RetroArch")
>               (commit (string-append "v" version))))
> +       (modules '((guix build utils)
> +                  (ice-9 ftw)
> +                  (srfi srfi-26)))
> +       (snippet
> +        #~(begin
> +            ;; XXX: 'delete-all-but' is copied from the turbovnc
> package.
> +            (define (delete-all-but directory . preserve)
> +              (define (directory? x)
> +                (and=> (stat x #f)
> +                       (compose (cut eq? 'directory <>) stat:type)))
> +              (with-directory-excursion directory
> +                (let* ((pred
> +                        (negate (cut member <> (append '("." "..")
> preserve))))
> +                       (items (scandir "." pred)))
> +                  (for-each (lambda (item)
> +                              (if (directory? item)
> +                                  (delete-file-recursively item)
> +                                  (delete-file item)))
> +                            items))))
> +            ;; Remove as much bundled sources as possible, shaving
> off about
> +            ;; 17 MiB.
> +            (delete-all-but "deps"
> +                            "7zip"
> +                            "SPIRV-Cross"   ;used in
> slang_reflection.cpp
Can we unvendor spirv-cross?
> +                            "discord-rpc"   ;used in
> network/discord.h
Can we drop this discord thing?
> +                            "dr"            ;used in audio_mixer.c
> +                            "feralgamemode" ;used in platform_unix.c
> +                            "ibxm"          ;used in audio_mixer.c
> +                            "mbedtls"       ;further refined below
> +                            "rcheevos"      ;used in menu_setting.c
> +                            "stb"           ;used in audio_mixer.c
> +                            "switchres"     ;used in
> video_crt_switch.c
> +                            "xdelta3"       ;used in task_patch.c
> +                            "yxml")         ;used in rxml.c
> +            ;; This is an old root certificate used in
> net_socket_ssl_mbed.c,
> +            ;; not actually from mbedtls.
> +            (delete-all-but "deps/mbedtls" "cacert.h")))
>         (file-name (git-file-name name version))
>         (sha256
>          (base32
> "15nh4y4vpf4n1ryhiy4fwvzn5xz5idzfzn9fsi5v9hzp25vbjmrm"))))
> @@ -1669,7 +1706,13 @@ (define-public retroarch
>  straight into any libretro-compatible frontend.  RetroArch is the
> official
>  reference frontend for the libretro API, currently used by most as a
> modular
>  multi-system game/emulator system.")
> -    (license license:gpl3+)))
> +    (license (list license:gpl3+         ;for RetroArch itself
> +                   license:asl2.0        ;SPIRV-Cross, xdelta3
> +                   license:public-domain ;7zip, stb
> +                   license:expat         ;discord-rpc, rcheevos,
> yxml
> +                   license:unlicense     ;dr
> +                   license:bsd-3         ;feragamemode, ibxm
> +                   license:gpl2+))))    ;switchres
Cheers
  
Maxim Cournoyer Oct. 6, 2024, 8:12 a.m. UTC | #2
Hi Liliana,

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

> Am Sonntag, dem 06.10.2024 um 14:32 +0900 schrieb Maxim Cournoyer:
>> * gnu/packages/emulators.scm (retroarch) [source]: Add snippet
>> removing
>> unnecessary sources.
>> [license]: Add licenses of bundled sources.
>> 
>> Change-Id: I824391424bf0fa2ec3888f02535b94dea3021378
>> ---
>> 
>>  gnu/packages/emulators.scm | 45
>> +++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 44 insertions(+), 1 deletion(-)
>> 
>> diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
>> index afe11caf7f..e6cf365e26 100644
>> --- a/gnu/packages/emulators.scm
>> +++ b/gnu/packages/emulators.scm
>> @@ -1587,6 +1587,43 @@ (define-public retroarch
>>         (uri (git-reference
>>               (url "https://github.com/libretro/RetroArch")
>>               (commit (string-append "v" version))))
>> +       (modules '((guix build utils)
>> +                  (ice-9 ftw)
>> +                  (srfi srfi-26)))
>> +       (snippet
>> +        #~(begin
>> +            ;; XXX: 'delete-all-but' is copied from the turbovnc
>> package.
>> +            (define (delete-all-but directory . preserve)
>> +              (define (directory? x)
>> +                (and=> (stat x #f)
>> +                       (compose (cut eq? 'directory <>) stat:type)))
>> +              (with-directory-excursion directory
>> +                (let* ((pred
>> +                        (negate (cut member <> (append '("." "..")
>> preserve))))
>> +                       (items (scandir "." pred)))
>> +                  (for-each (lambda (item)
>> +                              (if (directory? item)
>> +                                  (delete-file-recursively item)
>> +                                  (delete-file item)))
>> +                            items))))
>> +            ;; Remove as much bundled sources as possible, shaving
>> off about
>> +            ;; 17 MiB.
>> +            (delete-all-but "deps"
>> +                            "7zip"
>> +                            "SPIRV-Cross"   ;used in
>> slang_reflection.cpp
> Can we unvendor spirv-cross?

It could be done, but it'd have to be new development as their build
system doesn't currently support it.  I'll give it another try right
now, but if it becomes too much work, I'll drop it.

>> +                            "discord-rpc"   ;used in
>> network/discord.h
> Can we drop this discord thing?

Not easily, no.  I had checked and there's no switch to opt out in the
build system.

-- 
Thanks,
Maxim
  
Maxim Cournoyer Oct. 6, 2024, 4:26 p.m. UTC | #3
Hi again,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

[...]

>> Can we unvendor spirv-cross?
>
> It could be done, but it'd have to be new development as their build
> system doesn't currently support it.  I'll give it another try right
> now, but if it becomes too much work, I'll drop it.

I've spent the evening on it, but in the end it works!

>>> +                            "discord-rpc"   ;used in
>>> network/discord.h
>> Can we drop this discord thing?
>
> Not easily, no.  I had checked and there's no switch to opt out in the
> build system.

Actually I was wrong, after getting more knowledgeable about its
'quickbuild / qb' build configure script. I could pass --disable-discord
and a bunch of others to remove support provided via bundled libraries.

I've now push the series (see commit 3e9ebe7f28 and previous ones) with
these changes; you are welcome to inspect the result and let me know if
something is amiss.

Thanks for the review.

Happy hacking!
  

Patch

diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
index afe11caf7f..e6cf365e26 100644
--- a/gnu/packages/emulators.scm
+++ b/gnu/packages/emulators.scm
@@ -1587,6 +1587,43 @@  (define-public retroarch
        (uri (git-reference
              (url "https://github.com/libretro/RetroArch")
              (commit (string-append "v" version))))
+       (modules '((guix build utils)
+                  (ice-9 ftw)
+                  (srfi srfi-26)))
+       (snippet
+        #~(begin
+            ;; XXX: 'delete-all-but' is copied from the turbovnc package.
+            (define (delete-all-but directory . preserve)
+              (define (directory? x)
+                (and=> (stat x #f)
+                       (compose (cut eq? 'directory <>) stat:type)))
+              (with-directory-excursion directory
+                (let* ((pred
+                        (negate (cut member <> (append '("." "..") preserve))))
+                       (items (scandir "." pred)))
+                  (for-each (lambda (item)
+                              (if (directory? item)
+                                  (delete-file-recursively item)
+                                  (delete-file item)))
+                            items))))
+            ;; Remove as much bundled sources as possible, shaving off about
+            ;; 17 MiB.
+            (delete-all-but "deps"
+                            "7zip"
+                            "SPIRV-Cross"   ;used in slang_reflection.cpp
+                            "discord-rpc"   ;used in network/discord.h
+                            "dr"            ;used in audio_mixer.c
+                            "feralgamemode" ;used in platform_unix.c
+                            "ibxm"          ;used in audio_mixer.c
+                            "mbedtls"       ;further refined below
+                            "rcheevos"      ;used in menu_setting.c
+                            "stb"           ;used in audio_mixer.c
+                            "switchres"     ;used in video_crt_switch.c
+                            "xdelta3"       ;used in task_patch.c
+                            "yxml")         ;used in rxml.c
+            ;; This is an old root certificate used in net_socket_ssl_mbed.c,
+            ;; not actually from mbedtls.
+            (delete-all-but "deps/mbedtls" "cacert.h")))
        (file-name (git-file-name name version))
        (sha256
         (base32 "15nh4y4vpf4n1ryhiy4fwvzn5xz5idzfzn9fsi5v9hzp25vbjmrm"))))
@@ -1669,7 +1706,13 @@  (define-public retroarch
 straight into any libretro-compatible frontend.  RetroArch is the official
 reference frontend for the libretro API, currently used by most as a modular
 multi-system game/emulator system.")
-    (license license:gpl3+)))
+    (license (list license:gpl3+         ;for RetroArch itself
+                   license:asl2.0        ;SPIRV-Cross, xdelta3
+                   license:public-domain ;7zip, stb
+                   license:expat         ;discord-rpc, rcheevos, yxml
+                   license:unlicense     ;dr
+                   license:bsd-3         ;feragamemode, ibxm
+                   license:gpl2+))))    ;switchres
 
 (define-public wasm4
   (package