Bug 1045723 - %autosetup -pN parsing doesn't terminate at EOL
%autosetup -pN parsing doesn't terminate at EOL
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
22
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: packaging-team-maint
Fedora Extras Quality Assurance
Panu Matilainen
: Upstream
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-21 09:08 EST by Ville Skyttä
Modified: 2015-03-27 10:50 EDT (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1310704 (view as bug list)
Environment:
Last Closed: 2015-03-27 10:50:31 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)
Reproducer srpm (2.01 KB, application/octet-stream)
2013-12-21 09:08 EST, Ville Skyttä
no flags Details

  None (edit)
Description Ville Skyttä 2013-12-21 09:08:37 EST
Created attachment 840028 [details]
Reproducer srpm

%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.
Comment 1 Panu Matilainen 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)
Comment 2 Ville Skyttä 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.
Comment 3 Panu Matilainen 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.
Comment 4 Panu Matilainen 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 :)
Comment 5 Panu Matilainen 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...
Comment 6 Mikolaj Izdebski 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
Comment 7 Panu Matilainen 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.
Comment 8 Hedayat Vatankhah 2014-06-12 09:23:50 EDT
I also faced this bug when trying to use %autosetup -S git. :P
Comment 9 Panu Matilainen 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.
Comment 10 Fedora End Of Life 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.
Comment 11 Jaroslav Reznik 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

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