Creating a deb metapackage

I am writing this post as part of Tero Karvinen’s course: Linux palvelimena (roughly translated: Linux as a server) http://terokarvinen.com/2012/aikataulu-linux-palvelimena-ict4tn003-4-ja-ict4tn003-6-syksylla-2012.

On this post I will go through the following:

  • Create a deb metapackage
  • Add a python file to the metapackage
  • Test the metapackage
  • Install & configure Apache 2 to enable sharing of a repository
  • Create the repository
  • Add the metapackage to the repository
  • Test the repository with another computer

I am using a 32-bit Xubuntu 12.04.1 live dvd environment. My instructions and testing are based on instructions found in Tero’s blog (http://terokarvinen.com/2011/create-deb-metapackage-in-5-minutes and http://terokarvinen.com/2011/update-all-your-computers-with-a-deb-repository)

Creating the metapackage

I started by installing equivs:
$ sudo apt-get update
$ sudo apt-get install equivs

(To keep everything organized I made a folder for the metapackage $ mkdir meta and $ cd meta/)

I created the base for the metapackage with the command $ equivs-control kontsus-musthave.cfg
I opened the file with nano $ nano kontsus-musthave.cfg

After I was finished editing the file, I pressed “Ctrl+x” to exit, ‘y’ to save changes and “Enter” to confirm the filename.

Now to build the deb package $ equivs-build kontsus-musthave.cfg

Uh-oh: syntax error in control file: long description and info

I re-opened the file to see where the problem lies. My error was that I had removed the space from the text under “Description:” so it didn’t recognize the text below it as part of the description text.

at this point I could test that the package works, but I want to test adding a file of my own to the list of files to install. (the command for testing: $ sudo apt-get install gdebi-core
$ sudo gdebi kontsus-musthave_0.1_all.deb)

Adding your own files in the package

I’ll be making a hello world file with python

$ mkdir python
$ cd python
$ nano helloWorld.py

The file:

print "Hello World!"

and to test the file: $ python helloWorld.py

I re-opened the .cfg file in the meta folder and made the following changes as seen on the picture

I used lintian to verify that the metapackage is “legit” ($ sudo apt-get install lintian
$ lintian kontsus-musthave_0.2_all.deb)

I got the following warning: E: kontsus-musthave: non-standard-dir-in-var var/HelloWorld.py/
W: kontsus-musthave: file-in-unusual-dir var/HelloWorld.py/home/xubuntu/meta/python/helloWorld.py

So I made the following changes (starting from the meta -folder):

$ mkdir build
$ cd build
$ cp /home/xubuntu/meta/kontsus-musthave.cfg /home/xubuntu/meta/build/
$ cp /home/xubuntu/meta/python/helloWorld.py /home/xubuntu/meta/build/
$ nano kontsus-musthave.cfg

$ equivs-build kontsus-musthave.cfg
$ lintian kontsus-musthave_0.3_all.deb

E: kontsus-musthave: non-standard-dir-in-var var/HelloWorld.py/
W: kontsus-musthave: file-in-unusual-dir var/HelloWorld.py/helloWorld.py

last try:

Also in text:

Section: misc
Priority: optional
Standards-Version: 3.9.2

Package: kontsus-musthave
Version: 0.4
Maintainer: kontsu
Depends: gedit, chromium-browser
Files: helloWorld.py /Helloworld.py
Description: must have programs
long description and info
kontsu’s must have programs when using the live-cd (or dvd)
.
second paragraph

The error:

E: kontsus-musthave: non-standard-toplevel-dir HelloWorld.py/
W: kontsus-musthave: file-in-unusual-dir HelloWorld.py/helloWorld.py

at this point I’ll just ignore the error and see what happens:

EDIT: The correct place for your own files are /usr/local/bin
I’ll have to try the following in the file:
Files: HelloWorld.py /usr/local/bin/HelloWorld.py

(if you didn’t install gdebi: $ sudo apt-get install gdebi-core)
$ sudo gdebi kontsus-musthave_0.4_all.deb

I answered ‘y’ when I was asked “Do you want to install the software package?”

The program installed gedit and ignored chromium as I had it already installed. The Python file appeared in a folder “HelloWorld.py” under root directory. I was expecting that the file would go there but why it created the folder I do not know.

Installing & configuring apache 2 web server

I installed apache 2 web server:
$ sudo apt-get install apache2

enabled users to host files over internet:
$ sudo a2enmod userdir

restarted apache in order to apply the change:
$ sudo service apache2 restart

created the folder where the file will be shared:

$ cd
$ mkdir public_html
$ cd public_html/
$ mkdir -p repository/conf

Creating a repository & adding the metapackage

While in the public_html folder I created the repository file

$ nano repository/conf/distributions

The text in the file:

Codename: precise
Components: main
Suite: precise
Architectures: i386 amd64 source

install reprepro
$ sudo apt-get install reprepro

add the deb package to the repository:
$ reprepro -VVVV -b repository/ includedeb precise /home/xubuntu/meta/build/kontsus-musthave_0.4_all.deb

Testing the repository

I have deleted chromium and gedit to test the repository out. ($ sudo apt-get remove chromium-browser gedit)
(this is the part you would do in a client computer)

I opened the list of sources (where apt downloads packages) and added the repository there (the ip can be found out by using ifconfig on the host/server computer $ ifconfig)

$ sudoedit /etc/apt/sources.list.d/repository.list

The text in the file:

deb http://172.28.9.208/~xubuntu/repository precise main

and now to test:

$ sudo apt-get update
$ sudo apt-get install kontsus-musthave

the repository worked locally and installed gedit and chromium-browser to my live session.

I also tested the repository on another computer over local network and it worked there also.

Advertisements

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