Bug 1310704 - %autosetup -pN parsing doesn't terminate at EOL
%autosetup -pN parsing doesn't terminate at EOL
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: rpm (Show other bugs)
6.7
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: packaging-team-maint
BaseOS QE Security Team
:
Depends On:
Blocks: 1355985 1373252
  Show dependency treegraph
 
Reported: 2016-02-22 09:45 EST by Karel Srot
Modified: 2017-10-10 10:01 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1045723
Environment:
Last Closed: 2017-10-10 10:01:55 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Karel Srot 2016-02-22 09:45:13 EST
This is present in RHEL-6 too.
In RHEL-7 it has been fixes as bug 1225118

+++ This bug was initially created as a clone of Bug #1045723 +++

%autosetup -pN parsing doesn't terminate at EOL but continues to read the next line. For example this and foo.patch:

    %autosetup -p1
    echo hello

...results in this rpmbuild error:

    + /usr/bin/cat [...]/foo.patch
    + /usr/bin/patch -p1 -secho hello
    /usr/bin/patch: invalid option -- 'h'

Reproducer srpm attached.

--- Additional comment from Panu Matilainen on 2013-12-27 06:51:34 EST ---

Right, this looks like an off-by-one'ish thing with parametrized macros. The effect is reproducable with just this:

--
%define foo(x) echo "FOO"

%foo -x
echo hello
--

If %foo is "called" with -x, "hello" ends up on the same line, otherwise it goes on a line of its own. I'll have a closer look when back at work next week, but the behavior seems to be ages old (present in rpm 4.4.x too)

--- Additional comment from Ville Skyttä on 2013-12-27 12:13:35 EST ---

IIRC I've always ended parametrized macro definitions with %{nil}, don't remember exactly why but I suppose it could have been in order to avoid this very issue.

--- Additional comment from Panu Matilainen on 2014-01-02 08:41:13 EST ---

Yeah, %{nil} at end avoids the issue, and given all the quirks in macro processing people just tend to use whatever gets the job done, whether the whatever makes sense or not.

For added fun, merely adding a trailing space is enough to trigger this "behavior" too, ie '%foo ' will also cause the newline to be silently eaten away. I've a preliminary fix for it, the remaining question is whether there are people actually relying on that longstanding quirk.

--- Additional comment from Panu Matilainen on 2014-02-19 07:31:35 EST ---

Fixed upstream now: http://rpm.org/gitweb?p=rpm.git;a=commitdiff;h=1bdcd0500865efd3566efd7f951228f69b58e755

I guess I'd better stick that into rawhide rpm and see what blows up :)

--- Additional comment from Panu Matilainen on 2014-03-26 07:11:53 EDT ---

FYI, this just went into rawhide as of rpm-4.11.2-3, lets see what (if anything) happens...

--- Additional comment from Mikolaj Izdebski on 2014-03-27 03:57:04 EDT ---

(In reply to Panu Matilainen from comment #5)
> FYI, this just went into rawhide as of rpm-4.11.2-3, lets see what (if
> anything) happens...

This change breaks many macros used by Java packages

Macro definition (see also [1]):

%pom_xpath_inject()   %{expand: %{__pom_call}xpath_inject   %*
}

Macro call (see also [2]):

# use java 5 generics in modello plugin
%pom_xpath_inject "pom:plugin[pom:artifactId[text()='modello-maven-plugin']]"\
"/pom:executions/pom:execution/pom:configuration" \
"<useJava5>true</useJava5>" doxia-modules/doxia-module-fml/pom.xml

macro expansion diff between rpm 4.11.2-2 and 4.11.2-3:

--- old	2014-03-27 08:49:54.262248366 +0100
+++ new	2014-03-27 08:40:54.969246312 +0100
@@ -1,4 +1,5 @@
 # use java 5 generics in modello plugin
  python /usr/share/java-utils/pom_editor.py pom_xpath_inject   "pom:plugin[pom:artifactId[text()='modello-maven-plugin']]"\
+
 "/pom:executions/pom:execution/pom:configuration" \
 "<useJava5>true</useJava5>" doxia-modules/doxia-module-fml/pom.xml

There's new line added which breaks the code.

[1] https://github.com/mizdebsk/javapackages/blob/master/macros.d/macros.fjava#L197-L198
[2] http://pkgs.fedoraproject.org/cgit/maven-doxia.git/tree/maven-doxia.spec#n272

--- Additional comment from Panu Matilainen on 2014-03-27 05:48:17 EDT ---

So, that'd be ... a macro argument with a literal line-continuation in it, or something like that. Eep.

I've reverted the change while I scratch my with this.

--- Additional comment from Hedayat Vatankhah on 2014-06-12 09:23:50 EDT ---

I also faced this bug when trying to use %autosetup -S git. :P

--- Additional comment from Panu Matilainen on 2014-08-19 05:29:55 EDT ---

FWIW this should be now fixed in F21 + rawhide, in a way that doesn't break the Java macros.

--- Additional comment from Fedora End Of Life on 2015-01-09 17:23:05 EST ---

This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

--- Additional comment from Jaroslav Reznik on 2015-03-03 11:57:43 EST ---

This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22
Comment 1 Karel Srot 2016-02-22 09:52:24 EST
As no one was complaining about this bug before and making the fix now would put some builds in risk of breakage I am postponing it for 6.9 for now.
Comment 2 Orion Poplawski 2016-11-16 15:56:38 EST
%autosetup -p appears to be completely broken in EL6 - patches are not applied and I get:

$ fedpkg local
Could not execute local: Could not get n-v-r-e from '\n\n/bin/cat /home/orion/fedora/python3-pycurl/python3-pycurl-py3.patch | \n/usr/bin/patch -p1 -s\npython3-pycurl (none) 7.43.0 5.el6'
Comment 3 Florian Festi 2017-10-10 10:01:51 EDT
Proposing for closing.
Comment 4 Red Hat Bugzilla Rules Engine 2017-10-10 10:01:55 EDT
Development Management has reviewed and declined this request. You may appeal this decision by reopening this request.

Note You need to log in before you can comment on or make changes to this bug.