Building a metapackage and a local package repository

In this post I’m doing a home assignment for Tero Karvinen’s course of linux servers. The assignment is to build a metapackage that installs a bunch of software in a single package, to create a local package repository and to package a script so it installs a new command to all users. I’m going to do this on my desktop computer. The computer is i5-3570k (4X, 3,8GHz, 6M) 16GB RAM, 2x Asus GeForce GTX 560 TI in SLI mode. Using the xubuntu live-USB stick. I divided this post to two parts, part two ->.

Building a metapackage

This part was very easy, by using ‘equivs’.

sudo apt-get update && sudo apt-get install equivs -y

This command installs the latest packaged version of equivs on your system. For the assignment, I’m doing my own LAMP installation metapackage, containing only the things I need for a minimal installation.

mkdir mmm-lamp
cd mmm-lamp
equivs-control mmm-lamp

The ‘equivs-control’ command creates the basic structure for your own package and the ‘mmm-lamp’ is the name I gave for my package.

I modified the text file like so:

Section: misc
Priority: optional
Homepage: https://miro.metsanheimo.fi 
Standards-Version: 3.9.2

Package: mmm-lamp                                
Version: 0.0.1                                
Maintainer: Miro Metsänheimo <miro@metsanheimo.fi>
Depends: apache2, mariadb-server, php5, php5-mysql, libapache2-mod-php5
Description: Miro Metsänheimo's own LAMP package             
 LAMP package with minimal installation

The line that defines the package as a metapackage is the ‘depends’ line. There we list all the packages we want installed in the package.

  • apache2: The basic and most used web server software
  • mariadb-server: My favourite fork of the MySQL database software
  • php5: PHP package
  • php5-mysql: PHP module that makes it work well with MySQL
  • libapache2-mod-php5: Apache module that makes apache work well with PHP.

Now to build the package to an installable ‘.deb’ file.

equivs-build mmm-lamp

Now I have a package called ‘mmm-lamp_0.0.1_all.deb’ in the same folder.

Now to check if it goes through ‘lintian’.

lintian mmm-lamp_0.0.1_all.deb

It returns nothing, that means it doesn’t contain bugs or policy violations and should install fine.

Creating a package repository

I’ll be doing this using ‘reprepro’, it is required to have a web server running for this to work. I’m doing this over Apache that I installed using the metapackage I just created.

sudo apt-get install reprepro -y
gpg --gen-key

The GnuPG key generator will ask a series of questions in order to make the key. The recommended are the default options, so I just spammed enter until I got my key.

It also asked my real name, e-mail and a passphrase for the key. After that it needs a lot of random bytes, so it recommended me to type on my keyboard and move my mouse etc. to “collect more entropy”.

After the key is complete or meanwhile it’s in the making, lets create the folder structure for our repository

sudo mkdir -p apt/incoming
sudo mkdir -p apt/conf
sudo mkdir -p apt/key

The -p option makes the required parents for the directory.

The next command exports the created gpg key to the repository.

sudo gpg --armor --export Miro Metsänheimo miro@metsanheimo.fi >> /var/www/apt/key/deb.gpg.key

Then we need to create a file called ‘distributions’ in the ‘conf’ folder. And add some content to it.

sudoedit /var/www/apt/conf/distributions

I added these lines:

Origin: Miro Metsänheimo
Label: mmm-repo
Suite: stable
Codename: first-repo
Version: 14.04
Architectures: amd64
Components: universe
Description: My own repo
SignWith: yes

Now to create the repository with the configuration and the gpg-key:

sudo reprepro --ask-passphrase -Vb /var/www/apt export

And to add my own metapackage to the repository:

sudo reprepro --ask-passphrase -Vb . includedeb first-repo /home/xubuntu/Desktop/mmm-lamp/mmm-lamp_0.0.1_all.deb

Now I have a repository published on my Apache web server!

 

I wrote the home assignment in two parts, because the other one would better fit in another article. Part two ->

Sources

Class by Tero Karvinen

Lintian

Reprepro

 

Miro Metsänheimo

A software developer from Finland born in -92. I'm passionate about computers and technology. Feel free to message me about anything!

 

Leave a Reply

Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin