简体   繁体   English

为自定义存储库创建 go 二进制文件作为 debian 二进制文件 package

[英]Creating a go binary as debian binary package for a custom repository

I am trying to package a binary written in Go as a debian/ubuntu binary package.我正在尝试 package 一个用Go编写的二进制文件作为 debian/ubuntu 二进制文件 package。 This would be available for download from a custom web server and apt key .这可以从自定义 web 服务器和apt key下载。

I am - very - confused.我很困扰。

I looked at https://wiki.debian.org/Packaging/Intro?action=show&redirect=IntroDebianPackaging first.我首先查看了https://wiki.debian.org/Packaging/Intro?action=show&redirect=IntroDebianPackaging This looks like exhaustive, without wanting to say too complex.这看起来很详尽,不想说太复杂。

What confuses me is that the file debian/rules contains a make command.令我困惑的是文件debian/rules包含一个make命令。 But we don't have a Makefile , do I need to create one?但是我们没有Makefile ,我需要创建一个吗?

In fact I am at the debuild -us -uc step, and it obviously failed.事实上,我在debuild -us -uc步骤,显然失败了。

Then I saw this: https://askubuntu.com/a/251892 , where it says:然后我看到了这个: https://askubuntu.com/a/251892 ,上面写着:

Avoid the Debian bureaucracy by just building the binary: dpkg-buildpackage -b只需构建二进制文件即可避免 Debian 官僚作风:dpkg-buildpackage -b

I did that, and the command completed, but looking at the generated package there it doesn't contain any binaries, only a changelog.gz and a copyright file in the app folder below /usr/share/doc .我这样做了,命令完成了,但是查看生成的 package 那里不包含任何二进制文件,只有一个changelog.gz/usr/share/doc下面的应用程序文件夹中的copyright文件。

So I am lost, I have no idea which tutorial to follow here to build a binary custom package, which, btw, later will be available for download signed.所以我迷路了,我不知道要在这里遵循哪个教程来构建二进制自定义 package,顺便说一句,稍后可以下载签名。 Obviously it is my first debian/ubuntu package I am creating.显然这是我正在创建的第一个 debian/ubuntu package。

I'm currently working on a project written in go that is distributed as a.deb package in a repository.我目前正在开发一个用 go 编写的项目,该项目在存储库中作为 a.deb package 分发。

I have to tell you that it is not easy to find documentation about it.我必须告诉你,找到有关它的文档并不容易。 I use fpm for that activity.我使用fpm进行该活动。

First create in a folder that represents your project on the destination computer.首先在目标计算机上代表您的项目的文件夹中创建。 For example "/tmp/proj"例如“/tmp/proj”

Inside that folder you must put everything you want to distribute in the package.在该文件夹中,您必须将要分发的所有内容放入 package 中。 For example, if your compiled binary is called "myapp" and you want to put it in "/usr/bin/", then you have to create the folder "/tmp/proj/usr/bin" and put in it the executable file with the permissions you will use.例如,如果您编译的二进制文件名为“myapp”并且您想将其放入“/usr/bin/”,那么您必须创建文件夹“/tmp/proj/usr/bin”并将可执行文件放入其中具有您将使用的权限的文件。

This way with all the files you want to distribute.这种方式与您要分发的所有文件。

Then create a script that you will use to generate the package:然后创建一个用于生成 package 的脚本:

PKG_NAME= application name, one word, lowercase
PKG_DESCRIPTION= Brief description of the package
PKG_VERSION= Version, in x.y.z format
PKG_RELEASE= Correlative number from 1 onwards
PKG_MAINTAINER= Your name and email. Format: "name" < email >
PKG_VENDOR= Your company name
PKG_URL= URL of your product

FPM_OPTS="-n $PKG_NAME -v $PKG_VERSION --iteration $PKG_RELEASE"

fpm -s dir -t deb ${FPM_OPTS} -f \
    -maintainer "$PKG_MAINTAINER" \
    --vendor "$PKG_VENDOR" \
    --url "$PKG_URL" \
    --description "$PKG_DESCRIPTION" \
    --architecture "amd64" \
    -C /tmp/proj \
    .

And that's it, Well.就是这样,嗯。 there's a lot to learn.有很多东西要学。

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

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