Linux palvelimena – Homework 4 – Package handling

Week 4 – Metapackages and repositories

The fourth week had us dabble with packages. Sources used, if not explicitly stated otherwise, are:

http://terokarvinen.com/2011/create-deb-metapackage-in-5-minutes http://terokarvinen.com/2011/update-all-your-computers-with-a-deb-repository

Course homepage is: http://terokarvinen.com/2012/aikataulu-%E2%80%93-linux-palvelimena-ict4tn003-3-ja-ict4tn003-5-kevaalla-2012

Assignment

Release your own metapackage in your own repository.

Voluntary exercises
– sign the packages
– create metapackages with dependicer

Environment

Ubuntu 12.04 @ Virtualbox, username: antero, computer: VirtualBox

Creating a metapackage

Let’s start by creating a metapackage. A metapackage contains other packages, and it’s handy for installing your favourite software in one go.

We need equivs:

antero@VirtualBox:~$ sudo apt-get install equivs 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
...and so on

The package will contain two roguelike games, namely nethack and dungeon crawl, so I’ll make a working directory to keep organized. In the directory, we create a skeleton file for the package with equivs-control:

antero@VirtualBox:~$ pwd
/home/antero
antero@VirtualBox:~$ mkdir mymeta-games
antero@VirtualBox:~$ cd mymeta-games/
antero@VirtualBox:~/mymeta-games$ equivs-control mymeta-games.cfg
antero@VirtualBox:~/mymeta-games$ ls
mymeta-games.cfg
antero@VirtualBox:~/mymeta-games$

The file is now created. Next we edit it, but first a screenshot of the contents:

Notice the highlighted line about reasonable defaults. I love reasonable defaults. Anyway, time to edit the file a bit. We changed the package name, version number (to 0.1), depends (to include the games) and the description:

Time to build the deb package, then:

antero@VirtualBox:~/mymeta-games$ equivs-build mymeta-games.cfg 
dh_testdir
dh_testroot
dh_prep
dh_testdir
dh_testroot
dh_install
dh_installdocs
dh_installchangelogs
dh_compress
dh_fixperms
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dpkg-deb: building package `mymeta-games' in `../mymeta-games_0.1_all.deb'.

The package has been created.
Attention, the package has been created in the current directory,
not in ".." as indicated by the message above!
antero@VirtualBox:~/mymeta-games$

Let’s see if the deb was created:

antero@VirtualBox:~/mymeta-games$ ls
mymeta-games_0.1_all.deb  mymeta-games.cfg

It was. Now to see whether it works, with gdebi. Which, it seems, we have to install first:

The program 'gdebi' is currently not installed.  You can install it by typing:
sudo apt-get install gdebi-core
antero@VirtualBox:~/mymeta-games$ sudo apt-get install gdebi-core 
...
Processing triggers for man-db ...
Setting up gdebi-core (0.8.5build1) ...
antero@VirtualBox:~/mymeta-games$

Doing ‘man gdebi’ describes it as a “Simple tool to install deb files”, which sounds apt (as in fitting).

antero@VirtualBox:~/mymeta-games$ sudo gdebi mymeta-games_0.1_all.deb 
Reading package lists... Done
Building dependency tree        
Reading state information... Done
Building data structures... Done 
Building data structures... Done 

