Debian的包装Go应用程序 [英] Packaging Go application for Debian
问题描述
如何将我的Go二进制文件放入Debian包中?由于Go是静态链接的,所以我只有一个可执行文件 - 我不需要很多复杂的项目元数据信息。有没有一个简单的方法来打包可执行文件和资源文件,而不会经历 debuild
的创伤?
How can I put my Go binary into a Debian package? Since Go is statically linked, I just have a single executable--I don't need a lot of complicated project metadata information. Is there a simple way to package the executable and resource files without going through the trauma of debuild
?
现在已经看到现在的问题了,然而,我的所有研究都提出了有关包含golang开发环境的.deb文件的问题/答案(即,如果您执行 sudo apt-get install golang-go
)。
I've looked all over for existing questions; however, all of my research turns up questions/answers about a .deb file containing the golang development environment (i.e., what you would get if you do sudo apt-get install golang-go
).
推荐答案
嗯。我认为 debuild
唯一的创伤是在构建软件包后运行 lintian
,它的 lintian
谁试图找到你的包裹的问题。
Well. I think the only "trauma" of debuild
is that it runs lintian
after building the package, and it's lintian
who tries to spot problems with your package.
所以有两种方法来对付情况:
So there are two ways to combat the situation:
- 不要使用
debuild
:此工具只调用dpkg-buildpackage
这真的做了必要的举重。建立二进制包的通常调用是
dpkg-buildpackage -us -uc -b
。您仍然可以调用debuild
作为其他用途,例如debuild clean
。 - 添加所谓的lintian override,可用于使
lintian
对您的包裹的选择的问题视而不见,您坚持认为不是问题。
- Do not use
debuild
: this tool merely callsdpkg-buildpackage
which really does the necessary powerlifting. The usual call to build a binary package isdpkg-buildpackage -us -uc -b
. You still might calldebuild
for other purposes, likedebuild clean
for instance. - Add the so-called "lintian override" which can be used to make
lintian
turn a blind eye to selected problems with your package which, you insist, are not problems.
这两种方法都意味着您不要通过打包工具尝试构建您的应用程序,而应将其视为刚被包装到包中的Blob。这将需要从正常方式 debian / rules
工作(不要尝试构建任何东西)稍微减弱。
Both approaches imply that you do not attempt to build your application by the packaging tools but rather treat it as a blob which is just wrapped to a package. This would require slightly abstraining from the normal way debian/rules
work (to not attempt to build anything).
另一种解决方案可能是(或者更真的是Debian-ish)可能是可以尝试使用 gcc-go
(加$ code> gold 用于链接):由于它是一个GCC前端,因此该工具生成一个动态链接的应用程序(其链接到 libgo
或某事喜欢这个)。我个人没有经验,只有考虑使用它,如果你打算尝试推送你的包裹到Debian适当的。
Another solution which might be possible (and is really way more Debian-ish) is to try to use gcc-go
(plus gold
for linking): since it's a GCC front-end, this tool produces a dynamically-linked application (which links against libgo
or something like this). I, personally, have no experience with it yet, and would only consider using it if you intend to try to push your package into the Debian proper.
关于一般问题的Debian包装Go程序,您可能会发现以下资源有用:
Regarding the general question of packaging Go programs for Debian, you might find the following resources useful:
- 这个线程由Go for Debian包装商之一开始执行。
- 特别是,第一个发布在该线程链接到关于debian-devel的此讨论。
- 关于相同问题的debian-devel的第二个线程这是前线程的逻辑延续)。
- This thread started on go-nuts by one of Go for Debian packagers.
- In particular, the first post in that thread links to this discussion on debian-devel.
- The second thread on debian-devel regarding that same problem (it's a logical continuation of the former thread).
更新在2015-10-15。
Update on 2015-10-15.
(由于这篇文章似乎仍然被搜索,发现和研究由人们决定更新它以更好地反映当前的状况。)
(Since this post appears to still be searched and found and studied by people I've decided to update it to better reflec the current state of affairs.)
从那时起,包装Go应用程序和软件包的情况有了显着的改善,这是可能的使用来自Google的经典Go(所谓的 gc
套件)构建Debian包,而不是 gcc-go
。
还有一个很好的基础设施包。
Since then the situation with packaging Go apps and packages got improved dramatically, and it's possible to build a Debian package using "classic" Go (the so-called gc
suite originating from Google) rather than gcc-go
.
And there exist a good infrastructure for packages as well.
现在关于Go程序的debianize使用的关键工具是 dh- golang
描述了此处。
The key tool to use when debianizing a Go program now is dh-golang
described here.
这篇关于Debian的包装Go应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!