Reply
Thread Tools
Posts: 299 | Thanked: 241 times | Joined on Oct 2009 @ Singapore
#1
Hi!

I have an app that installs a SQLITE .db file. The .db file is included in my installation package, but on the device it will have permissions set to 644. When I run my app, I hit errors that the database is read only. When I do root + chmod 666 on the .db file, the app will work just fine again. How do I modify the permissions from the outset? I obviously don't want all my users to have to do chmod manually. I even try to change the permissions in code using the Qt setPermissions method, but that didn't to do the work either...

I sort of expect to change something like this:

Code:
INSTALLS    += db
db.path  = /home/user
db.files  = data/qsportsevent.db
db.permissions = 666
Thanks
__________________
My Maemo Apps:
QTeachMe
- Flashcard app
MobiTifo (which was formerly known as QSportsEvent) - Sports leagues tracking (mainly football).
 
Posts: 318 | Thanked: 735 times | Joined on Oct 2009
#2
You better use the postinst script to modify the permission.
 
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#3
From what I've read, debian packages install with the same permissions as when packaged, so try changing the permissions on the file prior to packaging.
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#4
Originally Posted by Rob1n View Post
From what I've read, debian packages install with the same permissions as when packaged, so try changing the permissions on the file prior to packaging.
Some permissions get "fixed" during install.
The debian/rules file includes the call to dh_fixperms.

nicolai
 
Posts: 299 | Thanked: 241 times | Joined on Oct 2009 @ Singapore
#5
Originally Posted by Rob1n View Post
From what I've read, debian packages install with the same permissions as when packaged, so try changing the permissions on the file prior to packaging.
I see. Didn't think that would work as I am on Windows, but maybe I can change permissions in MADDE? I'll try when I get access to my system again.
__________________
My Maemo Apps:
QTeachMe
- Flashcard app
MobiTifo (which was formerly known as QSportsEvent) - Sports leagues tracking (mainly football).
 
Posts: 299 | Thanked: 241 times | Joined on Oct 2009 @ Singapore
#6
Originally Posted by b0unc3 View Post
You better use the postinst script to modify the permission.
Ok, postinst seems to be the way to go...

Would this be the way to do it?

Code:
#!/bin/sh
# postinst script for qsportsevent
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    configure) chmod 666 /home/user/qsportsevent.db
    ;;

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

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

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
__________________
My Maemo Apps:
QTeachMe
- Flashcard app
MobiTifo (which was formerly known as QSportsEvent) - Sports leagues tracking (mainly football).
 
Posts: 318 | Thanked: 735 times | Joined on Oct 2009
#7
Use the KISS phylosophy, something like that should do the work:
Code:
#!/bin/sh

chmod 666 /path/to/file.db

exit 0
 

The Following User Says Thank You to b0unc3 For This Useful Post:
Posts: 299 | Thanked: 241 times | Joined on Oct 2009 @ Singapore
#8
Originally Posted by b0unc3 View Post
Use the KISS phylosophy, something like that should do the work:
Code:
#!/bin/sh

chmod 666 /path/to/file.db

exit 0
Well... I've now updated my postinst.ex file accordingly, but my .db is still 644. How do I make sure that the file is actually executed? I'm really quite new to this whole packaging stuff...
__________________
My Maemo Apps:
QTeachMe
- Flashcard app
MobiTifo (which was formerly known as QSportsEvent) - Sports leagues tracking (mainly football).
 
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#9
On a tangential note I'd say it's not the best to place application resources directly in the user's home directory.

/home/user/qsportsevent.db would be better in, for example, /home/user/.qsportsevent/qsportsevent.db . This reduces clutter and makes it easier to do a good cleanup, without risking other applications, if that's asked for.
 

The Following User Says Thank You to Joorin For This Useful Post:
Posts: 299 | Thanked: 241 times | Joined on Oct 2009 @ Singapore
#10
Originally Posted by Joorin View Post
On a tangential note I'd say it's not the best to place application resources directly in the user's home directory.
Yeah... I sort of knew it was not the best location but did not yet look into where it should be instead. Thanks for the reminder!

Back to my problem. In the 'sample' postinst.ex file, there is a 'set -e' statement at the beginning of the file. Is that significant? I'll try using it anyway...
__________________
My Maemo Apps:
QTeachMe
- Flashcard app
MobiTifo (which was formerly known as QSportsEvent) - Sports leagues tracking (mainly football).
 
Reply


 
Forum Jump


All times are GMT. The time now is 20:21.