Requires the installation of the following packages: 
crawl  nethack-common  nethack-console 
Nethack and Crawl in one go.
long description and info
.
second paragraph
Do you want to install the software package? [y/N]:y
Get:1 http://fi.archive.ubuntu.com/ubuntu/ precise/universe nethack-common i386 3.4.3-12.2 [453 kB]
Get:2 http://fi.archive.ubuntu.com/ubuntu/ precise/universe nethack-console i386 3.4.3-12.2 [882 kB]
Fetched 1335 kB in 0s (0 B/s)                                                                   
Preconfiguring packages ...
Preconfiguring packages ...
Selecting previously unselected package crawl.
(Reading database ... 170795 files and directories currently installed.)
Unpacking crawl (from .../crawl_2%3a0.9.1-1_i386.deb) ...
Selecting previously unselected package nethack-common.
Unpacking nethack-common (from .../nethack-common_3.4.3-12.2_i386.deb) ...
Selecting previously unselected package nethack-console.
Unpacking nethack-console (from .../nethack-console_3.4.3-12.2_i386.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Setting up crawl (2:0.9.1-1) ...
Setting up nethack-common (3.4.3-12.2) ...
Setting up nethack-console (3.4.3-12.2) ...
update-alternatives: using /usr/lib/games/nethack/nethack-console.sh to provide /usr/games/nethack (nethack) in auto mode.
Selecting previously unselected package mymeta-games.
(Reading database ... 170848 files and directories currently installed.)
Unpacking mymeta-games (from mymeta-games_0.1_all.deb) ...
Setting up mymeta-games (0.1) ...
antero@VirtualBox:~/mymeta-games$

Success! Although the lines “long description and info” and “second paragraph” look ugly. Now, to see if it passes lintian (a static analysis tool for Debian packages). We install lintian with sudo apt-get install lintian, and then:

antero@VirtualBox:~/mymeta-games$ man lintian
antero@VirtualBox:~/mymeta-games$ lintian mymeta-games_0.1_all.deb 
E: mymeta-games: debian-changelog-file-contains-invalid-email-address antero@VirtualBox
E: mymeta-games: maintainer-address-malformed Antero <antero@VirtualBox>
antero@VirtualBox:~/mymeta-games$

Looks like we have some tinkering to do. I’ll edit the cfg file to contain Erkki Esimerkki <erkki@esimerkki.com> and change the version number to 0.2 to prevent future errors. Actually, let’s add the long description as well, as its lack bothers me to no end:

Let's build it again, and retry lintian.
antero@VirtualBox:~/mymeta-games$ nano mymeta-games.cfg 
antero@VirtualBox:~/mymeta-games$ equivs-build mymeta-games.cfg 
dh_testdir
dh_testroot
dh_prep
dh_testdir
dh_testroot
dh_install
dh_installdocs
dh_installchangelogs
dh_compress
dh_fixperms
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dpkg-deb: building package `mymeta-games' in `../mymeta-games_0.2_all.deb'.

The package has been created.
Attention, the package has been created in the current directory,
not in ".." as indicated by the message above!
antero@VirtualBox:~/mymeta-games$ ls
mymeta-games_0.1_all.deb  mymeta-games_0.2_all.deb  mymeta-games.cfg
antero@VirtualBox:~/mymeta-games$ lintian mymeta-games_0.2_all.deb 
antero@VirtualBox:~/mymeta-games$

Let’s see if we can sign it. Remember how we set the maintainer to Erkki Esimerkki <erkki@esimerkki.com>? We need to remember that now, as we generate keys with gpg –gen-key. We insert Erkki’s info when asked, and set the key to expire in 1 week, and otherwise just press enter whenever asked something. I wouldn’t usually include all sensitive data on a report, but since this is a temporary environment with fake info, I’ll let it slip.

Did our key get saved succesfully?

antero@VirtualBox:~/mymeta-games$ gpg --list-secret-keys 
/home/antero/.gnupg/secring.gpg
-------------------------------
sec   1024R/25DB1429 2012-09-18 [expires: 2012-09-25]
uid                  Erkki Esimerkki <erkki@esimerkki.com>
ssb   1024R/C953C374 2012-09-18

Looks like it did. Next stop is to rebuild the package once again, this time with the –full parameter. Also, I’ll change to description a bit and increase the version number. (Latter steps not specifically reported anymore.) –full makes it use Erkki’s key. Quote from man equivs-build:

–full | -f

Do a complete build. debuild will be called, that is, a full package will be built and signed, suitable for upload to the Debian servers.The ID used to signed is taken from, in that order, the user from the last entry of a supplied changelog, the Maintainer: field in the equivs control file, or the local username.

It is now a signed package, unless I’ve misunderstood something along the way.

Repository

Next up, setting up a repository. We’re going to need to install Apache web server and enable userdir, so let’s get that out of the way.

antero@VirtualBox:~/mymeta-games$ sudo apt-get install apache2
...

We use a handy tool called a2enmod to enable userdir, and then restart the server:

antero@VirtualBox:~/mymeta-games$ sudo a2enmod userdir
Enabling module userdir.
To activate the new configuration, you need to run:
service apache2 restart
antero@VirtualBox:~/mymeta-games$ sudo service apache2 restart
* Restarting web server apache2                                                                 
apache2: Could     not reliably determine the server's fully 
qualified domain name, using 127.0.1.1 for ServerName
... waiting .apache2: Could not reliably determine the server's 
fully qualified domain name, using 127.0.1.1 for ServerName

It couldn’t reliably determine the domain name, maybe because it’s running on Virtualbox. I’ll have to look into that later.

Next we create and configure an empty repository:

antero@VirtualBox:~$ pwd
/home/antero
antero@VirtualBox:~$ cd public_html/
antero@VirtualBox:~/public_html$ mkdir -p repository/conf

Then we create a file called distributions and edit it to contain:

antero@VirtualBox:~/public_html/repository/conf$ cat distributions 
Codename: precise
Components: main
Suite: precise
Architectures: i386 amd64 source

(The example I’m following used codename and suite ‘lucid’, but I suppose ‘precise’ is appropriate for Ubuntu 12.04.) Then we add our previously created deb package into the repository, with reprepro, which we’ll also have to install.

antero@VirtualBox:~/public_html/repository$ reprepro
The program 'reprepro' is currently not installed.  You can install it by typing:
sudo apt-get install reprepro
antero@VirtualBox:~/public_html/repository$ sudo apt-get install reprepro
Reading package lists... Done
Building dependency tree
...

Now, to actually add the deb:

antero@VirtualBox:~/public_html/repository$ reprepro -VVVV -b /home/antero/public_html/repository/ includedeb precise /home/antero/mymeta-games/mymeta-games_0.3

Notice the -VVVV. More V flags mean more verbose output. -b is used to define the repository’s base dir. As the included screenshot shows, the output is verbose indeed:

Let’s add our repository to the sources.list file:

antero@VirtualBox:~/public_html/repository$ sudo nano /etc/apt/sources.list

and add:

## My test repository
deb http://localhost/~antero/repository precise main

Then we apt-get update and try to install the mymeta-games package we created earlier:

antero@VirtualBox:~/public_html/repository$ sudo apt-get install mymeta-games 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  mymeta-games
0 upgraded, 1 newly installed, 0 to remove and 52 not upgraded.
Need to get 2,088 B of archives.
After this operation, 26.6 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  mymeta-games
Install these packages without verification [y/N]? y
Get:1 http://localhost/~antero/repository/ precise/main mymeta-games all 0.3 [2,088 B]
Fetched 2,088 B in 0s (209 kB/s)          
Selecting previously unselected package mymeta-games.
(Reading database ... 172206 files and directories currently installed.)
Unpacking mymeta-games (from .../mymeta-games_0.3_all.deb) ...
Setting up mymeta-games (0.3) ...
antero@VirtualBox:~/public_html/repository$

It works! But it couldn’t be authenticated, which might indicate a problem with the gpg key stuff. I’ll probably update this post regarding that later.

Advertisements

About a1100320

IT student, musician, gamer. Beep boop.
This entry was posted in Linux palvelimena ICT4TN003-4. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s