unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Brendan Tildesley <mail@brendan.scot>
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 43367@debbugs.gnu.org
Subject: [bug#43367] [core-updates]: [PATCH 0/5]: Prevent wrap-progam from double-wrapping.
Date: Sun, 13 Sep 2020 22:30:50 +1000	[thread overview]
Message-ID: <6c55ad27-6661-c84f-53ec-0baaa9c9ce91@brendan.scot> (raw)
In-Reply-To: <20200913114019.58a6bda0@scratchpost.org>

[-- Attachment #1: Type: text/plain, Size: 3669 bytes --]

On 13/9/20 7:40 pm, Danny Milosavljevic wrote:
> On Sun, 13 Sep 2020 15:39:15 +1000
> Brendan Tildesley <mail@brendan.scot> wrote:
>
>> I'm attempting to fix a bug where wrap-program produces ..X-real-real
>> files by mistakenly wrapping already wrapped files. I haven't fully
>> tested these because it requires rebuilding everything which takes hours
>> to days and core-updates is stuck on mesa now anyway. Perhaps I'll try
>> testing on master. Also there may be other places where .X-real files
>> are accidentally wrapped, which will now error.
> But can't a thing be wrapped once for one reason and another time for another
> reason and that should be fine?

Yes, perhaps I should have explained that this is still possible and 
works fine. When a program is wrapped a second time, it will append to 
the existed wrapper, rather than creating a new file and moving the old 
one. repeated applications of wrap-program after the first one simply 
append. I'll illustrate how this can go wrong though: suppose we have 
/bin/foo and we we are in a repl and run:

(wrap-program "/bin/foo" `("BAR" = ("baz")) => /bin/.foo-real doesn't 
exist so /bin/foo is moved to /bin/.foo-real, a new /bin/foo is created 
that is a wrapper that then launches /bin.foo-real.

(wrap-program "/bin/foo" `("BAR" = ("baz")) => /bin/.foo-real exists so 
/bin/foo is assumed to already be a wrapper so variables are appended to 
/bin/foo.

(wrap-program "/bin/foo" `("BAR" = ("baz")) => same thing again, 
variables are appended

; Now suppose we then run:

(wrap-program "/bin/.foo-real" `("BAR" = ("baz")) => 
/bin/..foo-real-real doesn't exist, so /bin/.foo-real is moved to 
/bin/..foo-real-real and /bin/.foo-real is created again as another wrapper.

This should never be done intentionally I think, but sometimes there is 
code that uses (find-files dir ".") to find binaries to wrap, and this 
is run after a previous existing wrap phase, so the both /bin/foo and 
/bin/.foo-real are wrapped again. Generally everything will continue 
working though despite all this though.

You run this to find some of these double wrapped packages:

find /gnu/ -maxdepth 4 -iname '.*-real-real'

So I thought it best to error whenever this happens instead of allowing it.

An example of this causing an issue is when Prafulla Giri posted a 
patch[0] to fix a bug with Calibre. Their code ought to be correct, but 
it resulted in double wrapping. I created my own patch by overwriting 
the python-build-systems wrap phase and duplicating some code. Andreas 
ended up accepting my patch instead.

... Actually I just realised Prafulla's patch could have been fixed in a 
much simpler way by adjusting the (find-files ...) bit and avoided 
duplication. ...

Anyway, with these patches, Prafulla's patch would have caused an error 
and forced them to fix it, for example, by changing

(find-files "." ".")

to

(find-files "." (lambda (file stat) (not (wrapper? file))))
or
(find-files "." (lambda (file stat) (not (string-prefix "." (basename file))))

----------

So, the main change here is making (wrap-program ".foo-real") an error. 
If you cannot think of a good reason why that should ever be run, I 
think its good to block it. bugs that can slip through easily and lurk 
in the background usually not causing problems are not good in my 
opinion. After that has been decided we need to ensure all build systems 
don't misuse wrap-program that way. I notice some build systems actually 
only pass 'regular files, others allow symlinks or any file. I'm not 
really sure what the exact find-files filter should be.

[0] https://lists.gnu.org/archive/html/guix-patches/2020-09/msg00219.html


[-- Attachment #2: Type: text/html, Size: 4788 bytes --]

  reply	other threads:[~2020-09-13 12:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-13  5:39 [bug#43367] [core-updates]: [PATCH 0/5]: Prevent wrap-progam from double-wrapping Brendan Tildesley
2020-09-13  5:45 ` [bug#43367] [PATCH 1/5] utils: wrap-program: Refuse to wrap .X-real files Brendan Tildesley
2020-09-13  5:45   ` [bug#43367] [PATCH 2/5] utils: Rename wrapper? to wrapped-program? Brendan Tildesley
2020-09-13  5:45   ` [bug#43367] [PATCH 3/5] glib-or-gtk-build-system: Don't double wrap programs Brendan Tildesley
2020-09-13  5:45   ` [bug#43367] [PATCH 4/5] rakudo-build-system: " Brendan Tildesley
2020-09-13  5:45   ` [bug#43367] [PATCH 5/5] qt-build-system: " Brendan Tildesley
2020-09-13  9:40 ` [bug#43367] [core-updates]: [PATCH 0/5]: Prevent wrap-progam from double-wrapping Danny Milosavljevic
2020-09-13 12:30   ` Brendan Tildesley [this message]
2021-04-22  9:06 ` bug#43367: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6c55ad27-6661-c84f-53ec-0baaa9c9ce91@brendan.scot \
    --to=mail@brendan.scot \
    --cc=43367@debbugs.gnu.org \
    --cc=dannym@scratchpost.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).