简体   繁体   English

如何使用 Redline RPM Java 库创建 RPM 包?

[英]How to create a RPM package with Redline RPM Java library?

I would like to create a RPM package for my Java game (currently packaged as JARs + JNLP file).我想为我的 Java 游戏创建一个 RPM 包(目前打包为 JAR + JNLP 文件)。 I use Ant as a build tool.我使用 Ant 作为构建工具。 I cannot use platform-dependent tools as the few developers who use my source code use several operating systems, not necessarily GNU Linux unlike me.我不能使用依赖于平台的工具,因为使用我的源代码的少数开发人员使用多个操作系统,不一定与我不同的 GNU Linux。

At first, I tried to use JDIC but its source code hasn't been maintained for years and I had to modify tons of things just to make it compile anew.起初,我尝试使用JDIC,但它的源代码已经多年没有维护了,我不得不修改大量的东西才能让它重新编译。 Moreover, it just calls the native RPM tools under the hood.此外,它只是在后台调用本机 RPM 工具。 Then, I found RPM Ant task but it uses the native RPM tools under the hood too.然后,我发现了RPM Ant 任务,但它也使用了本机 RPM 工具。 After that, I found RPM Maven plugin but I don't want to switch to another build tool now just to create a RPM package.之后,我找到了RPM Maven 插件,但我现在不想切换到另一个构建工具来创建 RPM 包。

Finally, I found Redline RPM pure Java library which has an Ant task, there is an example here .最后,我发现其中有一个Ant任务红线RPM纯Java库,有一个例子在这里 I still don't understand how to use it.我仍然不明白如何使用它。 I understand the role of a few basic fields (group, version, release, name), I know that I have to use "depends" to indicate that my game requires at least Java 1.7 but I don't know what to do with my JARs, where to put the .desktop file for the desktop shortcut and where to put the bash script that calls the main class to run my game.我了解几个基本字段(组、版本、发布、名称)的作用,我知道我必须使用“depends”来表示我的游戏至少需要 Java 1.7 但我不知道如何处理我的JAR,在哪里放置桌面快捷方式的 .desktop 文件,以及在哪里放置调用主类来运行我的游戏的 bash 脚本。 As a first step, I'd like to create a binary package.作为第一步,我想创建一个二进制包。 I have found another example using this library here .在这里找到了另一个使用这个库的例子。 Do I have to provide an uninstall script too?我是否也必须提供卸载脚本? Should I use a postinstall script to copy the .desktop file into the desktop directory?我应该使用安装后脚本将 .desktop 文件复制到桌面目录中吗? Should I use a tarfileset for the third party libraries?我应该为第三方库使用 tarfileset 吗? I know it would be better to put the JARs into several RPMs but I want to succeed in doing something simple before doing more elaborated but cleaner things.我知道将 JAR 放入多个 RPM 会更好,但我想在做更复杂但更清晰的事情之前先做一些简单的事情。

I wrote a simple tutorial on how to use redline here我在这里写了一个关于如何使用 redline 的简单教程

Basically everything you have to do build an empty rpm is that :基本上,您需要做的就是构建一个空的 rpm:

org.redline_rpm.Builder builder = new Builder();

File directory = new File(".");
builder.setType(RpmType.BINARY);
builder.setPlatform(Architecture.X86_64, Os.LINUX);
builder.setPackage("name", "1", "1");
builder.setDescription("Description");
builder.setSummary("Summary");

builder.build(directory);

You can add dependency on certain commands : example您可以添加对某些命令的依赖:示例

builder.addDependencyMore("tar", "0");
builder.addDependencyMore("python", "0");
builder.addDependencyMore("wget", "0");

Then you can add some pre-install script or post-install script and files too.然后您也可以添加一些安装前脚本或安装后脚本和文件。

builder.setPostInstallScript(xxx);

File tarball = new File("/the/dir/of/your/file/file.tar.gz");
builder.addFile("/where/to/put/it/file.tar.gz", tarball);

Redline maven dependency红线 maven 依赖

<dependency>
    <groupId>org.redline-rpm</groupId>
    <artifactId>redline</artifactId>
    <version>1.2.1</version>
</dependency>

I solved my problem here .在这里解决了我的问题。 I just have to add a short script to run the application.我只需要添加一个简短的脚本来运行应用程序。

PS: By the way, I now use my own tool (which uses Redline RPM under the hood), it's fully documented, free software (under GPL) and works for DEB, APP and EXE (via NSIS) too, it's called Java Native Deployment Toolkit . PS:顺便说一句,我现在使用我自己的工具(它在引擎盖下使用 Redline RPM),它是完全文档化的免费软件(在 GPL 下)并且也适用于 DEB、APP 和 EXE(通过 NSIS),它被称为Java Native部署工具包

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM