Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 375983 - eutils.eclass: make epatch distinguish between "exit 1" and "exit 2" of the patch command
Summary: eutils.eclass: make epatch distinguish between "exit 1" and "exit 2" of the p...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-22 10:55 UTC by Toralf Förster
Modified: 2011-08-07 23:35 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
/var/tmp/portage/kde-base/systemsettings-4.6.5/temp/krandr.patch.out (krandr.patch.out,13.82 KB, text/plain)
2011-07-22 10:55 UTC, Toralf Förster
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Toralf Förster gentoo-dev 2011-07-22 10:55:29 UTC
From "man patch" :

       patch's exit status is 0 if all hunks are applied successfully, 1 if some hunks  cannot  be  applied,
       and  2 if there is more serious trouble.  When applying a set of patches in a loop it behooves you to
       check this exit status so you don't apply a later patch to a partially patched file.


It would be helpful to easier see the culprit in a mcuh smaller log file (example attached).


Reproducible: Always
Comment 1 Toralf Förster gentoo-dev 2011-07-22 10:55:49 UTC
Created attachment 280593 [details]
/var/tmp/portage/kde-base/systemsettings-4.6.5/temp/krandr.patch.out
Comment 2 SpanKY gentoo-dev 2011-07-22 18:20:04 UTC
so what exactly are you looking for here ?  you want epatch to log the exit status after every execution of `patch` ?

 ...
 Hunk #2 FAILED at 62.
 1 out of 2 hunks FAILED -- saving rejects to file kcontrol/randr/randrconfig.h.rej
+command exited with $?
 ========================
Comment 3 Toralf Förster gentoo-dev 2011-07-22 18:41:35 UTC
(In reply to comment #2)
> so what exactly are you looking for here ?  you want epatch to log the exit
> status after every execution of `patch` ?
Yes - b/c it doesn't make too much sense to probe for -p2, -p3, etc or?
Comment 4 SpanKY gentoo-dev 2011-07-22 19:03:34 UTC
that's something else.  including it in the log is trivial, but you're also asking for the loop behavior to change.

the man page indicates that the patch exit status is specific to GNU patch.  it also doesnt really say what "serious trouble" means.

i'm not sure that we can say that a patch which happens to match some files at say p0 should abort immediately when we actually want p1 and it matches everything.

the overhead of trying up to p5 is irrelevant as it only happens when earlier ones failed.  i dont think we should optimize for the "failure" paths.
Comment 5 Toralf Förster gentoo-dev 2011-07-22 19:42:21 UTC
Yep, you're right, seems that "serious" means much more than only a non-sense -p?, patch should behave more subtile ...
 

tfoerste@n22 ~/tmp $ patch -p0 -g0 -E --no-backup-if-mismatch < p.patch 
patching file foo
tfoerste@n22 ~/tmp $ echo $?
0
tfoerste@n22 ~/tmp $ echo foo > foo; echo foo > bar; echo bar >> bar; diff -u foo bar > p.patch; cp foo bar
tfoerste@n22 ~/tmp $ patch -p1 -g0 -E --no-backup-if-mismatch < p.patch 
missing header for unified diff at line 3 of patch
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- foo        2011-07-22 21:40:06.000000000 +0200
|+++ bar        2011-07-22 21:40:06.000000000 +0200
--------------------------
File to patch: 
Skip this patch? [y] y
Skipping patch.
1 out of 1 hunk ignored
tfoerste@n22 ~/tmp $ echo $?
1
Comment 6 SpanKY gentoo-dev 2011-08-07 23:35:45 UTC
the exact exit status is now logged for all runs

http://sources.gentoo.org/eclass/eutils.eclass?r1=1.359&r2=1.360