Reply
Thread Tools
Guest | Posts: n/a | Thanked: 0 times | Joined on
#1
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.
 
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#2
Originally Posted by XenGi View Post
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.
 

The Following User Says Thank You to Rob1n For This Useful Post:
santiago's Avatar
Posts: 518 | Thanked: 334 times | Joined on Mar 2010 @ italy
#3
Originally Posted by XenGi View Post
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
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#4
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's Avatar
Posts: 518 | Thanked: 334 times | Joined on Mar 2010 @ italy
#5
Originally Posted by XenGi View Post
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
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#6
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's Avatar
Posts: 518 | Thanked: 334 times | Joined on Mar 2010 @ italy
#7
try then with

sudo mkdir or become a root first
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#8
Originally Posted by santiago View Post
try then with

sudo mkdir or become a root first
This should be done automatically because qt creator launches dpkg remotely on the device.
 
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#9
Originally Posted by XenGi View Post
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?
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#10
ok. now I've renamed them, but it still does not work.
No /etc/myapp folder.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 06:48.