gnu: ungoogled-chromium: Convert computed origin to source snippet.
* gnu/packages/chromium.scm (computed-origin-method, %chromium-origin): Remove. (ungoogled-chromium-source): Rename to ... (ungoogled-chromium-snippet): ... this. Adjust for running as snippet. (ungoogled-chromium)[source]: Use URL-FETCH, with custom snippet.
This commit is contained in:
		
							parent
							
								
									e4e9a1bc35
								
							
						
					
					
						commit
						7eb8ae5f6c
					
				
					 1 changed files with 66 additions and 117 deletions
				
			
		|  | @ -248,19 +248,6 @@ | ||||||
|     "v8/third_party/inspector_protocol" ;BSD-3 |     "v8/third_party/inspector_protocol" ;BSD-3 | ||||||
|     "v8/third_party/v8/builtins")) ;PSFL |     "v8/third_party/v8/builtins")) ;PSFL | ||||||
| 
 | 
 | ||||||
| (define* (computed-origin-method gexp-promise hash-algo hash |  | ||||||
|                                  #:optional (name "source") |  | ||||||
|                                  #:key (system (%current-system)) |  | ||||||
|                                  (guile (default-guile))) |  | ||||||
|   "Return a derivation that executes the G-expression that results |  | ||||||
| from forcing GEXP-PROMISE." |  | ||||||
|   (mlet %store-monad ((guile (package->derivation guile system))) |  | ||||||
|     (gexp->derivation (or name "computed-origin") |  | ||||||
|                       (force gexp-promise) |  | ||||||
|                       #:graft? #f       ;nothing to graft |  | ||||||
|                       #:system system |  | ||||||
|                       #:guile-for-build guile))) |  | ||||||
| 
 |  | ||||||
| (define %chromium-version "83.0.4103.116") | (define %chromium-version "83.0.4103.116") | ||||||
| (define %ungoogled-revision "f08ce8b3f1300ef0750b5d6bf967b9cbbfd9a56d") | (define %ungoogled-revision "f08ce8b3f1300ef0750b5d6bf967b9cbbfd9a56d") | ||||||
| (define %debian-revision "debian/81.0.4044.92-1") | (define %debian-revision "debian/81.0.4044.92-1") | ||||||
|  | @ -328,16 +315,6 @@ from forcing GEXP-PROMISE." | ||||||
|         (debian-patch "system/openjpeg.patch" %debian-revision |         (debian-patch "system/openjpeg.patch" %debian-revision | ||||||
|                       "0zd6v5njx1pc7i0y6mslxvpx5j4cq01mmyx55qcqx8qzkm0gm48j"))) |                       "0zd6v5njx1pc7i0y6mslxvpx5j4cq01mmyx55qcqx8qzkm0gm48j"))) | ||||||
| 
 | 
 | ||||||
| (define %chromium-origin |  | ||||||
|   (origin |  | ||||||
|     (method url-fetch) |  | ||||||
|     (uri (string-append "https://commondatastorage.googleapis.com" |  | ||||||
|                         "/chromium-browser-official/chromium-" |  | ||||||
|                         %chromium-version ".tar.xz")) |  | ||||||
|     (sha256 |  | ||||||
|      (base32 |  | ||||||
|       "1hravbi1lazmab2mih465alfzji1kzy38zya1visbwz9zs6pw35v")))) |  | ||||||
| 
 |  | ||||||
| (define %ungoogled-origin | (define %ungoogled-origin | ||||||
|   (origin |   (origin | ||||||
|     (method git-fetch) |     (method git-fetch) | ||||||
|  | @ -349,106 +326,69 @@ from forcing GEXP-PROMISE." | ||||||
|      (base32 |      (base32 | ||||||
|       "0kc40p8f7cls696gh6ign37l8j4x1pyyz32jkkli9cmrpbsjsadl")))) |       "0kc40p8f7cls696gh6ign37l8j4x1pyyz32jkkli9cmrpbsjsadl")))) | ||||||
| 
 | 
 | ||||||
