I'm trying to build a debian package for a program that uses mono. My make install target currently puts all of my binaries /usr/local/lib/mypackage, then creates a tiny executable script in /usr/local/bin that invokes the actual binaries with mono. I use a one-liner to replace the placeholder PREFIX with the actual install path:

install: DESTDIR=/usr/local
install: LIBDIR=$(DESTDIR)/lib
install: BINDIR=$(DESTDIR)/bin
install: $(PHONIX) $(ANTLR) doc
    install -m 0755 -d $(LIBDIR)/phonix
    install -m 0755 -t $(LIBDIR)/phonix $(PHONIX) $(ANTLER)
    install -m 0755 -D phonix.sh $(BINDIR)/phonix
    sed -i "s!PREFIX!$(LIBDIR)!" $(BINDIR)/phonix

When I'm running under dh_make, $(LIBDIR) and $(BINDIR) point to the packaging directory as desired. Everything gets installed into the right place for the packager, but the sed call puts the path of my local packaging directory into the script, which then gets placed verbatim in the package. This obviously doesn't work once I actually install the package on the target system.

I think that I need to move the sed call into the post-install script, but I'm not sure how to get the local install directory (the moral equivalent of my $(LIBDIR) and $(BINDIR)) in the post-install step. Or is there a better way altogether to do this?

Edit: Here's my actual phonix.sh file, before sed is called:


exec mono PREFIX/phonix.exe

As you can see, the only purpose of this file is to provide an executable wrapper for the mono-based .exe. The sed call just replaces PREFIX with the value of $(LIBDIR). So all I really need to know is how can I get the actual installed location of my .exe on the target system so that the wrapper script works?

  • Is your debian package going to put files in /usr/local/bin? If so, it shouldn't. – Faheem Mitha Apr 21 '11 at 13:54
  • @Faheem, well my make install puts them in /usr/local/bin. When I run dh_make it puts them in $(DESTDIR)/bin, which I believe means they'll actually go in /usr/bin when the .deb is installed. I could be wrong about this -- I've never built a .deb file before. – JSBձոգչ Apr 21 '11 at 14:04
  • Can you explain what your sed call is doing? If it is rewriting your script after installation it is a bad idea. Why do you need to do that? What is this PREFIX for? Are you writing a rules file and using debhelper? You should set your variables in the rules file. You are reading the packaging documentation, right? – Faheem Mitha Apr 21 '11 at 14:38
  • @Faheem, Yes to all of your questions, for better or worse. I've edited the question with my actual .sh file, which hopefully clears things up. – JSBձոգչ Apr 21 '11 at 15:00
  • I'm not sure why PREFIX is required at all. The usual way these things work is exec mono phonix.exe and mono looks in a standard location for phonix. Disclaimer: I don't know a thing about mono. – Faheem Mitha Apr 21 '11 at 15:26

You are using DESTDIR in a nonstandard way. It is not the installation prefix of your package, it's the "fakeroot" prefix for things such as package builds.

The more typical way to write this is something like this:

prefix = /usr/local
bindir = $(prefix)/bin
libdir = $(prefix)/lib

install: $(PHONIX) $(ANTLR) doc
    install -m 0755 -d $(DESTDIR)$(libdir)/phonix
    install -m 0755 -t $(DESTDIR)$(libdir)/phonix $(PHONIX) $(ANTLER)
    install -m 0755 -D phonix.sh $(DESTDIR)$(bindir)/phonix
    sed -i "s!PREFIX!$(libdir)!" $(DESTDIR)$(bindir)/phonix

Leave DESTDIR empty in the makefile of your package. It should be set in debian/rules or automatically by dh or cdbs. I guess from your question that it does get set somehow.

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.