Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debian rules file make a symlink

I'm creating a small deb package to install a few files. Some of them will be located in /usr/lib/mypackage/ and I want to create a symlink from /usr/lib/mypackage/mybin to /usr/bin/mybin

For the /usr/lib/mypackage folder I'm using mypackage.install and copy the files over there. This seems to work fine.

However, in order to create my symlink I understand I need to use the debian rules file in there, and I'm not sure how to proceed, here is the line I need to add, where should it be added and how? Thanks

ln -s /usr/lib/mypackage/mybin /usr/bin/mybin
like image 381
Loic Duros Avatar asked Apr 01 '12 15:04

Loic Duros


1 Answers

The best way is to use dh_link, part of the debhelper suite. See man dh_link for details of its operation. As you can see from that, that you probably want something like the following in a file called debian/$mypackage.links:

/usr/lib/mypackage/mybin  /usr/bin/mybin

Where you should put dh_link in your debian/rules, if it's not already there, depends on how you're making your package. If you're using Debhelper, then your debian/rules probably already has dh_link taken care of (although if you're using classic Debhelper, then the dh_link line might be commented out, and you need to uncomment it). Using newer-style Debhelper (dh) or CDBS-plus-debhelper (include /usr/share/cdbs/1/rules/debhelper.mk) also count here; they'll take care of dh_link for you.

But if you're not using Debhelper, and you don't want to start, then dh_link probably isn't an option. In that case, you just need to make sure that you conform to Debian Policy on the subject (meaning your symlink there should be relative, not absolute). You'd probably want to make the link in your debian/rules's build target. Example:

build:
    # ... other stuff ...
    mkdir -p debian/$mypackage/usr/bin
    ln -s ../lib/mypackage/mybin debian/$mypackage/usr/bin/mybin
like image 60
the paul Avatar answered Sep 28 '22 21:09

the paul