2

rpm-maven-plugin を使用して、maven プロジェクトを rpm ファイルにパッケージ化したいと考えています。maven install( mvn clean install) の後、rpm が に作成されtarget/rpm/rpm-build/RPMS/noarch/ます。アプリケーションを開始するにはどうすればよいですか? rpm をインストールしようとすると、 todo :yum localinstall {name}.rpmは何もないというヒントが 表示されます。ドイツ語のエラー テキスト

ルーチンを理解するために、インストール後にテキスト ファイルを作成しました。

私の目には、 tmp-buildroot/ が空であるため、生成されたスペック ファイルが奇妙に見えます。

%define __jar_repack 0
Name: rpm-build
Version: 0.5.0
Release: SNAPSHOT20160809082044
Summary: rpm-build
License: (c) 2016 Nobody
Vendor: Nobody
URL: http://www.Nobody.com
Group: Development
Packager: Nobody
autoprov: yes
autoreq: yes
BuildArch: noarch
BuildRoot: /mnt/hgfs/workspace/test/rpm-build/target/rpm/rpm-build/buildroot

%description
test example: RPM Package.

%install

if [ -d $RPM_BUILD_ROOT ];
then
  mv /mnt/hgfs/workspace/test/rpm-build/target/rpm/rpm-build/tmp-buildroot/* $RPM_BUILD_ROOT
else
  mv /mnt/hgfs/workspace/test/rpm-build/target/rpm/rpm-build/tmp-buildroot $RPM_BUILD_ROOT
fi

%files

 "/opt/app//lib/"
%config  "/opt/app//conf"
%dir  "/opt/app//logs"

%pre
echo "installing now"

%post
#!/usr/bin/env bash

touch file.txt

私のpomに欠けているパラメータはどれですか?

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>nobody</artifactId>
        <groupId>com.nobody.nobody</groupId>
        <version>0.5.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>rpm-build</artifactId>
    <inceptionYear>2016</inceptionYear>
    <organization>
        <name>nobody</name>
        <url>http://www.nobody.com</url>
    </organization>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <app.home>/opt/app/</app.home>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>rpm-maven-plugin</artifactId>
                <version>2.1.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>rpm</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <group>Development</group>
                    <description>example: RPM Package.</description>
                    <mappings>
                        <mapping>
                            <directory>${app.home}/lib/</directory>
                            <dependency/>
                            <artifact/>
                        </mapping>
                        <mapping>
                            <directory>${app.home}/conf</directory>
                            <configuration>true</configuration>
                            <sources>
                                <source>
                                    <location>${project.build.outputDirectory}/app.properties</location>
                                    <destination>app.sample.properties</destination>
                                </source>
                            </sources>
                        </mapping>
                        <mapping>
                            <directory>${app.home}/logs</directory>
                        </mapping>
                    </mappings>
                    <preinstallScriptlet>
                        <script>echo "installing now"</script>
                    </preinstallScriptlet>
                    <postinstallScriptlet>
                        <scriptFile>src/main/scripts/postinstall.sh</scriptFile>
                        <fileEncoding>utf-8</fileEncoding>
                    </postinstallScriptlet>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <descriptor>src/assembly/dep.xml</descriptor>
                </configuration>
                <executions>
                    <execution>
                        <id>create-archive</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

これは私のプロジェクト構造です:

プロジェクト構造

現在、アプリケーションにSystem.out.printlnメッセージを送信しています。私の目標は、Linux デーモンを作成することです。postinstall スクリプトでそれが可能になることを願っています。

誰かが私にヒントをくれることを願っています。ありがとう。

4

0 に答える 0