Rameshwar Nagpure
Rameshwar Nagpure

Reputation: 174

Creating debian package on Ubuntu 12.04 LTS

Earlier I have created debian packages successfully, which were simple in their way. But now, I have to create the same for my application, which depends upon external packages. libwebkitgtk-1.0-0 and jdk1.7.0 are the external packages required. I want them to get installed automatically. Also my software have certain data, which needs to be stored in user's home directory.

Pls guide me on this.

Upvotes: 1

Views: 78

Answers (1)

tripleee
tripleee

Reputation: 189387

Your debian/control file needs to have a Depends: declaration for the other packages it needs. Apt will download and install them for you, dpkg will refuse to install unless they are installed.

Debian packages have no entry to users' home directories. Maybe create a wrapper which populates the user's home directory with a copy of /usr/share/yourpackage/config/* if the required files are missing.

#!/bin/sh
test -d $HOME/.yourpackage ||
    cp -r /usr/share/yourpackage/config $HOME/.yourpackage
exec /usr/lib/yourpackage/yourpackage.bin "$@"

So the real binary is in yourpackage.bin and this wrapper is /usr/bin/yourpackage.

For extra points, use environment variables so the paths are not completely hardcoded. Maybe more important for yourself (makes testing easier) than for your users, but keep the needs of both in mind.

(Hint: ${YOURPACKAGE_SITE_CONFIG-/usr/share/yourpackage/config} will expand to the value of $YOURPACKAGE_SITE_CONFIG if it is set, otherwise to /usr/share/yourpackage/config. You might want to do something similar for $YOURPACKAGE_CONFIG and $YOURPACKAGE_BIN to be able to run a simple test in your build directory with overrides for all three.)

Upvotes: 2

Related Questions