打包 Linux 软件,同时保持合理的文件结构

发布于 2024-10-08 18:26:07 字数 898 浏览 4 评论 0原文

所以我创建了一个软件,我想打包并发布到 Arch Linux 用户存储库,AUR, - 应该注意,我以前从未为任何发行版打包过任何东西 - 而且我也将它打包并安装在我自己的机器上通过 Arch 的包管理器 Pacman 成功,但现在我想知道我到底该如何构建文件夹和文件?

通常当我编写软件时,我使用这种结构:

build/ |源代码/ | makefile

至少,对于这个软件来说,makefile 只不过是从 src/ 到 build/ 编译一个 .cpp 文件。 为了制作 Arch 包,我还必须创建一个 .rc 文件,以正确使用该程序作为守护程序和 PKGBUILD 文件,该文件告诉 makepkg 程序如何构建安装程序包 - 这两个文件,不过,是特定于 Arch 的。 如果我想为 debian 打包程序,我也需要另一组文件来完成此操作,但这些文件仅适用于 debian。现在,我不能只是将 .rc 文件和 PKGBUILD 文件放入程序根文件夹中,因为这会“一团糟”,特别是如果我还有为 debian 构建包的文件,但我该把特定于发行版的文件?我至少需要将它放在程序根文件夹中才能跟踪它,我最初的想法是使用像 distro/arch/ 这样的结构来存储 Arch Linux 特定文件,然后是 PKGBUILD 文件只需运行程序根文件夹中的 makefile 并将编译后的文件从 build/ 复制到 distro/arch/ ,然后再执行其他操作,但我发现我无法让 PKGBUILD 以这种方式工作,并且 Freenode 上的 #archlinux 上的人们也这样做说这不是一个聪明的主意。

那么我应该把发行版特定的文件放在哪里呢?如果我知道我只需要为 Arch 提供这个程序,那么只为 Makepkg 构建它会很容易,但我不喜欢像那样禁锢软件,而且我也可以想象为 debian 等其他主要发行版提供软件包,所以如何在保持合理的文件结构的同时实现这一目标?

问候, 克里斯·布赫霍尔兹

So I have created a piece of software which I wanna package and post to Arch Linux User Repositories, AUR, -should note, that I have never packaged anything for any distro before - and I have also got it packaged and installed on my own machine via Arch's package manager Pacman successfully, but now I am wondering how on earth am I gonna structure the folders and files?

Normally when I wrote software, I use this structure:

build/ | src/ | makefile

As a minimum, and in the case of this piece of software, the makefile does nothing more than compile a .cpp file from src/ to build/.
To make the Arch package, I also had to create a .rc file, to use the program properly as a daemon and the PKGBUILD file, which is the file that tells the makepkg program how to build the installer-package - these two files, though, are specific to Arch.
If I wanna package the program for say debian, I would need another set of files to do this too, but these files only work for debian. Now, I can't just put the .rc file and the PKGBUILD file in to the programs root folder, since that would "be a mess" especially if I also had files to build a package for debian, but where do I put the distro-specific files? I need to have it in the programs root folder -at-least- to be able to keep track of it, and my initial thought was to go with a structure like distro/arch/ for Arch Linux specific files, and then the PKGBUILD file would just run the makefile in the programs root folder and copy the compiled file from build/ to distro/arch/ before it did anything else, but I discovered that I couldnt get PKGBUILD to work that way, and people on #archlinux on Freenode also said it was not a smart idea.

So where do I put the distro specific files? If I knew I only had to provide this program for Arch, it would be easy to just structure it only for Makepkg, but I dont like to imprison the softwarelike that, and I could also imagine providing packages for other mayor distros like debian, so how do I achieve this while keeping a sane file structure?

Regards,
Chris Buchholz

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

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

发布评论

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

评论(1

末が日狂欢 2024-10-15 18:26:07

您经常会在 tarball 中找到一个名为“debian”的目录,其中包含 debian 特定文件。我会走同样的路线并创建一个目录“archlinux”并将文件放在那里。

然后我会继续在 archlinux 目录中放置一个 README 文件,解释如何正确使用 PKGBUILD。

一种解决方案可能是在 Makefile“package-arch”中写入一条规则,将 PKGBUILD 复制到根目录中,运行 makepkg,然后删除多余的 PKGBUILD。

这很 hackish,所以我还会为 Arch 人员写一份错误报告来修复这个限制。但是,您尝试过 makepkg -p archlinux/PKGBUILD 吗?

Very often you find in tarballs a directory called 'debian' which has the debian specific files in it. I would go the same route and create a directory 'archlinux' and put the files there.

Then I would go on and put a file README in the archlinux directory that explains how to use the PKGBUILD properly.

One solution could be to write a rule into your Makefile 'package-arch' that copies the PKGBUILD into the root directory, runs makepkg, then deletes the redundant PKGBUILD.

It's hackish, so I would also write a bug report for the Arch people to fix this limitation. However, did you try makepkg -p archlinux/PKGBUILD?

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