18

I have a python script that I want to package for Debian. I use a debian/install file where I wrote

auto_dice.py /usr/bin/

Linitan then complains about the .py extension (script-with-language-extension).

I then changed it to

auto_dice.py /usr/bin/autodice.py

which causes an error because it interpreted autodice.py as a directory.

How can I do the rename there? I do not want to rename my python script in the sources.

3 Answers 3

15

From Debian bug 245554 already mentioned:

this can already be easily solved if you use dh >= 9 and dh-exec. Just make your .install file executable, add #!/usr/bin/dh-exec to the top, and you can use "source => dest", like this:

#!/usr/bin/dh-exec
debian/default.conf => /etc/my-package/start.conf
1
  • This definitely is the best way. Not much to do really, just make sure you have dh-exec installed, enter the list of files to be installed with a different name, and also make sure that the install file is an executable (chmod a+x). Very easy! Nov 2, 2022 at 5:09
13

You cannot rename files using dh_install (via the debian/install). You will need to rename it during the debian/rules "build" target before you get to the dh_install invocation.

4
  • so it will be build: \\ mv auto_dice.py autodice? Apr 5, 2011 at 21:38
  • likely the mv would happen in the target directory rather than the build directory, but yeah, you'd have to add the move before calling dh_install.
    – Kees Cook
    Apr 7, 2011 at 1:39
  • For a bug report requesting this feature, see bugs.debian.org/cgi-bin/bugreport.cgi?bug=245554 Mar 21, 2012 at 19:39
  • @Kees Cook: if you rename it in the target directory - would apt-get still be able to remove the file after package removal/upgrading?
    – zerkms
    May 27, 2013 at 22:34
0

I wanted to specify that if the file to install is a folder, you can also rename it by using a pattern. This may not be self explanatory, so I thought it would be a good idea to have an example.

Say you have a configuration folder named source and you want to install it on target machines as destination. Your .install file would look like this:

path/to/source/*       path/to/destination/

This is rather simple, but you may not think about using the pattern when installing a whole folder.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .