How to install your 200 favourite programs automatically? Latest versions with bug fixes, please. Create a metapackage.
Install requirements
$ sudo apt-get update $ sudo apt-get -y install equivs
Create source file
Create a skeleton file. Use only small caps letters [a-z], numbers [0-9] and dash “-” for the name. Use unique, descriptive name.
$ equivs-control teros-ipknow.cfg
Change “Package”, “Version” and “Depends”. Remove comment mark hash “#” from lines you edit.
$ nano teros-ipknow.cfg
Use the same package name as in filename, without the .cfg suffix. You must add to version number every time you make changes. Version number is not a decimal, it is two or three integers separated with a dot (1.2.0<1.10.0).
Depends line lists packages you want to install. Package name must be correct, it should work with apt-get. For example, ‘sudo apt-get install agave’.
My example file looks like this (comments excluded)
Section: misc Priority: optional Standards-Version: 3.6.2 Package: teros-ipknow Version: 0.1 Depends: geoip-bin, gparted Description: long description and info . second paragraph
Build your deb package
$ equivs-build teros-ipknow.cfg
A new package is created.
If build fails, check that you have chosen a package name correctly. Good: “teros-programming”, bad: “Some Metapackage”
Test
$ sudo gdebi -n teros-ipknow_0.1_all.deb
Your package should install and pull all the dependencies (geoip-bin and gparted).
Congratulations, you have built your first metapackge!
Whenever you install a new computer, you can just install your metapackage. This way, you can have 200 of your favorite programs installed automatically.
Where to go next?
- Make your package pass ‘lintian’
- Sign your package
- Create a repository with ‘reprepro’
- Create a pre-install or post-install script (don’t overuse these)
- Automatically answer questions. Even though it’s rare, some packages (mysql-server, sendmail) ask questions. Use debconf-get-selections and debconf-set-selections to automatically answer these questions.
A quick example, run on Ubuntu 11.04.
$ mkdir teros-progs
$ equivs-control teros-progs.cfg
$ cat teros-progs.cfg |grep -v ^#|grep -v ‘^$’
Section: misc
Priority: optional
Standards-Version: 3.6.2
Package: teros-progs
Version: 0.1
Maintainer: Tero Karvinen
Depends: git-core, gcc, vlc, miro, g++
Description: Metapackage of some of Tero’s favourite progs
long description and info
.
second paragraph
$ equivs-build teros-progs.cfg
$
$ lintian teros-progs_0.1_all.deb # passes lintian check
$ sudo gdebi -n teros-progs_0.1_all.deb
$ apt-cache show teros-progs
$ dpkg –list teros-progs
Syntax-error
maintainer-address-missing
Fix Maintainer:
Maintainer: Firstname Lastname
$ head -100 tscript.cfg tscript.py
==> tscript.cfg <==
Section: misc
Priority: optional
Homepage: http://terokarvinen.com
Standards-Version: 3.9.2
Package: tscript
Version: 0.2
Maintainer: Tero Karvinen
Depends: curl
Files: tscript.py /usr/local/bin/
Description: Teros sample script
Sample script
For metapacking tutorial, see
http://terokarvinen.com/2011/create-deb-metapackage-in-5-minutes
==> tscript.py <==
#!/usr/bin/python
print("Hello tScript World!")
$ lintian tscript_0.3_all.deb
W: tscript: script-with-language-extension usr/bin/tscript.py
W: tscript: binary-without-manpage usr/bin/tscript.py
E: tscript: python-script-but-no-python-dep usr/bin/tscript.py
$ sudo apt-get -y install gdebi-core
$ sudo gdebi -n tscript_0.3_all.deb
$ tscript.py
Hello tScript World!
$ which tscript.py
/usr/bin/tscript.py
Solutions to common problems:
## Remove whitespace before field name
It’s wrong to have whitespace before field name. Whitespace in the beginning of a line means that previous field continues.
Standards-Version: 3.6.2
Package: teros-progs # WRONG, remove whitespace before field name
Version: 0.1
Correct:
Standards-Version: 3.6.2
Package: teros-progs
Version: 0.1
## Add maintainer address
Lintian complains: maintainer-address-missing
Fix by adding your name and valid email address to maintainer field. Email address and angle brackets “” around it are required.
Maintainer: Tero Karvinen
In above example, wordpress does not show incorrect whitespace before field name.
In previous comment, WordPress ate email address inside angle brackets.