5

I build a package from my own source using dh_make and dpkg-buildpackage. The install-file in /debian specifies the destinations for the project files. To make the installed program work, they need to be executable / have execution permissions with chmod. In particular it is about a python script and a .desktop-file.

How do I set those permissions in setup? By only copying them to their destinations it is not done. It would be ok for me if I could trigger a command at the end of setup, or something like this, but don't know how to include this.

Braiam
  • 67,791
  • 32
  • 179
  • 269
user2366975
  • 717
  • 1
  • 10
  • 19

2 Answers2

7

You could create a post installation script:

gedit debian/packagename.postinst

This is just a normal script, so the following instructions will do:

#!/bin/sh
set -e
chmod 755 /path/to/pythonscript.py
exit 0

Alternatively, you could exclude the file from having its permissions altered by dh_fixperms. This can be done within debian/rules:

%:
    dh  $@ --with python2

override_dh_fixperms:
    dh_fixperms --exclude path/to/pythonscript.py

The first option is preferable because dh_fixperms does other useful things like changing the owner of a file, and excluding the file prevents dh_fixperms from doing anything useful. Also note that in the first option, there is a preceding slash /path/to/pythonscript.py as it is an absolute path, whereas the second option is relative to the debian subdirectory.

EDIT: @AlexisWilke has mentioned a better alternative for option 2, that is:

%:
    dh  $@ --with python2

override_dh_fixperms:
    dh_fixperms
    chmod 755 path/to/pythonscript.py

This allows dh_fixperms to work its magic followed by the minor necessary fix.

muru
  • 197,895
  • 55
  • 485
  • 740
Charlie
  • 213
  • Couldn't we do dh_fixperms first, the a chmod a+x path/to/pythonscript.py? — because that way dh_fixperms does everything right as per debian and then you fix a few more things your way. Correct? – Alexis Wilke Dec 21 '15 at 11:47
  • Yes, I think you are right, modified answer to suit. – Charlie Dec 22 '15 at 07:27
2

The .desktop file doesn't need execution permissions, your .py script does.

braiam@bt:~$ ls -l /usr/share/app-install/desktop/deluge.desktop 
-rw-r--r--. 1 root root 1276 Aug  6  2012 /usr/share/app-install/desktop/deluge.desktop
braiam@bt:~$ ls -l /usr/bin/deluge
-rwxr-xr-x 1 root root 289 Jan 27  2013 /usr/bin/deluge

You should before packaging have set the executable bit on the python script, that dpkg will take care of the rest.

The .desktop file is a configuration file read by xdg, and has it own variables set to execute the needed binary:

cat /usr/share/app-install/desktop/deluge.desktop
[...]
GenericName=BitTorrent Client
X-GNOME-FullName=Deluge BitTorrent Client
Comment=Download and share files over BitTorrent
Exec=deluge-gtk %U
Icon=deluge
Terminal=false
Type=Application
Categories=Network;FileTransfer;P2P;GTK
StartupNotify=true
MimeType=application/x-bittorrent;x-scheme-handler/magnet;

As you wan see it has a Exec variable that takes care of the execution when the file is accessed.

Braiam
  • 67,791
  • 32
  • 179
  • 269