简体   繁体   English

如何为 Linux 打包游戏?

[英]How to package a game for Linux?

I have a game that currently runs under Windows and Mac OS X and I'd like to make it available under Linux.我有一个目前在 Windows 和 Mac OS X 下运行的游戏,我想让它在 Linux 下可用。 The porting should be fairly easy since it's a Java based game and uses portable libraries that are available on all 3 platforms.移植应该相当容易,因为它是一个基于 Java 的游戏,并使用在所有 3 个平台上都可用的可移植库。

The hard part and the reason for this question is packaging it so that it works on as many modern Linux distributions as possible.这个问题的难点和原因是将它打包,以便它可以在尽可能多的现代 Linux 发行版上运行。 The primary target will be Ubuntu 9.主要目标将是 Ubuntu 9。

Webstart is not an acceptable way, .tar.gz is the last resort. Webstart 不是一种可接受的方式,.tar.gz 是最后的手段。 I would stronly prefer a package that has correctly defined dependencies (such as Java) and installs easily.我更喜欢具有正确定义的依赖项(例如 Java)并且易于安装的包。

I also need to be able to build the package under a Windows environment since some tools in my build chain are Windows-only.我还需要能够在 Windows 环境下构建包,因为我的构建链中的某些工具仅适用于 Windows。

Start by looking at how a similar project has achieved this.首先看看一个类似的项目是如何实现这一目标的。 One that springs to mind is Freecol , a cross-platform Java-based game.我首先想到的是Freecol ,这是一款基于 Java 的跨平台游戏。 Their download page has fairly clear information on installing it on a number of platforms.他们的下载页面有关于在许多平台上安装它的相当清晰的信息。 They also have packages available at sites such as GetDEB for Ubuntu and PackMan for OpenSuse.他们还在诸如GetDEB for Ubuntu 和PackMan for OpenSuse 等站点上提供了软件包。

Generally, if you want to hit as many distributions as possible, the formats you should consider are (in rough order of importance):通常,如果您想达到尽可能多的分布,您应该考虑的格式是(按重要性的粗略顺序):

  1. Ubuntu .deb (also create a repository if you can) Ubuntu .deb(如果可以,也创建一个存储库)
  2. OpenSUSE .rpm or .ypm (1 click install) OpenSUSE .rpm 或 .ypm(一键安装)
  3. Fedora .rpm Fedora .rpm
  4. .tar.gz pre-compiled package .tar.gz 预编译包

Then a build from source option, or a best-effort binary installer.然后从源选项构建,或尽力而为的二进制安装程序。 Finally, look at other popular distros such as Debian, Mandriva, and BSDs最后,看看其他流行的发行版,例如 Debian、Mandriva 和 BSD

Once a package exists for a specific platform, you may wish to consider getting it accepted into that distribution.一旦某个特定平台的软件包存在,您可能希望考虑将其纳入该发行版。 This will make it easier for users to find and acquire.这将使用户更容易找到和获取。 Information on the process for ubuntu can be found here:可以在此处找到有关 ubuntu 过程的信息:

(EDIT: Better list, thanks to Jonik's suggestion.) (编辑:更好的列表,感谢 Jonik 的建议。)

Have a look at Zero Install ( http://0install.net/ ).看看零安装( http://0install.net/ )。

  • Anyone can install software任何人都可以安装软件

You don't have to be the administrator just to install a word-processor [ more ]您不必成为管理员即可安装文字处理器 [ 更多 ]

  • Anyone can distribute software任何人都可以分发软件

You don't need to be blessed by a distribution (or anyone else) to be part of Zero Install;你不需要受到发行版(或其他任何人)的祝福才能成为零安装的一部分; The system is completely decentralised [ more ]系统完全去中心化 [ 更多 ]

  • Automatic updates自动更新

When updates are available, Zero Install will notify you[ more ]当有更新可用时,零安装会通知您[更多]

  • Security安全

If one user downloads a malicious program, other users aren't affected;如果一个用户下载了恶意程序,其他用户不受影响; Users can share downloads without having to trust each other;用户无需相互信任即可共享下载; Installation does not execute any of the downloaded code;安装不会执行任何下载的代码; Digital signatures are always checked before new software is r在新软件发布之前总是检查数字签名

You can use the deb system for Ubuntu.您可以将 deb 系统用于 Ubuntu。 It'll help you to mark correctly dependencies.它将帮助您正确标记依赖项。

A guide for packaging is available here .此处提供了包装指南。

Good question - I don't know the answer (and I guess there isn't an easy, all-encompassing solution), but here are some points to consider, from a Linux user's point of view.好问题 - 我不知道答案(我想没有一个简单的、包罗万象的解决方案),但从 Linux 用户的角度来看,这里有一些需要考虑的要点。

I think .tar.gz (or .tar.bz2) is not necessarily that bad.我认为 .tar.gz(或 .tar.bz2)不一定那么糟糕。 Linux users are used to it, and eg many commercial software packages are distributed that way. Linux 用户已经习惯了,例如,许多商业软件包都是以这种方式分发的。 It often beats a graphical Windows-style installer if the main point is to just extract files at some location.如果主要目的只是在某个位置提取文件,它通常会胜过图形 Windows 风格的安装程序。

Some (perhaps many?) users have JRE installed outside the package management system, so offering only RPM or deb (which depends on having JRE installed as RPM or deb) may be problematic.一些(也许很多?)用户在包管理系统之外安装了 JRE,所以只提供 RPM 或 deb(这取决于将 JRE 安装为 RPM 或 deb)可能有问题。 (Personally I prefer to have several JRE versions (JDK actually) installed under /usr/local/java .) So at least consider offering a zip/gz/bz2 package along with other options. (我个人更喜欢在/usr/local/java下安装几个 JRE 版本(实际上是 JDK)。)所以至少考虑提供一个 zip/gz/bz2 包以及其他选项。

Also, to learn about creating RPM packages of Java software, take a look at JPackage .此外,要了解如何创建 Java 软件的 RPM 包,请查看JPackage

Each distro may have it's own conventions of where common files go.每个发行版可能都有自己的公共文件去向约定。
In Ubuntu, common java jars go into /usr/share/java.在 Ubuntu 中,常见的 java jar 进入 /usr/share/java。 Things like commons-cli and liblog4j exists.存在诸如 commons-cli 和 liblog4j 之类的东西。 If you use any of these, make sure your deb depends on the appropriate package.如果您使用其中任何一个,请确保您的 deb 依赖于适当的包。 If the library is of use outisde your application, but not in the Ubuntu repos, consider putting it in its own deb and depending on that.如果该库在您的应用程序之外使用,但不在 Ubuntu 存储库中,请考虑将其放在自己的 deb 中并视情况而定。 You will need to create a folder for your specific games jars in /usr/share/[name]/ and then create a shell script to launch the game.您需要在 /usr/share/[name]/ 中为您的特定游戏 jar 创建一个文件夹,然后创建一个 shell 脚本来启动游戏。 This script should be placed in /usr/bin (or /usr/games) and be executable.这个脚本应该放在/usr/bin(或/usr/games)中并且是可执行的。

Don't forget to depend on an appropriate java package either (I suggest the sun-java#-jre packages 'cause gjc is crap and open-jdk isn't 100% there yet (At least the METAL LaF is fubar, I don't know about anything else yet.)也不要忘记依赖合适的 java 包(我建议使用 sun-java#-jre 包,因为 gjc 是垃圾,而 open-jdk 还不是 100%(至少 METAL LaF 是 fubar,我不其他的还不知道。)

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

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