Pages

Wednesday, 14 October 2009

Debian packaging: Changing permissions and ownership of dirs

Regarding creating users and permissions our beloved Debian Policy [chap. 10.9] tells us:
...you must arrange for your package to create the user or group if necessary using adduser in the preinst or postinst script (again, the latter is to be preferred if it is possible).

I wanted to stick to the postinst since it's preferrable so I couldn't change the permissions in the rules file.

Now the thing is I need to give this user permissions for the dirs it will need to own/write and so on. I already have the dirs listed in debian/dirs and I don't want to hardcode anything else in the rules or in the postinst. Of course not being a so experienced debian devel I started to google but didn't find anything... asked around but nothing yet... so I hacked it in this way in the end:
debian/rules:
...
MYDIRS := $(shell cat $(CURDIR)/debian/dirs)
SUBME := $(foreach dir, $(MYDIRS), chown -R \$$the_user $(dir);)
SUBFRIENDLY := $(shell echo "$(SUBME)" | sed -e 's/\//\\\//g')
...
binary-indep: build install
...
dh_installdeb
sed -i -e 's/PLACEHOLDER/$(SUBFRIENDLY)/' $(DESTDIR)/DEBIAN/postinst
...
...

debian/postinst:
...
configure)
the_user="xyz"
#Creating the user if it does not exist
if ! getent passwd $the_user > /dev/null; then
adduser $the_user
fi

#Changing the permissions for the given dirs
PLACEHOLDER
...


(user=xyz can be easily changed to numeric ID)

I don't know if this is the 'standard' way to do it (nor if there is a standard way) but it's at least a way that worked... If anybody there can give me an hint on how to do it better, it would be really appreciated.

Friday, 2 October 2009

N900 and TV-out: I just love it


After I read the post of Urho about Wiimote+DrNokSnes+TVout I couldn't help trying it out right away (except the Wiimote thing that I don't have). That was a funny jump back in time to when I was young and passed the evenings at a friend's apartment trying to finish the (amazing at that time) Super Mario bros on the NES (I didn't have a NES myself).

Besides that I tried out for the first time in these months the TV-out. I never realized it was so amazing... after having that strange cable packed on my desk for a whole 2 months I got to really use it. And, even if at first it was just to play Mario, I realized that the N900 it's a full blown audio/video player that supports a lot of formats. So I just started to watch a TV show on the bus, arrived home and plugged it into the TV and finished watching the show there.

I mean it's amazing! 180 grams plus a cable and you have a multimedia station with 32G storage on board. I've been thinking to get some kind of media box lately... well I think I found it... it was in my pocket the whole time.