1

I am trying to package a binary written in Go as a debian/ubuntu binary package. This would be available for download from a custom web server and apt key.

I am - very - confused.

I looked at https://wiki.debian.org/Packaging/Intro?action=show&redirect=IntroDebianPackaging first. This looks like exhaustive, without wanting to say too complex.

What confuses me is that the file debian/rules contains a make command. But we don't have a Makefile, do I need to create one?

In fact I am at the debuild -us -uc step, and it obviously failed.

Then I saw this: https://askubuntu.com/a/251892 , where it says:

Avoid the Debian bureaucracy by just building the binary: 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.

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. Obviously it is my first debian/ubuntu package I am creating.

5
  • This debian.org/doc/manuals/maint-guide/first.en.html#simplemake seems to suggest that indeed there should be a Makefile Commented Apr 29, 2020 at 17:17
  • That's for source distributions. Binary distributions do not need a makefile. Commented Apr 29, 2020 at 17:47
  • 1
    See wiki.debian.org/Packaging/… Commented Apr 29, 2020 at 17:48
  • Thanks, I had found that one, but that is only saying what a binary package is - not how to create one. There is this: tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO, but it says: "The intended use of such a newly created archive is to install it only on your own box, not to get them into the official Debian distribution. " I don't want to get them into the official Debian distro, nor I want it to install just on my own box. I want people to reliably download and install it from our own repo.... Commented Apr 29, 2020 at 20:16
  • 2
    Then you're fine. Being an open-source repository, Debian will not add packages to their repo without the source. In your own repo, you set your own rules. Commented Apr 29, 2020 at 20:25

1 Answer 1

2

I'm currently working on a project written in go that is distributed as a .deb package in a repository.

I have to tell you that it is not easy to find documentation about it. I use fpm for that activity.

First create in a folder that represents your project on the destination computer. For example "/tmp/proj"

Inside that folder you must put everything you want to distribute in the 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.

This way with all the files you want to distribute.

Then create a script that you will use to generate the 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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I am going through the same, the docs are there but confusing so it's a bag of learning indeed! I came to similar conclusions, however I did not know fpm, so I'll check that out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.