Search code examples
pythondistutilssetup.pydeb

Point to the true home directory in .deb package


I have my woking setup.py file; which contain the following line :

home = os.environ["HOME"]   # home =  /home/dr in my machine; 
distutils.core.setup(
... 
data_files=  [  ('%s/.config/autostart'%home,['data/RockDome-autostart.desktop']),      
               ("%s/.gnome2/nautilus-scripts"%home , ['data/Add to RockDome'])  ,
             ]

Now I proceed to create .deb packge by dpkg-buildpackage -i -I -rfakeroot; all are true except that the resulted .deb package has the following hirreracy:

.deb
    / ... other paths 
    /home
         /dr
            /.gnome2
                   /nautilus-scripts
                                    /Add to RockDome
            /.config
                    /autostart
                              /RockDome-autostart.desktop

As you see; the .deb will install some files to the path:

/home/dr/.gnome2/nautilus-scripts/Add to RockDome

/home/dr/.config/autostart/RockDome-autostart.desktop

this paths isn't correct except in my machine; in other machinesit will create that dirs outside the home dir of the user!!


Solution

  • Debian packages should not install files to users' home directories. These files should be installed to the appropriate system-wide locations if possible; if this isn't an option, a postinstall helper script could put them in place for each user. (Keep in mind that there may be more than one user on a system!)