所以我有一個基本的Java程序,我試圖用Ant的rpm任務打包爲RPM。我通過Cygwin運行它。我的問題是當我運行ant build腳本時,它似乎試圖使用rpm命令而不是所需的rpmbuild命令。從我讀過的內容來看,ant rpm任務應該使用rpmbuild,除非找不到,在這種情況下,它將使用rpm。我知道一個事實都安裝正確,因爲我可以使用命令行手動創建RPM就好了。我不確定是否需要在構建腳本或spec文件中更改某些內容才能使其發揮作用,因爲我對這類事情很陌生。或者如果這是Cygwin依賴性問題?在Cygwin上使用Ant創建RPM
證明轉和的rpmbuild的安裝Cygwin中:
$ which rpm
/usr/bin/rpm
和
$ which rpmbuild
/usr/bin/rpmbuild
這裏是我的build.xml文件:
<project name="SimpleJavaApp" default="all">
<property name="src" value="${basedir}/src" />
<property name="output" value="${basedir}/output" />
<property name="classes" value="${output}/classes" />
<property name="jars" value="${output}/jars" />
<property name="build.dir" value="${basedir}/build"/>
<target name="clean">
<delete dir="${output}" />
</target>
<target name="compile">
<mkdir dir="${classes}" />
<javac srcdir="${src}" destdir="${classes}" />
</target>
<target name="jar">
<mkdir dir="${jars}" />
<jar basedir="${classes}" destfile="${jars}/app.jar">
<manifest>
<attribute name="Main-Class" value="Main"/>
</manifest>
</jar>
</target>
<!-- Create directories -->
<mkdir dir="${build.dir}/BUILD"/>
<mkdir dir="${build.dir}/SOURCES"/>
<mkdir dir="${build.dir}/RPMS/noarch"/>
<mkdir dir="${build.dir}/SPECS"/>
<!-- copy spec files -->
<copy todir="${build.dir}/SPECS" preservelastmodified="true" failonerror="true">
<fileset dir="${basedir}" includes="*.spec"/>
</copy>
<target name="rpm" description="Compile single binary rpm by spec file">
<rpm
specFile="project.spec"
topDir="build"
cleanBuildDir="false"
removeSpec="false"
removeSource="false"
command = "ba"
failOnError="false"
/>
</target>
<target name="all" depends="clean, compile, jar, rpm" />
這裏是我的spec文件,prett Ÿ簡單:
Summary: An RPM Spec example
Name: Application-Example
Version: 1.0
Release: 1
Group: Applications/Sample
URL: http://www.mycompany.com
Packager: Name <[email protected]>
BuildArch: noarch
%description
This is a sample SPEC file for the RPM project
demonstrating how to build, package, install(deploy)
%files
最後,這裏是Ant構建的輸出(只轉一部分):
rpm:
[rpm] Building the RPM based on the project.spec file
[rpm] RPM version 4.1
[rpm] Copyright (C) 1998-2002 - Red Hat, Inc.
[rpm] This program may be freely redistributed under the terms of the GNU GPL
[rpm]
[rpm] Usage: rpm [-a|--all] [-f|--file] [-g|--group] [-p|--package] [--specfile]
[rpm] [--whatrequires] [--whatprovides] [-c|--configfiles] [-d|--docfiles]
[rpm] [--dump] [-l|--list] [--queryformat=QUERYFORMAT] [-s|--state]
[rpm] [--nomd5] [--nofiles] [--nodeps] [--noscript] [--addsign]
[rpm] [-K|--checksig] [--import] [--resign] [--nodigest] [--nosignature]
[rpm] [--initdb] [--rebuilddb] [--allfiles] [--allmatches] [--badreloc]
[rpm] [-e|--erase <package>+] [--excludedocs] [--excludepath=<path>]
[rpm] [--force] [-F|--freshen <packagefile>+] [-h|--hash] [--ignorearch]
[rpm] [--ignoreos] [--ignoresize] [-i|--install] [--justdb] [--nodeps]
[rpm] [--nomd5] [--noorder] [--nosuggest] [--noscripts] [--notriggers]
[rpm] [--oldpackage] [--percent] [--prefix=<dir>] [--relocate=<old>=<new>]
[rpm] [--repackage] [--replacefiles] [--replacepkgs] [--test]
[rpm] [-U|--upgrade <packagefile>+] [-D|--define 'MACRO EXPR']
[rpm] [-E|--eval 'EXPR'] [--macros=<FILE:...>] [--nodigest] [--nosignature]
[rpm] [--rcfile=<FILE:...>] [-r|--root ROOT] [--querytags] [--showrc]
[rpm] [--quiet] [-v|--verbose] [--version] [-?|--help] [--usage]
[rpm] [--scripts] [--setperms] [--setugids] [--conflicts] [--obsoletes]
[rpm] [--provides] [--requires] [--info] [--changelog] [--triggers]
[rpm] [--last] [--filesbypkg] [--redhatprovides] [--redhatrequires]
[rpm] [--buildpolicy=<policy>] [--with=<option>] [--without=<option>]
all:
BUILD SUCCESSFUL
Total time: 1 second