Re: Build Debian bin pkg from Ubunt scr pkg

Stefan Schlee <[email protected]> Sat, 3 Oct 2009 13:34:44 -0700 (PDT)
Newsgroups gmane.text.refdb.general
Message-ID <[email protected]>
Hallo!

My last posting is so terse that it nearly qualifies to be wrong.  Sorry for that, I will be verbose again (thanks for your patience ;)

When I freshly install the "refdb" package, either the first time or after a purge of the package the server exits prematurely after the installation is completed.  So far I was right.  But this statement/answer is not relevant for Markus, to whom's posting I have replied, because the server code apparently works as he writes (only checking for the presence of a db-driver) and the reason why the server exits is a packaging issue.

Torsten Bronger writes:

> I thought it fails on Stefan's system because it doesn't find
> libdbd-sqlite3.  This was the reason why I suggested to swap
> libdbd-sqlite3 and libdbd-sqlite in the "Depends:" and "Recommends":
> fields of the package.  Which libdbd's must be installed for a
> refdbd which doesn't find any configuration files?

Only having installed a package "libdbd-sqlite" instead of "libdbd-sqlite3" was one of the reasons why the server could not start when I first tried to install the package.  But installing "libdbd-sqlite3" only solved the problem partially - the server still did not start.  The reason for this was that the "refdbd"-server does not find an "/etc/refdb/refdbdrc" file, because the "/etc/refdb" only contains "*.example" files until I _manually_ run the "refdbd-init" script.

And now for the somewhat intricate part of the story.  As Torsten writes:

> For me, it works, probably because my system has everything
> installed anyway.

Although it did not work for me, this still may be true for Torsten, because:

1. When you have a running installation and your remove (not purge !) the package and reinstall the package, you will have a running server at the end of the installation.

2. When you install the package for the first time or reinstall it after purging the package (not removing !) it may seem that the "refdbd"-server runs after the end of the installation, because the installation scripts do not issue an error message - although the server has exited prematurely.  If you run the "refdb-init" script immediately after the installation in this case, the script will create a copy of the appropriate "refdbdrc" in the "/etc/refdb" directory, initialise the "refdb" database and start the "refdbd" server.

In both cases everything works fine or seems to work fine.

ad case 1.

When you have a running installation this is so because you manually executed the "refdb-init" script _after_ the installation had completed.  If you remove the package ("dpkg -r refdb") all the files that have been installed into the "/etc/refdb" directory _during_ the Debian installation process will be removed.  The "refdbdrc" that was copied into the "/etc/refdb" directory though will _not_ be removed.  The reason for this is that Debian tries hard to respect the work of the administrator.  If the package-removal software recognises any changes to the original configuration files or any added files in the configuration directory it will leave these files untouched during a package removal.  This means that if you reinstall the package the installation process will find "the old refdbdr
 c" in the "/etc/refdb" directory and will happily use this configuration file to start the server.

ad case 2.

The reason why the installation process (sometimes) does not issue an error message although the "refdbd" server exits prematurely is probably due to a timing issue.  The "/etc/init.d/refdb" script contains a variable STARTTIME.  Setting this variable to a (small) positive value serves two purposes: It shall prohibit false negative and false positive indications immediately after the server is started.  The false positive indication in our case may have its reason in the fact that STATTIME is not set at all.  This means that the server exits after the "server-probe" has been performed.   Hence the installation scripts issue no error, although the server is not running after the installation has been completed.

ad "purging the refdb-package".

If you try to purge the "refdb"-package ("dpkg -P refdb"), which is much more radical than removing and will eradicate (nearly ?) every trace of the package from the system, you will get some error messages. I assume that this is because the rm-scripts of the package do not currently work perfectly.  Because purging is very valuable if you are testing package installation and removing the remaining traces by hand gets tedious with the time I have written a short script that may be of some help for you.  I have enclosed this script at the end of the posting.  Be careful if you use it: It will remove your carefully crafted configuration file and it may remove your reference database if you are not careful (at least in the "sqlite(3)" case).

Kind regards

Stefan

8<- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

#!/bin/bash

exit_on_err () {
    echo $1
    exit 1
}

dpkg -P refdb 2> /dev/null

echo "Package refdb purged partially ..."

# Remove configuratin files
#
rm -f /etc/refdb/*

rmdir /etc/refdb || exit_on_err "Error: Unable to remove configuration files in /etc. Purging of package refdb probably not completed."

rm -f /root/.refdbarc || exit_on_err "Error: Unable to remove rc files in /root. Purging of package refdb not completed"

echo "Configuration files removed"

# Remove pid files
#
rm -f /var/run/refdb/*

rmdir /var/run/refdb || exit_on_err "Error: Unable to remove pid files. Purging of package refdb probably not completed."

echo "Pid files removed"

# Remove log files
#
rm -f /var/log/refdb/*

rmdir /var/log/refdb || exit_on_err "Error: Unable to remove log files of refdb server. Purging of package refdb probably not completed."

rm -f /var/log/refdba.log || exit_on_err "Error: Unable to remove log files of refdba. Purging of package refdb probably not completed."

echo "Log files removed"

# Remove the databases
#
if [ -e /var/lib/refdb ]
then
    echo "Do you want to remove the databases too? (y/n)"

    while true ; do
	read confirm
	[ `echo ${confirm} | grep "y\|n"` ] && break
	echo -ne "\a"
    done

    if [ "${confirm}" = "y" ]
    then
	rm -f /var/lib/refdb/db/*
	rmdir /var/lib/refdb/db
	rmdir /var/lib/refdb
	echo "All databases removed" || exit_on_err "Error: Unable to remove databases. Purging of package refdb probably not completed."
    fi
fi



      

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf