How difficult is this?
Not so difficult at all. I do all my packaging from scratch. Once you know a few tools, and understand what's going on, the process is fairly simple. Be prepared to spend some time, learning the processes, though.
Do I need to create my own repository for this to work?
A repository (such as a PPA) is for publishing your package to the wider world. So, yes, if you want people to be able to install the package, either you need to get it included in Debian/Ubuntu, or you need to publish it in a repository.
PPAs also have access to the Launchpad build farm, so they can build binary packages from source packages. But you can do this locally, too. And while packaging something, you really want to be test-building locally, rather than waiting for LP to build your package (the LP build queues can be hours long).
Do I need to sign it with my public key or something?
If you want to upload to a PPA, you need to sign your source package with your private key.
Will one deb package work for all Debian-based distributions, or do I need to build a separate version for each flavour?
The safe answer is no. But sometimes it's fairly straightforward to produce once deb that will work on all current Debian and Ubuntu releases. It depends on the package and the toolchain you used.
I suggest:
Below, I'm assuming that the source is open (e.g. Python scripts) which are therefore not bound to any architecture (e.g. amd64 or i386), hence "all". If you have some C source, you need to use Architecture: amd64 i386
in your source control
file.
creating package ready for Launchpad
This will eventually will become a series of individual launchpad PPA packages.
What I prefer (but may not be able to achieve...) is to keep my packaging to a minimum - create a series of packages from a template and adjust the bare minimum (changelog etc + the tar file).
Launchpad only accepts source packages, so create a rules
that installs the files in the correct places. For convenience, I'll use debhelper. The directory with your files should look like:
debian/changelog
debian/control
debian/rules
debian/compat
mypluginfolder/...
A debian/copyright
file may also be useful for informing users about the licenses associated with the package. I don't think you need a postinst
script since you only need to extract some files. compat
should contain the debhelper compatilbility level, say "8". (please refer to the manual page of debhelper for more details)
The changelog
file can be edited with the dch
command, available from the devscripts
package. The rules
(using debhelper) should contain:
#!/usr/bin/make -f
%:
dh $@
override_dh_install:
dh_install mypluginfolder/ /usr/share/rhythmbox/plugins
Make it executable using chmod 755 debian/rules
. A source package can be build using debuild -S
. Be sure to be in a directory named <package-name>-<version>
. More information about the override_
behavior and the dh
command can be found on its manual page.
The Debian New Maintainers' Guide was very valuable for me to understand this, it's recommended reading. Example packaging can be found on https://github.com/Bumblebee-Project/bumblebee-ppa.
creating package from existing file tree
dpkg-deb -b
can be used for creating tarballs from an existing file tree. First, start with creating a directory that should be named after your package. I'll assume you want to name it myplugin
, and put it in /usr/share/rhythmbox/plugins/mypluginfolder
. In addition, create the DEBIAN
directory (uppercase!) for storing package information:
mkdir -p myplugin/usr/share/rhythmbox/plugins/mypluginfolder
mkdir myplugin/DEBIAN
Copy over your files:
cp -r ~/mypluginsfolder myplugin/usr/share/rhythmbox/plugins
Next, you'll need a so-called control file located at myplugin/DEBIAN/control
which describes the package. The contents of such a file are put below:
Package: myplugin
Version: 1.0-1
Maintainer: You <whatever@contact.address>
Architecture: all
Description: plugins for Rhythmbox
Longer description here
.
As you can see, new paragraph are split by a single dot,
and lines have to be indented by one space.
Now, you can optionally verify the contents of your package. The next command lists the file and directory entries contents of myplugin
:
find myplugin -ls
If you're satisfied, build the package in the current directory:
dpkg-deb -b myplugin .
A new file will appear, named like <package>_<version>_<architecture>.deb
which is in this example myplugin_1.0-1_all.deb
. You can use the less
program to peek in the file. For example, less myplugin_1.0-1_all.deb
.
Best Answer
The tutorial you have linked uses a low level approach for building a package. Such an approach is not usually recommended and may lead to all sorts of issues when not done carefully.
Creating a .deb for a script is very simple once you understand packaging basics. In a nutshell:
Adding more scripts requires them to be copied to the directory and added to the debian/install file -- then just re-run debuild. You should also check and update the debian/* files as required .
You should read the man pages for:
dh_make
,dh_install
, anddebuild