Active Topics

 



Notices


Reply
Thread Tools
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#31
Originally Posted by BrentDC View Post
Whoa, $HOME is being interpreted as /root/ instead of /home/user/. I'm no bash expect, but something isn't right there...

I'll look into it.
$HOME` == /root because dpkg will run the package's install scripts as root.
 

The Following 2 Users Say Thank You to qwerty12 For This Useful Post:
BrentDC's Avatar
Posts: 903 | Thanked: 632 times | Joined on Apr 2008
#32
Originally Posted by qwerty12 View Post
$HOME` == /root because dpkg will run the package's install scripts as root.
I see (although I still think it's strange it worked on some devices). What would be the correct way to get the user's home directory from a script run as root?

Thanks.
__________________
-Brent

Author of TouchSearch -- web searching software for Maemo 5.

Mobile Device lineage: Palm Z22 -> Palm TX -> Nokia N800 -> Nokia N900
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#33
Originally Posted by BrentDC View Post
What would be the correct way to get the user's home directory from a script run as root?
Unfortunately, I'm not sure that there is one (I certainly do not know of a method of getting it cleanly anyway, perhaps someone else does?). The thing is, preinst scripts aren't really meant to install files to ~ - dpkg is, as you'll know, from Debian which can be used with multiple users (I know, doesn't sound like a feature but look at Windows 95/98/ME to understand...) and, in that world, installing files to one person's ~ isn't correct - what if a user, with a new account made after installing such a program wants use a program that relies on that method of installing files?

But, anyway, sorry for the mini-rant above (it's not intended as one! ). I hardcode "/home/user" because this is Maemo which is ever unlikely to see apps, desktop, etc running as a different account.

I can't remember which package demonstrates this but Nokia have a way of checking for scratchbox (think it's along the lines of "if [ -e /scratchbox/tools/config ]", something like that), if that scratchbox check proves true, you may wish to do something along the lines of: "for userz in `ls /home`; do cp whatever /home/$userz; done" etc. (with the caveat that this only works for already added users, not for users that'll be added later like above).

You may just want to do "if not os.path.exists" from your python application, upon its first run, and just copy the files if not existing from that. That'll be pretty much universal as you can get the correct $HOME etc.

Last edited by qwerty12; 2009-06-03 at 14:27.
 

The Following 2 Users Say Thank You to qwerty12 For This Useful Post:
Posts: 542 | Thanked: 117 times | Joined on Sep 2008 @ 52 N, 6 E
#34
Code:
pocketpenguin:~# apt-get install quickclip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  quickclip
0 upgraded, 1 newly installed, 0 to remove and 38 not upgraded.
Need to get 43.6kB of archives.
After unpacking 315kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  quickclip
Install these packages without verification [y/N]? y
Get:1 http://repository.maemo.org diablo/free quickclip 0.4.4-2 [43.6kB]
Fetched 43.6kB in 0s (60.4kB/s)
(Reading database ... 19023 files and directories currently installed.)
Unpacking quickclip (from .../quickclip_0.4.4-2_all.deb) ...
mkdir: cannot create directory '/root/MyDocs/Quick_Clip/': No such file or directory
Setting up quickclip (0.4.4-2) ...
chown: /root/MyDocs/Quick_Clip/: No such file or directory
Cache file created successfully.
still not working yet after reboot ....

Last edited by skatebiker; 2009-06-03 at 10:22.
 
BrentDC's Avatar
Posts: 903 | Thanked: 632 times | Joined on Apr 2008
#35
Originally Posted by qwerty12 View Post
Unfortunately, I'm not sure that there is one (I certainly do not know of a method of getting it cleanly anyway, perhaps someone else does?). The thing is, preinst scripts aren't really meant to install files to ~ - dpkg is, as you'll know, from Debian which can be used with multiple users (I know, doesn't sound like a feature but look at Windows 95/98/ME to understand...) and, in that world, installing files to one person's ~ isn't correct - what if a user, with a new account made after installing such a program wants use a program that relies on that method of installing files?

