Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Users List »

Problem with exec task

Marc Gimpel

2008-01-14


Author LoginPost Reply
 Hi,

 I'm trying to use ant to install some RPM pre-requisits
(PostgreSQL) on a RHEL 5 server. When I run the following command line,
everything works fine

[root@(protected)
http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-libs-8.2.6-1PGDG.rhel5.i686.rpm
http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-server-8.2.6-1PGDG.rhel5.i686.rpm
Retrieving http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-8.2.6-1PGDG.rhel5.i686.rpm
Retrieving http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-libs-8.2.6-1PGDG.rhel5.i686.rpm
Retrieving http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-server-8.2.6-1PGDG.rhel5.i686.rpm
warning: /var/tmp/rpm-xfer.y8kdPG: Header V3 DSA signature: NOKEY, key ID 20579f                                                   11
Preparing...           ########################################### [100%]
  1:postgresql-libs     ########################################### [ 33%]
  2:postgresql         ########################################### [ 67%]
  3:postgresql-server    ########################################### [100%]

But when I try to run this in an Ant exec task:

<project>
 <target name="rpm">
  <exec executable="rpm">
    <arg value="-ivh"/>
    <arg value="http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-8.2.6-1PGDG.rhel5.i686.rpm"/>
    <arg value="http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-libs-8.2.6-1PGDG.rhel5.i686.rpm"/>
    <arg value="http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-server-8.2.6-1PGDG.rhel5.i686.rpm"/>
  </exec>
 </target>
</project>

I get the following error:

[root@(protected)
Apache Ant version 1.7.0 compiled on December 13 2006
Buildfile: build.xml
Detected Java version: 1.6 in: /usr/java/jdk1.6.0_03/jre
Detected OS: Linux
parsing buildfile /root/build.xml with URI = file:/root/build.xml
Project base dir set to: /root
Build sequence for target(s) `rpm' is [rpm]
Complete build sequence is [rpm, ]

rpm:
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
   [exec] Current OS is Linux
   [exec] Executing 'rpm' with arguments:
   [exec] '-ivh'
   [exec] 'http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-8.2.6-1PGDG.rhel5.i686.rpm'
   [exec] 'http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-libs-8.2.6-1PGDG.rhel5.i686.rpm'
   [exec] 'http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-server-8.2.6-1PGDG.rhel5.i686.rpm'
   [exec]
   [exec] The ' characters around the executable and arguments are
   [exec] not part of the command.
   [exec] Retrieving http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-8.2.6-1PGDG.rhel5.i686.rpm
   [exec] Retrieving http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-libs-8.2.6-1PGDG.rhel5.i686.rpm
   [exec] Retrieving http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-server-8.2.6-1PGDG.rhel5.i686.rpm
   [exec] Preparing...           ##################################################
   [exec] postgresql-libs         ##################################################
   [exec] postgresql            ##################################################
   [exec] warning: /var/tmp/rpm-xfer.LQkrB5: Header V3 DSA signature: NOKEY, key ID 20579f11
   [exec] error: %post(postgresql-libs-8.2.6-1PGDG.rhel5.i686) scriptlet failed, exit status 255
   [exec] error: %pre(postgresql-server-8.2.6-1PGDG.rhel5.i686) scriptlet failed, exit status 255
   [exec] error:  install: %pre scriptlet failed (2), skipping postgresql-server-8.2.6-1PGDG.rhel5
   [exec] Result: 3

BUILD SUCCESSFUL
Total time: 36 seconds

The end result is that only 2 of the 3 RPMs are installed:
postgresql and postgresql-libs are installed (although the post install
script for postgresql-libs probably wasn't executed)
but postgresql-server isn't installed (the pre-install script appears to
fail but only when it is run inside of ant).

I have tried wrapping it in:
bash -c 'rpm -ivh ...'

<project>
 <target name="rpm2">
  <exec executable="bash">
    <arg value="-c"/>
    <arg value="rpm -ivh http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-8.2.6-1PGDG.rhel5.i686.rpm
http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-libs-8.2.6-1PGDG.rhel5.i686.rpm
http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-server-8.2.6-1PGDG.rhel5.i686.rpm"/>
  </exec>
 </target>
</project>

but that doesn't seem to work any better:

[root@(protected)
Apache Ant version 1.7.0 compiled on December 13 2006
Buildfile: build.xml
Detected Java version: 1.6 in: /usr/java/jdk1.6.0_03/jre
Detected OS: Linux
parsing buildfile /root/build.xml with URI = file:/root/build.xml
Project base dir set to: /root
Build sequence for target(s) `rpm2' is [rpm2]
Complete build sequence is [rpm2, rpm, ]

rpm2:
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
   [exec] Current OS is Linux
   [exec] Executing 'bash' with arguments:
   [exec] '-c'
   [exec] 'rpm -ivh http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-8.2.6-1PGDG.rhel5.i686.rpm
http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-libs-8.2.6-1PGDG.rhel5.i686.rpm
http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-server-8.2.6-1PGDG.rhel5.i686.rpm'
   [exec]
   [exec] The ' characters around the executable and arguments are
   [exec] not part of the command.
   [exec] Retrieving http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-8.2.6-1PGDG.rhel5.i686.rpm
   [exec] Retrieving http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-libs-8.2.6-1PGDG.rhel5.i686.rpm
   [exec] Retrieving http://ftp7.us.postgresql.org/pub/postgresql//binary/v8.2.6/linux/rpms/redhat/rhel-5/postgresql-server-8.2.6-1PGDG.rhel5.i686.rpm
   [exec] Preparing...           ##################################################
   [exec] postgresql-libs         ##################################################
   [exec] warning: /var/tmp/rpm-xfer.ogeKCY: Header V3 DSA signature: NOKEY, key ID 20579f11
   [exec] error: %post(postgresql-libs-8.2.6-1PGDG.rhel5.i686) scriptlet failed, exit status 255
   [exec] postgresql            ##################################################
   [exec] error: %pre(postgresql-server-8.2.6-1PGDG.rhel5.i686) scriptlet failed, exit status 255
   [exec] error:  install: %pre scriptlet failed (2), skipping postgresql-server-8.2.6-1PGDG.rhel5
   [exec] Result: 3

BUILD SUCCESSFUL
Total time: 31 seconds

Does anyone know the reason for this problem, and is there are workaround?

--
--------------------------------------------------------------------------
Marc Gimpel
Director of Research

WIMBA - PEOPLE TEACH PEOPLE
Espace Beethoven, bat 2B, 1200 Route des Lucioles
06560 Sophia Antipolis, France
Tel + 33 (0)4 93 00 45 85
Fax + 33 (0)4 93 00 45 81
Mob + 33 (0)6 74 88 02 72
mgimpel@(protected)

www.wimba.com
--------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.