summary refs log tree commit diff
path: root/gnu/packages/patches/racket-backport-8.7-pkg-strip.patch
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2023-01-30 11:33:18 +0200
committerEfraim Flashner <efraim@flashner.co.il>2023-01-30 12:39:40 +0200
commit4cf1acc7f3033b50b0bf19e02c9f522d522d338c (patch)
tree9fd64956ee60304c15387eb394cd649e49f01467 /gnu/packages/patches/racket-backport-8.7-pkg-strip.patch
parentedb8c09addd186d9538d43b12af74d6c7aeea082 (diff)
parent595b53b74e3ef57a1c0c96108ba86d38a170a241 (diff)
downloadguix-4cf1acc7f3033b50b0bf19e02c9f522d522d338c.tar.gz
Merge remote-tracking branch 'origin/master' into core-updates
 Conflicts:
	doc/guix.texi
	gnu/local.mk
	gnu/packages/admin.scm
	gnu/packages/base.scm
	gnu/packages/chromium.scm
	gnu/packages/compression.scm
	gnu/packages/databases.scm
	gnu/packages/diffoscope.scm
	gnu/packages/freedesktop.scm
	gnu/packages/gnome.scm
	gnu/packages/gnupg.scm
	gnu/packages/guile.scm
	gnu/packages/inkscape.scm
	gnu/packages/llvm.scm
	gnu/packages/openldap.scm
	gnu/packages/pciutils.scm
	gnu/packages/ruby.scm
	gnu/packages/samba.scm
	gnu/packages/sqlite.scm
	gnu/packages/statistics.scm
	gnu/packages/syndication.scm
	gnu/packages/tex.scm
	gnu/packages/tls.scm
	gnu/packages/version-control.scm
	gnu/packages/xml.scm
	guix/build-system/copy.scm
	guix/scripts/home.scm
Diffstat (limited to 'gnu/packages/patches/racket-backport-8.7-pkg-strip.patch')
-rw-r--r--gnu/packages/patches/racket-backport-8.7-pkg-strip.patch90
1 files changed, 90 insertions, 0 deletions
diff --git a/gnu/packages/patches/racket-backport-8.7-pkg-strip.patch b/gnu/packages/patches/racket-backport-8.7-pkg-strip.patch
new file mode 100644
index 0000000000..703b6e8e82
--- /dev/null
+++ b/gnu/packages/patches/racket-backport-8.7-pkg-strip.patch
@@ -0,0 +1,90 @@
+From 1b7e15c23baf1fda44b1d0752902ddea11419fc5 Mon Sep 17 00:00:00 2001
+From: Philip McGrath <philip@philipmcgrath.com>
+Date: Fri, 7 Oct 2022 02:15:13 -0400
+Subject: [PATCH] pkg/strip: handle read-only input
+
+A package directory supplied to the functions from `pkg/strip` might
+have had all of its write permission bits unset. Since `copy-file`
+preserves the permissions of the source file, we may end up with a
+read-only file that we want to overwrite (e.g. an `info.rkt` file).
+Explicitly setting `user-write-bit` before writing avoids this problem.
+Conservatively, we only set the permissions when actually needed,
+and we restore the original permissions when we are done.
+
+(cherry picked from commit 8c647c8cc9b66112198fcf9bea27fc0e3737162f)
+---
+ racket/collects/pkg/strip.rkt | 35 +++++++++++++++++++++++++++++------
+ 1 file changed, 29 insertions(+), 6 deletions(-)
+
+diff --git a/racket/collects/pkg/strip.rkt b/racket/collects/pkg/strip.rkt
+index 0ff58cea02..5899dbc6e6 100644
+--- a/racket/collects/pkg/strip.rkt
++++ b/racket/collects/pkg/strip.rkt
+@@ -306,9 +306,8 @@
+            #t
+            new-mod*-subs))))
+   (unless (eq? mod new-mod)
+-    (call-with-output-file*
++    (call-with-output-file/writable
+      new-p
+-     #:exists 'truncate/replace
+      (lambda (out) (write new-mod out)))))
+ 
+ (define (fixup-local-redirect-reference p js-path #:user [user-js-path js-path])
+@@ -340,9 +339,8 @@
+                                       (string->bytes/utf-8 user-js-path)
+                                       (subbytes s (+ delta end2)))]
+                        [else s]))))
+-    (call-with-output-file*
++    (call-with-output-file/writable
+      p
+-     #:exists 'truncate/replace
+      (lambda (out) (write-bytes new-bstr out)))))
+ 
+ ;; Used in binary[-lib] mode:
+@@ -383,9 +381,8 @@
+          (convert-mod info-lib defns)]))
+     (unless (equal? new-content content)
+       ;; write updated:
+-      (call-with-output-file* 
++      (call-with-output-file/writable
+        new-p
+-       #:exists 'truncate
+        (lambda (out)
+          (write new-content out)
+          (newline out)))
+@@ -503,3 +500,29 @@
+                     which
+                     dir)
+             (current-continuation-marks)))))
++
++(define (call-with-output-file/writable pth proc)
++  ;; In case `pth` was copied from a file without the user-write-bit set,
++  ;; explicitly make it writable while we overwrite it.
++  (define (run)
++    (call-with-output-file* pth
++      #:exists 'truncate/replace
++      proc))
++  (cond
++    [(file-exists? pth)
++     (define old-mode
++       (file-or-directory-permissions pth 'bits))
++     (define new-mode
++       (if (eq? (system-type) 'windows)
++           (bitwise-ior old-mode user-write-bit group-write-bit other-write-bit)
++           (bitwise-ior old-mode user-write-bit)))
++     (if (= old-mode new-mode)
++         (run)
++         (dynamic-wind
++          (λ ()
++            (file-or-directory-permissions pth new-mode))
++          run
++          (λ ()
++            (file-or-directory-permissions pth old-mode))))]
++    [else
++     (run)]))
+
+base-commit: 7e4f6e2362d4a08affbbae3c7ee4b98e325274c6
+-- 
+2.38.0
+