mojohaus / rpm-maven-plugin

http://www.mojohaus.org/rpm-maven-plugin/
Other
56 stars 48 forks source link

With keyname set, execution of rpmbuild fails #7

Closed sakarlsson closed 9 years ago

sakarlsson commented 9 years ago

With keyname set RPMHelper.java will call rpmbuild with some extra arguments for _gpg_name and optionally _gpg_path. However the argument passing seems wrong, causing rpmbuild to complain with:

...
[INFO] error: Macro % has illegal name (%define)
[INFO] error: Macro % has illegal name (%define)
[INFO] error: Macro % has illegal name (%define)
[INFO] error: Macro % has illegal name (%define)
...

This cured my issue:

index fb3bdf5..4f1992e 100644
--- a/src/main/java/org/codehaus/mojo/rpm/RPMHelper.java
+++ b/src/main/java/org/codehaus/mojo/rpm/RPMHelper.java
@@ -127,11 +127,11 @@ final class RPMHelper
         if ( keyname != null && keyPassphrase == null )
         {
             cl.createArg().setValue( "--define" );
-            cl.createArg().setValue( "\"_gpg_name " + keyname + "\"" );
+            cl.createArg().setValue( "_gpg_name " + keyname );
             if ( keypath != null )
             {
                 cl.createArg().setValue( "--define" );
-                cl.createArg().setValue( "\"_gpg_path " + keypath + "\"" );
+                cl.createArg().setValue( "_gpg_path " + keypath );
             }
             cl.createArg().setValue( "--sign" );
         }

(Which is also consistent with the handling of "--define _topdir ..")

rickard-von-essen commented 9 years ago

Thanks for the report and patch.

Can you share some info about:

The escaping seems to have been introduced in @88016585a271dc2ae29259156d97952a42d297da @dantran any memory of why this was added?

sakarlsson commented 9 years ago

Sorry for the missing info. We run on RedHat 6.6. rpm and rpm-build is version 4.8.0. Shell is bash 4.1.2. - invoked as /bin/sh by maven (according to an strace of the maven run)

dantran commented 9 years ago

@sakarlsson please folow instructsions under src/it/rpm-sign-with-keyname-lookup to see it sees your error? ( without yr fix)

sakarlsson commented 9 years ago

The rpm-sign-with-keyname-lookup test does not execute the problematic code because the passphrase is set. To repeat the problem:

cd target/it/rpm-sign-with-keyname-lookup
grep -v passphrase settings.xml > settings2.xml
mvn -s settings2.xml verify -DdisableSigning=false -Dgpg.homedir=../../test-classes/gnupg -Ptestkey
dantran commented 9 years ago

@sakarlsson so you have no passphase for your gpgkey? your fix passes all IT tests?

dantran commented 9 years ago

will commit your patch

dantran commented 9 years ago

patch applied at a632a5a. Thanks

dantran commented 9 years ago

@sakarlsson please test latest 2.1.4-SNAPSHOT

sakarlsson commented 9 years ago

Yes, it works like a charm. Many thanks!