Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


      chmod +x $(TARGET)

      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?

share|improve this question
up vote 2 down vote accepted

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:

    # ensure the destination directory exists
    mkdir -p $(DESTDIR)/usr/bin
    # copy the program to its final destination
    # 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.

share|improve this answer
Why not fold the use of install into your example (and remove the cp)? – jmtd Jun 24 '11 at 15:11
Thanks for your help. :) – SammySP Jun 24 '11 at 19:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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