But, anyway, sorry for the mini-rant above (it's not intended as one! ). I hardcode "/home/user" because this is Maemo which is ever unlikely to see apps, desktop, etc running as a different account.

I can't remember which package demonstrates this but Nokia have a way of checking for scratchbox (think it's along the lines of "if [ -e /scratchbox/tools/config ]", something like that), if that scratchbox check proves true, you may wish to do something along the lines of: "for userz in `ls /home`; do cp whatever /home/$userz; done" etc. (with the caveat that this only works for already added users, not for users that'll be added later like above).

You may just want to do "if not os.path.exists" from your python application, upon its first run, and just copy the files if not existing from that. That'll be pretty much universal as you can get the correct $HOME etc.
Oh, please keep ranting, that was very interesting!

I already do the if not os.path.exists checks at application startup to ensure the proper files are in place, just liked using pre/post install scripts to get things running from the get-go.

I now understand this is a very sloppy way to do things, and will not try to create any user-owned directories or files during application installation.

Based on what you just said I did a bit of Googling and came across this topic at StackOverflow:

http://stackoverflow.com/questions/5...-account-linux

...and that pretty much confirms everything you've said. In addition, the poster there seemed to think using "sudo echo $HOME" would result in the correct directory being printed. This might explain why this worked fine on my device but not others (the different ways to get root? that was my initial hunch).

Thanks for the tips!
__________________
-Brent

Author of TouchSearch -- web searching software for Maemo 5.

Mobile Device lineage: Palm Z22 -> Palm TX -> Nokia N800 -> Nokia N900
 

The Following User Says Thank You to BrentDC For This Useful Post:
BrentDC's Avatar
Posts: 903 | Thanked: 632 times | Joined on Apr 2008
#36
Originally Posted by skatebiker View Post
Code:
pocketpenguin:~# apt-get install quickclip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  quickclip
0 upgraded, 1 newly installed, 0 to remove and 38 not upgraded.
Need to get 43.6kB of archives.
After unpacking 315kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  quickclip
Install these packages without verification [y/N]? y
Get:1 http://repository.maemo.org diablo/free quickclip 0.4.4-2 [43.6kB]
Fetched 43.6kB in 0s (60.4kB/s)
(Reading database ... 19023 files and directories currently installed.)
Unpacking quickclip (from .../quickclip_0.4.4-2_all.deb) ...
mkdir: cannot create directory '/root/MyDocs/Quick_Clip/': No such file or directory
Setting up quickclip (0.4.4-2) ...
chown: /root/MyDocs/Quick_Clip/: No such file or directory
Cache file created successfully.
still not working yet after reboot ....
I will be updated the package soon; hang in there.
__________________
-Brent

Author of TouchSearch -- web searching software for Maemo 5.

Mobile Device lineage: Palm Z22 -> Palm TX -> Nokia N800 -> Nokia N900
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#37
Originally Posted by BrentDC View Post
In addition, the poster there seemed to think using "sudo echo $HOME" would result in the correct directory being printed. This might explain why this worked fine on my device but not others (the different ways to get root? that was my initial hunch).
I believe this is because sudo does not inherit root's environment by default and continues to use the env. variables of the user it was invoked with.

AFAIK, the application manager uses a helper process (apt-worker) which uses sudo for its root ability and possibly does not inherit root environment variables either and runs dpkg with $HOME = /home/user - but I'm only sure on the apt-worker and sudo part, not sure about variable inheriting here.
 

The Following 2 Users Say Thank You to qwerty12 For This Useful Post:
BrentDC's Avatar
Posts: 903 | Thanked: 632 times | Joined on Apr 2008
#38
skatebiker:

I just built a test version. Do you mind testing it out? It's attached to this post.
Attached Files
File Type: deb quickclip_0.4.4-3_all.deb (42.4 KB, 120 views)
__________________
-Brent

Author of TouchSearch -- web searching software for Maemo 5.

Mobile Device lineage: Palm Z22 -> Palm TX -> Nokia N800 -> Nokia N900
 
BrentDC's Avatar
Posts: 903 | Thanked: 632 times | Joined on Apr 2008
#39
Hi all!

I just uploaded 0.4.4-3 to Diablo/Chinook/Fremantle extras-devel. It fixes the installation problems related to the discussion above and uses a patch by qwerty12 (to use Hildon Filechooser instead of GTK).

Test away!

P.S. The next release should have some cool new features instead of just boring bug fixes!
__________________
-Brent

Author of TouchSearch -- web searching software for Maemo 5.

Mobile Device lineage: Palm Z22 -> Palm TX -> Nokia N800 -> Nokia N900
 

The Following 2 Users Say Thank You to BrentDC For This Useful Post:
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#40
Originally Posted by qwerty12 View Post
The thing is, preinst scripts aren't really meant to install files to ~ - dpkg is, as you'll know, from Debian which can be used with multiple users (I know, doesn't sound like a feature but look at Windows 95/98/ME to understand...) and, in that world, installing files to one person's ~ isn't correct - what if a user, with a new account made after installing such a program wants use a program that relies on that method of installing files?
Here's a suggestion: The "clean" way would probably be to install any "default config" files somewhere below /usr/share/<appname>/ and then on application startup check if the files in ~ exist, and if not, copy them from /usr/share/<appname>/. This way, the package can "manage" and "upgrade" the template files in /usr/share/<appname>/ without disrupting the user's (potentially modified) config in ~. And if the files are not meant to be modified, they should go into /usr/, anyway

(btw: Quick Clip works great for me so far )
 

The Following 3 Users Say Thank You to thp For This Useful Post:
Reply

Tags
development, python, quick clip


 
Forum Jump


All times are GMT. The time now is 05:34.