LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (http://www.linuxquestions.org/questions/debian-26/)
-   -   Building my own .deb package (help on postinst config) (http://www.linuxquestions.org/questions/debian-26/building-my-own-deb-package-help-on-postinst-config-523132/)

odiseo77 01-26-2007 07:45 PM

Building my own .deb package (help on postinst config)
 
Hi all, first excuse me if this is more suitable on the programming section (a mod can move it there if he/she prefer). The point is this: I'm building the linux packages for Mercury (a multiplatform MSN messenger clone). Since it's distributed in binary .zip files, I have to make a virtual file system on my home directory and then run 'dpkg-deb -b /home/username/fake_file_system' to build the package, after that, I convert the .deb package to .rpm and .tgz packages using alien. Everything works like a charm, no problems here, but I'd like my packages to come preconfigured for new users because Mercury has a lot of hidden options and need some tweking to work properly (to use the sound system of the desktop you're running and to set the default browser, etc.); for this, Mercury uses a file named GlobalSettings.xml which is stored under /home/username/.Mercury; so basically what I need is to create two GlobalSettings.xml files: one for KDE (using artsplay as sound player) and other one for GNOME and other DE's like fluxbox, XFCE, etc which use mainly alsa as the default sound player. (I think these two files could go in '/usr/share/mercury'), but I need a postinstall script which detects whether the directory '/home/username/.Mercury' exists or not, and if the directory exists do nothing (don't write a new GlobalSettings.xml file there because it would erase a previous config), but if the directory does not exist, then detect which desktop is the user running and write one of the 2 GlobalSettings.xml files in the directory.

So my question is, which file(s) under my /home/username/fake_file_system/DEBIAN directory do the job of the post-installation config and which manual(s) should I read in order to edit these files (so far I only have a '.../DEBIAN/control' file). I've read the debian new maintainers' guide and they say something about a postinst.ex file which, I assume' is the one that does this job, but the reference is rather superficial and doesn't point me to any other manual on how to create a postinstall configuration file.

Oh, and another question: after succesfully building a preconfigured .deb package will this package run fine on other systems after converting it with alien?? (I mean, the postinstallation script will run on the .rpm and .tgz packages??).

Thanks in adavance.

Dutch Master 01-28-2007 07:49 AM

Well, your cause is very noble, but it's still a script request. Not sure if that's allowed here.

Anyway, I'll give you the benefit of the doubt. Try this:
Code:

#! /bin/bash

S1=`ls -a $HOME | grep .Mercury`
if [ "$S1" = ".Mercury" ]; then
echo found a previous Mercury install, not writing default configuration
exit 0
else
echo no configuration file found, creating default
# <insert write command for xml file here>

exit 0

I know this fails, but you'd have to think along this line.

odiseo77 01-28-2007 08:52 AM

Hi Dutch Master, thanks for your answer. Well, I don't see anything wrong with scripts as they can be very usefull in these cases (I don't know how to make complex bash scripts, but I can try with a guide under my arm, lol). But what I'd specially like to know is, which file(s) of the debian packaging system do the job of the postinstall configuration. Also a good manual on how to edit these files would be very usefull for me (I've read the Debian New Maintainers' guide but as I said above, the reference to the postinst.ex file is rather vague).

Anyway, creating preconfigured linux packages of Mercury is not that important since most of the people using mercury has a previous configuration (it would be usefull only for new users)... I rather see this as an opportunity to challenge myself and learn something new, but if it's too complex for me to write these scripts, well, I'll leave it like that (I've managed to build the packages anyway).

Thanks in advance.

odiseo77 01-28-2007 10:49 AM

ok, I found the file in question, it's the 'postinst' script under the '.../DEBIAN' subdirectory of the fake file system... Thanks for your help.


All times are GMT -5. The time now is 04:57 AM.