From 487ec682c64fea85ff48ab44d6d918c388f43565 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Fri, 3 Jan 2020 19:32:52 +0100 Subject: [PATCH 2/2] gnu: qtwebengine: Purge unused bundled software from the source. * gnu/packages/qt.scm (qtwebengine)[source](modules, snippet): New fields. [inputs]: Add CURL and VALGRIND. --- gnu/packages/qt.scm | 200 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 190 insertions(+), 10 deletions(-) diff --git a/gnu/packages/qt.scm b/gnu/packages/qt.scm index d6ceb5b90f..38a620c90c 100644 --- a/gnu/packages/qt.scm +++ b/gnu/packages/qt.scm @@ -11,7 +11,7 @@ ;;; Copyright © 2018 Nicolas Goaziou ;;; Copyright © 2018 Hartmut Goebel ;;; Copyright © 2018 Eric Bavier -;;; Copyright © 2019 Marius Bakke +;;; Copyright © 2019, 2020 Marius Bakke ;;; Copyright © 2018 John Soo ;;; Copyright © 2020 Mike Rosset ;;; @@ -47,6 +47,7 @@ #:use-module (gnu packages cmake) #:use-module (gnu packages compression) #:use-module (gnu packages cups) + #:use-module (gnu packages curl) #:use-module (gnu packages databases) #:use-module (gnu packages documentation) #:use-module (gnu packages fontutils) @@ -83,6 +84,7 @@ #:use-module (gnu packages sqlite) #:use-module (gnu packages telephony) #:use-module (gnu packages tls) + #:use-module (gnu packages valgrind) #:use-module (gnu packages video) #:use-module (gnu packages vulkan) #:use-module (gnu packages xdisorg) @@ -2036,15 +2038,191 @@ time Web content can be enhanced with native controls.") (inherit qtsvg) (name "qtwebengine") (version (package-version qtbase)) - (source (origin - (method url-fetch) - (uri (string-append "https://download.qt.io/official_releases/qt/" - (version-major+minor version) "/" version - "/submodules/" name "-everywhere-src-" - version ".tar.xz")) - (sha256 - (base32 - "08c60nh95m98mcqk444axs76xi6m9x0wvdxrzk9c2cxwqdbz59fa")))) + (source + (origin + (method url-fetch) + (uri (string-append "https://download.qt.io/official_releases/qt/" + (version-major+minor version) "/" version + "/submodules/" name "-everywhere-src-" + version ".tar.xz")) + (sha256 + (base32 + "08c60nh95m98mcqk444axs76xi6m9x0wvdxrzk9c2cxwqdbz59fa")) + (modules '((ice-9 ftw) + (ice-9 match) + (srfi srfi-1) + (srfi srfi-26) + (guix build utils))) + (snippet + '(begin + (let ((preserved-third-party-files + '("base/third_party/dmg_fp" + "base/third_party/dynamic_annotations" + "base/third_party/icu" + "base/third_party/libevent" + "base/third_party/nspr" + "base/third_party/superfasthash" + "base/third_party/symbolize" + "base/third_party/xdg_mime" + "base/third_party/xdg_user_dirs" + "net/third_party/http2" + "net/third_party/mozilla_security_manager" + "net/third_party/nss" + "net/third_party/spdy" + "net/third_party/quic" + "third_party/abseil-cpp" + "third_party/angle" + "third_party/angle/src/common/third_party/base" + "third_party/angle/src/common/third_party/smhasher" + "third_party/angle/src/third_party/compiler" + "third_party/blink" + "third_party/boringssl" + "third_party/boringssl/src/third_party/fiat" + "third_party/breakpad" + "third_party/brotli" + "third_party/ced" + "third_party/crc32c" + "third_party/ffmpeg" + "third_party/googletest" + "third_party/hunspell" + "third_party/iccjpeg" + "third_party/icu" + "third_party/inspector_protocol" + "third_party/jinja2" + "third_party/jstemplate" + "third_party/khronos" + "third_party/leveldatabase" + "third_party/libaddressinput" + "third_party/libjingle_xmpp" + "third_party/libpng" + "third_party/libsrtp" + "third_party/libsync" + "third_party/libudev" + "third_party/libvpx" + "third_party/libwebm" + "third_party/libwebp" + "third_party/libxml" + "third_party/libxslt" + "third_party/libyuv" + "third_party/lss" + "third_party/markupsafe" + "third_party/mesa" + "third_party/metrics_proto" + "third_party/modp_b64" + "third_party/opus" + "third_party/ots" + "third_party/ply" + "third_party/polymer" + "third_party/protobuf" + "third_party/pyjson5" + "third_party/re2" + "third_party/rnnoise" + "third_party/skia" + "third_party/skia/third_party/gif" + "third_party/skia/third_party/skcms" + "third_party/smhasher" + "third_party/snappy" + "third_party/sqlite" + "third_party/usrsctp" + "third_party/web-animations-js" + "third_party/webrtc" + "third_party/webrtc_overrides" + "third_party/widevine/cdm/widevine_cdm_common.h" + "third_party/widevine/cdm/widevine_cdm_version.h" + "third_party/woff2" + "third_party/yasm" + "third_party/zlib" + "url/third_party/mozilla" + "v8/src/third_party/utf8-decoder" + "v8/src/third_party/valgrind" + "v8/third_party/antlr4" + "v8/third_party/inspector_protocol")) + (protected (make-regexp "\\.(gn|gyp)i?$"))) + (define preserved-club + (map (lambda (member) + (string-append "./" member)) + preserved-third-party-files)) + (define (empty? dir) + (equal? (scandir dir) '("." ".."))) + (define (third-party? file) + (if (string-contains file "third_party/") + #t + #f)) + (define (useless? file) + (any (cute string-suffix? <> file) + '(".zip" ".so" ".dll" ".exe" ".jar"))) + (define (parents child) + ;; Return all parent directories of CHILD up to and including + ;; the closest "third_party". + (let* ((dirs (match (string-split child #\/) + ((dirs ... last) dirs))) + (closest (list-index (lambda (dir) + (string=? "third_party" dir)) + (reverse dirs))) + (delim (- (length dirs) closest))) + (fold (lambda (dir prev) + (cons (string-append (car prev) "/" dir) + prev)) + (list (string-join (list-head dirs delim) "/")) + (list-tail dirs delim)))) + (define (remove-loudly file) + (format #t "deleting ~a...~%" file) + (force-output) + (delete-file file)) + (define (delete-unwanted-files child stat flag base level) + (match flag + ((or 'regular 'symlink 'stale-symlink) + (when (third-party? child) + (unless (or (member child preserved-club) + (any (cute member <> preserved-club) + (parents child)) + (regexp-exec protected child)) + (remove-loudly child))) + (when (and (useless? child) (file-exists? child)) + (remove-loudly child)) + #t) + ('directory-processed + (when (empty? child) + (rmdir child)) + #t) + (_ #t))) + + (with-directory-excursion "src/3rdparty" + ;; TODO: Try removing "gn" too for future versions of qtwebengine. + (delete-file-recursively "ninja") + + (with-directory-excursion "chromium" + ;; Delete bundled software and binaries that were not explicitly + ;; preserved above. + (nftw "." delete-unwanted-files 'depth 'physical) + + ;; Assert that each preserved item is present to catch removals. + (for-each (lambda (third-party) + (unless (file-exists? third-party) + (error (format #f "~s does not exist!" third-party)))) + preserved-club) + + ;; Use relative header locations instead of hard coded ones. + (substitute* + "base/third_party/dynamic_annotations/dynamic_annotations.c" + (("base/third_party/valgrind") "valgrind")) + (substitute* + "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h" + (("third_party/curl") "curl")) + + ;; Replace Google Analytics bundle with an empty file and hope + ;; no one notices. + (mkdir-p "third_party/analytics") + (call-with-output-file + "third_party/analytics/google-analytics-bundle.js" + (lambda (port) + (const #t))))) + + ;; Do not build support for the Widevine DRM. + (substitute* "src/core/config/common.pri" + (("enable_widevine=true") + "enable_widevine=false")) + #t))))) (build-system gnu-build-system) (native-inputs `(("bison" ,bison) @@ -2059,6 +2237,7 @@ time Web content can be enhanced with native controls.") `(("alsa-lib" ,alsa-lib) ("atk" ,atk) ("cups-minimal" ,cups-minimal) + ("curl" ,curl) ("dbus" ,dbus) ("ffmpeg" ,ffmpeg) ("fontconfig" ,fontconfig) @@ -2102,6 +2281,7 @@ time Web content can be enhanced with native controls.") ("re2" ,re2) ("snappy" ,snappy) ("udev" ,eudev) + ("valgrind" ,valgrind) ("xcb-util" ,xcb-util))) (arguments (substitute-keyword-arguments (package-arguments qtsvg) -- 2.24.1