2

I have been recently trying to package a small Python utility to put on my PPA and I've almost got it to work, but I'm having problems in making the package install the binary (a chmod +x Python script) under /usr/bin. Instead it installs under /. I have this directory structure -> http://db.tt/0KhIYQL.

My package Makefile is like so:

TARGET=usr/bin/txtrevise

make:
      chmod +x $(TARGET)

install:
      cp -r $(TARGET) $(DESTDIR)

I've used $(DESTDIR), as I understand it to place the file under the debian subdir when debuild is run.

I have the txtrevise script, my executable, under usr/bin folder under the root of my package. I also have the Makefile and usr/bin/textrevise in my tarball: txtrevise_1.1.original.tar.gz.

However when I build this and look inside of the Debian package, txtrevise is always at the root of the package instead of under usr/bin and will be installed to / instead of /usr/bin.

How can I get debuild to put the script in the right place?

2

The problem is in the cp $(TARGET) $(DESTDIR) invocation: this will copy the file textrevise under directory $(DESTDIR), i.e. skips the /usr/bin prefix. You need to preserve the directory structure, so for instance:

install:
    # ensure the destination directory exists
    mkdir -p $(DESTDIR)/usr/bin
    # copy the program to its final destination
    cp $(TARGET) $(DESTDIR)/$(TARGET)
    # ensure the program and directories have the correct permissions
    chmod a+rx $(DESTDIR)/$(TARGET)

Note that you must also ensure, when building a software package for others to use, that the permissions an all directories and binaries are set according to the Debian policy; in this case you want $(DESTDIR)/usr/bin/textrevise to be owned by root:root and mode 0755 (and so the directories $(DESTDIR)/usr and $(DESTDIR)/usr/bin).

You might want to have a look at the install command, that gives you more control over the owner, group and mode of the installed files to write more concise Makefile stanzas.

  • 1
    Why not fold the use of install into your example (and remove the cp)? – jmtd Jun 24 '11 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.