| ;; This is a "computed" origin that does the following: | ;; This is a source 'snippet' that does the following: | ||||||
| ;; *) Runs the Ungoogled scripts on a pristine Chromium tarball. | ;; *) Applies various patches for unbundling purposes and libstdc++ compatibility. | ||||||
| ;; *) Applies Debians Chromium patches, for their unbundling and GCC work. | ;; *) Runs the ungoogled patch-, domain substitution-, and scrubbing scripts. | ||||||
| ;; *) Prunes all third_party directories that are not explicitly preserved. | ;; *) Prunes all third_party directories that are not explicitly preserved. | ||||||
| ;; *) Adjusts "GN" build files such that system libraries are preferred. | ;; *) Adjusts "GN" build files such that system libraries are preferred. | ||||||
| (define ungoogled-chromium-source | (define ungoogled-chromium-snippet | ||||||
|   (let ((chromium-source %chromium-origin) |   ;; Note: delay to cope with cyclic module imports at the top level. | ||||||
|         (ungoogled-source %ungoogled-origin)) |   (delay | ||||||
|     (origin |     #~(begin | ||||||
|       (method computed-origin-method) |         (let ((chromium-dir (getcwd))) | ||||||
|       (file-name (string-append "ungoogled-chromium-" %package-version ".tar.xz")) |           (set-path-environment-variable | ||||||
|       (sha256 #f) |            "PATH" '("bin") | ||||||
|       (uri |            (list #+patch #+python-wrapper #+xz)) | ||||||
|        (delay |  | ||||||
|          (with-imported-modules '((guix build utils)) |  | ||||||
|            #~(begin |  | ||||||
|                (use-modules (guix build utils) |  | ||||||
|                             (ice-9 rdelim) |  | ||||||
|                             (srfi srfi-1) |  | ||||||
|                             (srfi srfi-26)) |  | ||||||
|                (let ((chromium-dir    (string-append "chromium-" #$%chromium-version)) |  | ||||||
|                      (preserved-files '#$%preserved-third-party-files)) |  | ||||||
| 
 | 
 | ||||||
|                  (set-path-environment-variable |           (format #t "Removing non-free file...~%") | ||||||
|                   "PATH" '("bin") |           (force-output) | ||||||
|                   (list #+(canonical-package patch) |           ;; This file has a CC-BY-NC clause according to LICENSES from | ||||||
|                         #+(canonical-package xz) |           ;; the same directory, making it non-free. | ||||||
|                         #+(canonical-package tar) |           (delete-file | ||||||
|                         #+python-wrapper)) |            "third_party/blink/perf_tests/svg/resources/HarveyRayner.svg") | ||||||
| 
 | 
 | ||||||
|                  (copy-recursively #+ungoogled-source "/tmp/ungoogled") |           ;; Apply patches before running the ungoogled scripts because | ||||||
|  |           ;; domain substitution may break some of the patches. | ||||||
|  |           (format #t "Applying assorted build fixes...~%") | ||||||
|  |           (force-output) | ||||||
|  |           (for-each (lambda (patch) | ||||||
|  |                       (invoke "patch" "-p1" "--force" "--input" | ||||||
|  |                               patch "--no-backup-if-mismatch")) | ||||||
|  |                     (append | ||||||
|  |                      '#+%gentoo-patches '#+%debian-patches | ||||||
|  |                      '#+(list (local-file | ||||||
|  |                                (search-patch | ||||||
|  |                                 "ungoogled-chromium-system-jsoncpp.patch")) | ||||||
|  |                               (local-file | ||||||
|  |                                (search-patch | ||||||
|  |                                 "ungoogled-chromium-system-zlib.patch"))))) | ||||||
| 
 | 
 | ||||||
|                  (with-directory-excursion "/tmp/ungoogled" |           (with-directory-excursion #+%ungoogled-origin | ||||||
|  |             (format #t "Ungooglifying...~%") | ||||||
|  |             (force-output) | ||||||
|  |             (invoke "python" "utils/prune_binaries.py" chromium-dir | ||||||
|  |                     "pruning.list") | ||||||
|  |             (invoke "python" "utils/patches.py" "apply" | ||||||
|  |                     chromium-dir "patches") | ||||||
|  |             (invoke "python" "utils/domain_substitution.py" "apply" "-r" | ||||||
|  |                     "domain_regex.list" "-f" "domain_substitution.list" | ||||||
|  |                     "-c" "/tmp/domainscache.tar.gz" chromium-dir)) | ||||||
| 
 | 
 | ||||||
|                    (format #t "Unpacking chromium tarball...~%") |           (format #t "Pruning third party files...~%") | ||||||
|                    (force-output) |           (force-output) | ||||||
|                    (invoke "tar" "xf" #+chromium-source) |           (apply invoke (string-append #+python-2 "/bin/python") | ||||||
|  |                  "build/linux/unbundle/remove_bundled_libraries.py" | ||||||
|  |                  "--do-remove" '#$%preserved-third-party-files) | ||||||
| 
 | 
 | ||||||
|                    (with-directory-excursion chromium-dir |           (format #t "Replacing GN files...~%") | ||||||
|                      (format #t "Removing non-free file...~%") |           (force-output) | ||||||
|                      (force-output) |           (invoke "python" "build/linux/unbundle/replace_gn_files.py" | ||||||
|                      ;; This file has a CC-BY-NC clause according to LICENSES from |                   "--system-libraries" "ffmpeg" "flac" "fontconfig" | ||||||
|                      ;; the same directory, making it non-free. |                   "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent" | ||||||
|                      (delete-file |                   "libjpeg" "libpng" "libvpx" "libwebp" "libxml" | ||||||
|                       "third_party/blink/perf_tests/svg/resources/HarveyRayner.svg") |                   "libxslt" "openh264" "opus" "re2" "snappy" "yasm" | ||||||
| 
 |                   "zlib") | ||||||
|                      ;; Apply patches before running the ungoogled scripts because |           #t)))) | ||||||
|                      ;; domain substitution may break some of the patches. |  | ||||||
|                      (format #t "Applying assorted build fixes...~%") |  | ||||||
|                      (force-output) |  | ||||||
|                      (for-each |  | ||||||
|                       (lambda (patch) |  | ||||||
|                         (invoke "patch" "-p1" "--force" "--input" |  | ||||||
|                                 patch "--no-backup-if-mismatch")) |  | ||||||
|                       (append |  | ||||||
|                        '#+%gentoo-patches '#+%debian-patches |  | ||||||
|                        '#+(list (local-file |  | ||||||
|                                  (search-patch |  | ||||||
|                                   "ungoogled-chromium-system-jsoncpp.patch")) |  | ||||||
|                                 (local-file |  | ||||||
|                                  (search-patch |  | ||||||
|                                   "ungoogled-chromium-system-zlib.patch")))))) |  | ||||||
| 
 |  | ||||||
|                    (format #t "Ungooglifying...~%") |  | ||||||
|                    (force-output) |  | ||||||
|                    (invoke "python" "utils/prune_binaries.py" chromium-dir |  | ||||||
|                            "pruning.list") |  | ||||||
|                    (invoke "python" "utils/patches.py" "apply" |  | ||||||
|                            chromium-dir "patches") |  | ||||||
|                    (invoke "python" "utils/domain_substitution.py" "apply" "-r" |  | ||||||
|                            "domain_regex.list" "-f" "domain_substitution.list" |  | ||||||
|                            "-c" "/tmp/domainscache.tar.gz" chromium-dir) |  | ||||||
| 
 |  | ||||||
|                    (with-directory-excursion chromium-dir |  | ||||||
|                      (format #t "Pruning third party files...~%") |  | ||||||
|                      (force-output) |  | ||||||
|                      (apply invoke (string-append #+python-2 "/bin/python") |  | ||||||
|                             "build/linux/unbundle/remove_bundled_libraries.py" |  | ||||||
|                             "--do-remove" preserved-files) |  | ||||||
| 
 |  | ||||||
|                      (format #t "Replacing GN files...~%") |  | ||||||
|                      (force-output) |  | ||||||
|                      (invoke "python" "build/linux/unbundle/replace_gn_files.py" |  | ||||||
|                              "--system-libraries" "ffmpeg" "flac" "fontconfig" |  | ||||||
|                              "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent" |  | ||||||
|                              "libjpeg" "libpng" "libvpx" "libwebp" "libxml" |  | ||||||
|                              "libxslt" "openh264" "opus" "re2" "snappy" "yasm" |  | ||||||
|                              "zlib")) |  | ||||||
| 
 |  | ||||||
|                    (format #t "Packing new ungoogled tarball ...~%") |  | ||||||
|                    (force-output) |  | ||||||
|                    (invoke "tar" "cvfa" #$output |  | ||||||
|                            ;; Avoid non-determinism in the archive. |  | ||||||
|                            "--mtime=@0" |  | ||||||
|                            "--owner=root:0" |  | ||||||
|                            "--group=root:0" |  | ||||||
|                            "--sort=name" |  | ||||||
|                            chromium-dir) |  | ||||||
| 
 |  | ||||||
|                    #t))))))))) |  | ||||||
| 
 | 
 | ||||||
| (define opus+custom | (define opus+custom | ||||||
|   (package/inherit opus |   (package/inherit opus | ||||||
|  | @ -467,7 +407,16 @@ from forcing GEXP-PROMISE." | ||||||
|     (name "ungoogled-chromium") |     (name "ungoogled-chromium") | ||||||
|     (version %package-version) |     (version %package-version) | ||||||
|     (synopsis "Graphical web browser") |     (synopsis "Graphical web browser") | ||||||
|     (source ungoogled-chromium-source) |     (source (origin | ||||||
|  |               (method url-fetch) | ||||||
|  |               (uri (string-append "https://commondatastorage.googleapis.com" | ||||||
|  |                                   "/chromium-browser-official/chromium-" | ||||||
|  |                                   %chromium-version ".tar.xz")) | ||||||
|  |               (sha256 | ||||||
|  |                (base32 | ||||||
|  |                 "1hravbi1lazmab2mih465alfzji1kzy38zya1visbwz9zs6pw35v")) | ||||||
|  |               (modules '((guix build utils))) | ||||||
|  |               (snippet (force ungoogled-chromium-snippet)))) | ||||||
|     (build-system gnu-build-system) |     (build-system gnu-build-system) | ||||||
|     (arguments |     (arguments | ||||||
|      `(#:tests? #f |      `(#:tests? #f | ||||||
|  |  | ||||||
		Reference in a new issue