maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   how to add configuration file to debian package? (https://talk.maemo.org/showthread.php?t=72227)

XenGi 2011-04-16 14:49

how to add configuration file to debian package?
 
hi,

I'm developing an application with qt creator for n900.
In my app I need to save some stuff to a config file. This file should be located at "~/.myapp/config.xml".
Creating and editing the file at runtime is no problem but how do I add it to the debian package so that it will be installed along with the binary?
That should be the standard way in debian, should it?

I search google and found many stuff regarding debian packaging but I'm didn't find a suitable answer.

Rob1n 2011-04-16 15:40

Re: how to add configuration file to debian package?
 
Quote:

Originally Posted by XenGi (Post 989900)
hi,

I'm developing an application with qt creator for n900.
In my app I need to save some stuff to a config file. This file should be located at "~/.myapp/config.xml".
Creating and editing the file at runtime is no problem but how do I add it to the debian package so that it will be installed along with the binary?
That should be the standard way in debian, should it?

No, you should never be installing a user config file as part of the package. Packages should only install system-wide config files (usually in /etc), or install the config files to a shared directory (under /usr/share usually), where they can be copied into the user directory when first run.

santiago 2011-04-16 15:43

Re: how to add configuration file to debian package?
 
Quote:

Originally Posted by XenGi (Post 989900)
hi,

I'm developing an application with qt creator for n900.
In my app I need to save some stuff to a config file. This file should be located at "~/.myapp/config.xml".
Creating and editing the file at runtime is no problem but how do I add it to the debian package so that it will be installed along with the binary?
That should be the standard way in debian, should it?

I search google and found many stuff regarding debian packaging but I'm didn't find a suitable answer.

use the postinst file ;)
u can create a config to write or u can move a config file after the installation directly using the postinst file to add at the DEBIAN folder ;)

XenGi 2011-04-16 15:58

Re: how to add configuration file to debian package?
 
So in my postinst.ex file I have now the following code:

Code:

[...]
case "$1" in
    configure)
        mkdir -p /etc/myapp/
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" > /etc/myapp/config.xml
        echo "<root>" >> /etc/myapp/config.xml
        echo "</root>" >> /etc/myapp/config.xml
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac
[...]

And that in my postrm.ex file:

Code:

case "$1" in
    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
        rm -r /etc/myapp/
    ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

Is that correct? I haven't tested it.

santiago 2011-04-16 16:04

Re: how to add configuration file to debian package?
 
Quote:

Originally Posted by XenGi (Post 989956)
So in my postinst.ex file I have now the following code:

Code:

[...]
case "$1" in
    configure)
        mkdir -p /etc/myapp/
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" > /etc/myapp/config.xml
        echo "<root>" >> /etc/myapp/config.xml
        echo "</root>" >> /etc/myapp/config.xml
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac
[...]

And that in my postrm.ex file:

Code:

case "$1" in
    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
        rm -r /etc/myapp/
    ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

Is that correct? I haven't tested it.

i think u gotta use /myapp without / at the end

XenGi 2011-04-16 16:37

Re: how to add configuration file to debian package?
 
Something doesn't work. The directory and file under /etc isn't created when I test my project in qt creator.

Also when I edit the files in the myapp-build-maemo/debian directory nothing happens.

santiago 2011-04-16 16:40

Re: how to add configuration file to debian package?
 
try then with

sudo mkdir or become a root first

XenGi 2011-04-16 16:45

Re: how to add configuration file to debian package?
 
Quote:

Originally Posted by santiago (Post 989983)
try then with

sudo mkdir or become a root first

This should be done automatically because qt creator launches dpkg remotely on the device.

Rob1n 2011-04-16 21:49

Re: how to add configuration file to debian package?
 
Quote:

Originally Posted by XenGi (Post 989956)
So in my postinst.ex file I have now the following code

postinst.ex is the example file isn't it? Have you actually renamed it to myapp.postinst?

XenGi 2011-04-16 22:02

Re: how to add configuration file to debian package?
 
ok. now I've renamed them, but it still does not work.
No /etc/myapp folder.


All times are GMT. The time now is 16:31.

vBulletin® Version 3.8.8