Here at Qcode we are liking the convenience of using checkinstall to generate .deb files for software we need which hasn’t found its way into the official Debian repositories.

Currently Squeeze stable distributes postgresql 8.4. However, Postgresql 9.0 has some very powerful streaming replication features we needed.

The answer is to compile Postgresql ourselves and use checkinstall to produce a .deb package we can store on our repository for future use.

It’s trivial to do:

[david@qcode:~]$ wget http://ftp.postgresql.org/pub/source/v9.0.2/postgresql-9.0.2.tar.gz
[david@qcode:~]$ tar -zxf postgresql-9.0.2.tar.gz
[david@qcode:~]$ cd postgresql-9.0.2
[david@qcode:~postgresql-9.0.2]$ ./configure
...
[david@qcode:~postgresql-9.0.2]$ make
...
[david@qcode:~postgresql-9.0.2]$ checkinstall
...
[david@qcode:~postgresql-9.0.2]$ ls -l *.deb
-rw-r--r-- 1 david david 10504544 Feb 24 14:11 postgresql_9.0.2-qcode1-1_amd64.deb

That’s it…

Now we can import this .deb into reprepro on our repository host:

david@asw19:~/debian.qcode.co.uk$ reprepro includedeb squeeze debs/postgresql_9.0.2-qcode1-1_amd64.deb
debs/postgresql_9.0.2-qcode1-1_amd64.deb: component guessed as 'main'
Exporting indices...

However! When we run a apt-get update against the repository now we get the following error:

...
Reading package lists... Error!
E: Problem parsing dependency Depends
E: Error occurred while processing postgresql (NewVersion2)
E: Problem with MergeList /var/lib/apt/lists/debian.qcode.co.uk_dists_squeeze_main_binary-amd64_Packages
E: The package lists or status file could not be parsed or opened.

Looking into this further we can have a look at the package file:

dists/squeeze/main/binary-amd64/Packages

Package: postgresql
Installed-Size: 43648
Maintainer: hackers@qcode.co.uk
Architecture: amd64
Version: 9.0.2-qcode1-1
Depends:
Provides: postgresql
Conflicts:
Replaces:
Priority: extra
Section: checkinstall
Filename: pool/main/p/postgresql/postgresql_9.0.2-qcode1-1_amd64.deb
Size: 10504544
SHA256: 14de3d338744e1e8b5ed16b0470ecb1cd771a755c434a12e292695227fb75952
SHA1: f6826c952db327c56bb374b874ef2a57bf2c040a
MD5sum: 4b4b2f717cd7c25bfddc7c0251beb0cb
Description: object-relational SQL database, version 9.0.2 server (Qcode packaged)
 object-relational SQL database, version 9.0.2 server (Qcode packaged)
 PostgreSQL is a fully featured object-relational database management
 system. It supports a large part of the SQL standard and is designed
 to be extensible by users in many aspects. Some of the features are:
 ACID transactions, foreign keys, views, sequences, subqueries,
 triggers, user-defined types and functions, outer joins, multiversion
 concurrency control. Graphical user interfaces and bindings for many
 programming languages are available as well.

Note the empty entries against the control file fields Depends, Requires and Conflicts generated by checkinstall. Those are our problem!

Checkinstall will, by default, leave these lines blank which confuses apt-get no end.

How to get around this? A couple of ways (that we’ll go into – as always there will be others) depending on your preference.

  1. Repackage with checkinstall.
    Or
  2. Changing reprepro config.

Repackage with Checkinstall Adding the Required Fields

We found if we repackage using the following options the apt-get was happy:

[david@qcode:~]$ checkinstall --requires libc6 --replaces none --conflicts none

“Requires” translates to “depends”, and it cannot be set to “none” so we’re added a cursory dependency to keep apt-get happy.

However, maybe you don’t have control of the .deb file and can’t repackage it. If not, don’t worry, there’s another way.

Reprepro overrides

You have the option of specifying override files in the options for your reprepro repository.

david@asw19:~/debian.qcode.co.uk$ cat conf/options

Origin: Qcode Software Limited
Label: Qcode Software Limited
Codename: squeeze
Version: 3.0
Architectures: i386 amd64
Components: main
Description: Qcode Apt Repository
SignWith: yes
DebOverride: override.squeeze
DscOverride: override.squeeze

In the last 2 lines you can see the override files set up for the squeeze repos. In this override file we can specify what we want each field to be rewritten in the postgresql package by reprepro as.

debian.qcode.co.uk@asw19:~/debian.qcode.co.uk$ cat conf/override.squeeze

postgresql Depends libc6
postgresql Conflicts none
postgresql Replaces none

Now we just remove and reinclude the .deb file:

david@asw19:~/debian.qcode.co.uk$ reprepro remove squeeze postgresql
removing 'postgresql' from 'squeeze|main|amd64'...
Exporting indices...
Deleting files no longer referenced...
deleting and forgetting pool/main/p/postgresql/postgresql_9.0.2-qcode1-1_amd64.deb
removed now empty directory ./pool/main/p/postgresql
removed now empty directory ./pool/main/p

david@asw19:~/debian.qcode.co.uk$ reprepro includedeb squeeze debs/postgresql_9.0.2-qcode1-1_amd64.deb
debs/postgresql_9.0.2-qcode1-1_amd64.deb: component guessed as 'main'
Exporting indices...

Check the Package file again:

david@asw19:~/debian.qcode.co.uk$ vim dists/squeeze/main/binary-amd64/Packages

Package: postgresql
Installed-Size: 43648
Maintainer: hackers@qcode.co.uk
Architecture: amd64
Version: 9.0.2-qcode1-1
Provides: postgresql
Replaces: none
Conflicts: none
Depends: libc6
Priority: extra
Section: checkinstall
Filename: pool/main/p/postgresql/postgresql_9.0.2-qcode1-1_amd64.deb
Size: 10504544
SHA256: 14de3d338744e1e8b5ed16b0470ecb1cd771a755c434a12e292695227fb75952
SHA1: f6826c952db327c56bb374b874ef2a57bf2c040a
MD5sum: 4b4b2f717cd7c25bfddc7c0251beb0cb
Description: object-relational SQL database, version 9.0.2 server (Qcode packaged)
 object-relational SQL database, version 9.0.2 server (Qcode packaged)
 PostgreSQL is a fully featured object-relational database management
 system. It supports a large part of the SQL standard and is designed
 to be extensible by users in many aspects. Some of the features are:
 ACID transactions, foreign keys, views, sequences, subqueries,
 triggers, user-defined types and functions, outer joins, multiversion
 concurrency control. Graphical user interfaces and bindings for many
 programming languages are available as well.

And finally, back on the host which is trying to use the repo:

[david@qcode:~]$ apt-get update
....
Fetched 5,344 B in 0s (5,949 B/s)
Reading package lists... Done

And we’re done.