为 Linux 应用程序创建安装程序

发布于 2024-08-24 10:46:42 字数 1539 浏览 5 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

-柠檬树下少年和吉他 2024-08-31 10:46:42

*nix 系统(且不仅如此)上的标准通用安装程序是 Autotools

# the user will install like so:
./configure --with-stuff
make # if package is from source
make install

您还可以提供特定于发行版的安装程序,例如 RedHat 或 CentOS 上的 RPMdeb 适用于 Debian、Ubuntu,不过一旦你有了 Autotools 生成的 Makefile,制作这些文件就轻而易举了。

# the user will install like so:
yum install your-package-1.0.rpm # on redhat or
apt-get install your-package-1.0.deb # on debian

Autotools也被称为“GNU构建系统”,乍一看有点吓人,而新用户在遇到诸如古老的m4宏系统和M4宏系统之类的东西时会感到困惑。公司但nota bene这是大多数人的做法,一旦掌握了窍门,就会很容易。

学习资源

The standard all mighty universally available installer on *nix systems (and not only) is Autotools.

# the user will install like so:
./configure --with-stuff
make # if package is from source
make install

You can also provide distribution specific installers like a RPM on RedHat or CentOS or deb for Debian, Ubuntu, although once you have the Makefile spitted by Autotools, making these is a breeze.

# the user will install like so:
yum install your-package-1.0.rpm # on redhat or
apt-get install your-package-1.0.deb # on debian

Autotools also known as "the GNU build system" is a little scary on the first sight, and the new user is puzzled when meeting things like the ancient m4 macro system & co. but nota bene this is the way most people do it and is pretty easy once you get the hang of it.

Learning resources

尐偏执 2024-08-31 10:46:42

如果可能,选择不需要安装程序,而是使用简单的提取并运行方法。这将允许用户将文件放在他们想要的任何地方并运行它。

但是,您确实还有其他选择,例如:

  1. 使用 autoconf
  2. 使用 CMake
  3. 使用 Java 安装程序,如 IZPack

If possible, opt for not requiring an installer but using a simple extract-and-run approach. This will allow the user to put the file(s) anywhere they want and run it.

But, you do have other options, such as:

  1. Using autoconf,
  2. Using CMake,
  3. Using a Java installer like IZPack
  4. etc
萌吟 2024-08-31 10:46:42

查看InstallJammer。您可以为 Windows 和 Linux 安装程序编写一个项目,Mac 支持很快就会推出。

Take a look at InstallJammer. You can write a single project for both your Windows and your Linux installer, and the Mac support is coming very soon.

前事休说 2024-08-31 10:46:42

编写一个非常强大的 makefile!或使用 CMake

Write a really robust makefile! or use CMake

携君以终年 2024-08-31 10:46:42

我开始编写 unistall 来应对必须在各种发行版上安装二进制包的情况。

它尝试做一些事情:

  • 实现操作系统类型和包管理器,允许您使用系统包管理器来提取程序可能需要的任何依赖项。例如,如果使用debian/ubuntu,它会知道使用apt-get install libncurses5-dev,如果使用RHEL/Fedora/CentOS,它会知道使用yum install libncurses-devel
  • 了解什么机制如果需要,用于更新 init
  • 创建一个安全的卸载程序
  • 在任何 shell 上工作(bash、dash、zsh、pdksh、busybox ash 等)

我将存储库保留下来,因为它充满了有用的位,但是我很快放弃了为 Linux 发行版安装安装屏蔽类型程序的想法。您会发现为 .deb 、 .rpm 和(可能)slackware .tgz 格式生成可安装包要好得多。

可以使用 checkinstall 等工具将其集成到您的构建系统中。请注意,根据 Debian 和其他人制定的严格的 lint 指南,checkinstall 生成的软件包并不总是完美的,但是这些软件包工作得很好。

您可以为用户提供的最佳安装体验是允许他们使用其本机包管理器安装(和更新)您的软件。

I started writing unistall for situations when you had to install binary packages on a variety of distros.

It attempts to do a few things:

  • Realize the OS type and package manager, allowing you to use the system package manager to pull in any dependencies that your program might require. For instance, it will know to use apt-get install libncurses5-dev if using debian/ubuntu, yum install libncurses-devel if using RHEL/Fedora/CentOS
  • Understand what mechanism is used to update init, if needed
  • Create a safe un-installer
  • Work on any shell (bash, dash, zsh, pdksh, busybox ash, etc)

I leave the repo up because its full of useful bits, however I quickly gave up on the idea of an install sheild type program for Linux distributions. You'll find that its much, much better to produce installable packages for .deb , .rpm and (possibly) slackware .tgz formats.

This can be integrated into your build system using a tool like checkinstall. Note, the packages that checkinstall generates are not always perfect, according to strict lint guidelines set out by Debian and others, however the packages work just fine.

The best installation experience you can provide a user is allowing them to install (and update) your software using their native package manager.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文