3
5
Fork 0
mirror of git://git.savannah.gnu.org/guix.git synced 2023-12-14 03:33:07 +01:00
guix/gnu/packages/patches/racket-backport-8.7-pkg-strip.patch
Philip McGrath fca5e1a507
gnu: racket: Update to 8.7.
Also, update 'chez-scheme-for-racket' to 9.5.9.8.

Note that racket-backport-8.6-cross-install.patch,
racket-backport-8.6-docindex-write.patch, and
racket-backport-8.6-hurd.patch were missing from dist_patch_DATA.

* gnu/packages/patches/racket-backport-8.6-cross-install.patch,
gnu/packages/patches/racket-backport-8.6-docindex-write.patch,
gnu/packages/patches/racket-backport-8.6-hurd.patch,
gnu/packages/patches/racket-backport-8.6-zuo.patch: Remove patches.
* gnu/packages/patches/racket-backport-8.7-pkg-strip.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Update accordingly.
* gnu/packages/racket.scm (%racket-origin)[patches]: Likewise.
(%racket-version): Update to 8.7.
(racket)[inputs]: Add 'scheme-doc' source package from '%racket-origin'.
(racket)[inputs]<compatibility, db, deinprogramm, draw, drracket>
<eopl, errortrace, gui, htdp, mzscheme, parser-tools, pict, plai, plot>
<r6rs, redex, scribble, slideshow, snip, typed-racket, srfi>
<string-constants>: Update checksums.
* gnu/packages/chez.scm (chez-scheme-for-racket): Update to 9.5.9.8.
[arguments]: Enable tests.
[description]: Update.
(chez-scheme-for-racket-bootstrap-bootfiles)[arguments]: Update path to
'rktboot'.

Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
2022-11-20 02:22:18 +01:00

90 lines
3.1 KiB
Diff

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