Bug 45316 - Ant RPM task is unable to build RPM package due to missing space character between option name and directory
Summary: Ant RPM task is unable to build RPM package due to missing space character be...
Status: RESOLVED DUPLICATE of bug 46659
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: unspecified
Hardware: All Linux
: P2 major with 3 votes (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-01 05:56 UTC by Volodymyr Lisivka
Modified: 2010-11-05 04:27 UTC (History)
2 users (show)



Attachments
Example build.xml and .spec file (655 bytes, application/x-tar)
2008-07-01 05:57 UTC, Volodymyr Lisivka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Volodymyr Lisivka 2008-07-01 05:56:17 UTC
rpmbuild cannot build rpm when called from ant. Ant called rpmbuid with
following parameters (example taken using strace):

"/usr/bin/rpmbuild" "--define"
"_topdir/home/vlisivka/svnwork/ops/trunk-clean/tools/prr-mysqld_multi/build"
"-bb" "--clean" "SPECS/prr-mysqld_multi.spec"

rpmbuild reports following error:

      [rpm] Building the RPM based on the prr-mysqld_multi.spec file
      [rpm] error: File
/home/vlisivka/svnwork/ops/trunk_clean/tools/prr_mysqld_multi/build/SOURCES/prr-mysqld_multi-3.2.tar.gz:
No such file or directory
BUILD FAILED

Note the strange "_" character inserted instead of "-" in ".../trunk-clean/...".

Version-Release number of selected component (if applicable):

ant-1.7.0-1jpp.4.fc9.i386

The problem is in parameter for --define option: _topdir and path must be separated by space to work correctly (but they must remain as single parameter). Example:
  "--define" "_topdir /home/vlisivka/svnwork/ops/trunk-clean/tools/prr-mysqld_multi/build"

Note the space between "_topdir" and rest of parameter.

When rpmbuild is called manually with corrected argument, it works fine.

How to test:

  * install Fedora 9;
  * create temporary directory with "-" in path, e.g. /tmp/foo-bar;
  * unarchive example project to that directory (see attachment);
  * try to build project using "ant" command.

Actual result:

-(/tmp/foo-bar:$)-> ant
Buildfile: build.xml

rpm:
      [rpm] Building the RPM based on the example.spec file
      [rpm] Processing files: example-1-1
      [rpm] Checking for unpackaged file(s): /usr/lib/rpm/check-files %{buildroot}
      [rpm] error: cannot create /tmp/foo_bar/build/RPMS/noarch: No such file or directory
      [rpm] error: Could not open /tmp/foo_bar/build/RPMS/noarch/example-1-1.noarch.rpm: No such file or directory
      [rpm] 
      [rpm] 
      [rpm] RPM build errors:
      [rpm]     cannot create /tmp/foo_bar/build/RPMS/noarch: No such file or directory
      [rpm]     Could not open /tmp/foo_bar/build/RPMS/noarch/example-1-1.noarch.rpm: No such file or directory

BUILD FAILED
/tmp/foo-bar/build.xml:24: '/usr/bin/rpmbuild' failed with exit code 1

Total time: 0 seconds


Expected result:

-(/tmp/foobar:$)-> ant
Buildfile: build.xml

rpm:
      [rpm] Building the RPM based on the example.spec file
      [rpm] Processing files: example-1-1
      [rpm] Checking for unpackaged file(s): /usr/lib/rpm/check-files %{buildroot}
      [rpm] Wrote: /tmp/foobar/build/RPMS/noarch/example-1-1.noarch.rpm
      [rpm] Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.33406
      [rpm] + umask 022
      [rpm] + cd /tmp/foobar/build/BUILD
      [rpm] + exit 0

BUILD SUCCESSFUL


Workaround:
This small shell wrapper script can be used as workaround:

#!/bin/bash
OPTIONS=( )
for I in "$@"
do
  [[ "$I" == _topdir* ]] && I="_topdir ${I#_topdir}"
  OPTIONS[${#OPTIONS[@]}]="$I"
done
rpmbuild.orig "${OPTIONS[@]}"


Just rename original rpmbuild tool to rpmbuild.orig and sotre the shell script as /usr/bin/rpmbuild (don't forget to chmod a+rwx /usr/bin/rpmbuild).


See also: https://bugzilla.redhat.com/show_bug.cgi?id=453121
Comment 1 Volodymyr Lisivka 2008-07-01 05:57:51 UTC
Created attachment 22201 [details]
Example build.xml and .spec file
Comment 2 Henri Gomez 2008-07-01 06:38:52 UTC
The RPM spec is not maintened for ages. And I recommand you to check jpackage initiative (www.jpackage.org), where ant and majors Java projects are actively maintened

Regards
Comment 3 Volodymyr Lisivka 2008-07-02 06:45:13 UTC
Please, commit this trivial patch:

diff -rub
apache-ant-1.7.0.orig/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java
apache-ant-1.7.0/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java
---
apache-ant-1.7.0.orig/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java 
    2006-12-13 14:16:22.000000000 +0200
+++ apache-ant-1.7.0/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java  
2008-07-02 16:10:42.000000000 +0300
@@ -120,7 +120,7 @@
                                 : rpmBuildCommand);
         if (topDir != null) {
             toExecute.createArgument().setValue("--define");
-            toExecute.createArgument().setValue("_topdir" + topDir);
+            toExecute.createArgument().setValue("_topdir " + topDir);
         }

         toExecute.createArgument().setLine(command);

-
Comment 4 Volodymyr Lisivka 2009-06-10 02:15:13 UTC
Can someone apply that one symbol patch or it will stay forever?
Comment 5 Joe Wilkicki 2009-06-17 14:41:00 UTC
(In reply to comment #2)
> The RPM spec is not maintened for ages. And I recommand you to check jpackage
> initiative (www.jpackage.org), where ant and majors Java projects are actively
> maintened
> 
> Regards

(In reply to comment #4)
> Can someone apply that one symbol patch or it will stay forever?

It looks like there is a misunderstanding here.  This bug is not about Ant's old spec file; the problem is that the Ant RPM task isn't calling rpmbuild properly for newer versions of RPM.

For the record, I encountered this bug on Red Hat Enterprise Linux 5.3 while setting topdir in my Ant build file.  It would really help if the suggest patch was applied.  For now, I'm working around it by making sure my topdir doesn't have any hyphens in it.
Comment 6 Volodymyr Lisivka 2009-11-09 03:09:10 UTC
Trivial one-character bug is still no applied because Henri Gomez just ignores it for more than 1 year. Is Henri Gomez still alive? Can he respond here?
Comment 7 Stefan Bodewig 2010-11-04 09:11:39 UTC
you are talking about the rpm task, not about RPM containing Ant that we once provided (or better, Henri Gomez once did).

Unfortunately I lack the karma to change the "assigned to" field, so either Volodymyr or Henri must change it to notifications@ant.a.o
Comment 8 Antoine Levy-Lambert 2010-11-05 04:27:46 UTC
this bug is a duplicate of 46659 which is fixed.

*** This bug has been marked as a duplicate of bug 46659 ***