1

したがって、Ant のrpmタスクを使用して RPM としてパッケージ化しようとしている基本的な Java プログラムがあります。これをCygwinで実行しています。私の問題は、ant ビルド スクリプトを実行すると、必要な rpmbuild コマンドの代わりに rpm コマンドを使用しようとしているように見えることです。私が読んだことから、ant rpm タスクは rpmbuild を使用する必要がありますが、見つからない場合は rpm を使用します。コマンド ラインを使用して手動で RPM を作成できるので、どちらも適切にインストールされていることがわかっています。私はこの種のことは初めてなので、これを機能させるためにビルド スクリプトまたはスペック ファイルを変更する必要があるかどうかはわかりません。または、これが Cygwin の依存関係の問題である場合は?

Cygwin での rpm および rpmbuild インストールの証明:

$ 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" />

そして、これが私の仕様ファイルです。非常に単純です。

Summary:    An RPM Spec example
Name:       Application-Example
Version:    1.0
Release:    1
Group:  Applications/Sample
URL:        http://www.mycompany.com
Packager:   Name <name@name.com>
BuildArch:  noarch

%description
This is a sample SPEC file for the RPM project
demonstrating how to build, package, install(deploy)

%files

最後に、ant ビルドの出力を次に示します (rpm 部分のみ)。

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
4

1 に答える 1