how to include a directory in the package debuild
A Q/D example utilizing dh* and dpkg-buildpackage:
1) Pepare working directory and test file (we are going to package "foo" script which should be installed to "/any/dir") :
mkdir test-0.0.1
cd test-0.0.1
echo -e "#\!/bin/sh\necho \"hi, i'm foo\"" > foo
chmod +x foo
2) Create simple Makefile which will handle installation:
binary:
# we are not going to build anything
install:
mkdir -p $(DESTDIR)/any/dir
cp foo $(DESTDIR)/any/dir
3) Generate package skeleton:
dh_make -i --createorig
3a) Optionally adjust debian control file
4) Build the package:
dpkg-buildpackage -A -uc
5) Test generated package contents:
dpkg-deb -c ../test_0.0.1-1_all.deb | grep any
drwxr-xr-x root/root 0 2012-06-12 20:54 ./any/
drwxr-xr-x root/root 0 2012-06-12 20:54 ./any/dir/
-rwxr-xr-x root/root 30 2012-06-12 20:54 ./any/dir/foo
Edit: Example without using Makefile (if you are not going to build anything):
1) Create test data:
mkdir test-0.0.1
cd test-0.0.1
mkdir contents
touch contents/a
touch contents/b
2) Create package skeleton:
dh_make -i --createorig
3) Create debian/test.install file with following contents:
contents/ /usr/share/mycontents
4) Build package:
dpkg-buildpackage -A -uc
5) Examine built package:
dpkg-deb -c ../test_0.0.1-1_all.deb | grep contents
drwxr-xr-x root/root 0 2012-06-13 11:44 ./usr/share/mycontents/
drwxr-xr-x root/root 0 2012-06-13 11:38 ./usr/share/mycontents/contents/
-rw-r--r-- root/root 0 2012-06-13 11:37 ./usr/share/mycontents/contents/a
-rw-r--r-- root/root 0 2012-06-13 11:38 ./usr/share/mycontents/contents/b
Conf files and static files in a deb package
As viraptor said you can put an install command for each file into your debian/rules
to install the files into the debian/pkgname directory.
Or you can use a debian/install
file to simply list all the files (or just directories) and have a dh_install command in your debian/rules
to do it for you.
It seems you are a little confused about how packages are built and which files are included. This is extremely generalized, but when the debian/rules
script compiles a program using standard ./configure && make && make install
method, it instructs the make install
to install the files to debian/pkgname
instead of /
. Then it knows that everything under debian/pkgname
is what should be in the final .deb. If the make install
step doesn't put everything in the correct location, then the debian/rules
script needs to do that. Previously it seems calling install ...
from debian/rules
to copy the files to the debian/pkgname
directory was common but now using a debian/install
file seems to be the preferred method.
I need my Debian rules file to simply copy files to it's target
Although you've already got your own answer, I'll point out a couple of things.
You seem to be doing this in a very complicated manner. If you simply need to copy files into certain directories, write a debian/mypackagename.install
with the following format:
path/to/file/relative/to/source/root path/to/install/relative/to/system/root
(do not prepend /
before /usr
, or /opt
, or whatever your target directory is. Read man dh_install
for more information)
Then your debian/rules
can be:
#!/usr/bin/make -f
%:
dh $@
If you have some sort of makefile, etc in your source root, then append this to the above rules
file:
override_dh_auto_build:
override_dh_auto_install:
Don't forget put 7
in debian/compat
.
Also, you shouldn't install files into /opt/
or /usr/local/
, etc. Those are meant for files not installed by Debian packages. Debian recommends installing in /usr/share/yourcompany/
. As juzzlin points out below, the Ubuntu Software Center may have different requirements.
More specifically, your mypackage.install
file should look like this:
src/bin/* usr/bin
src/etc/* etc/
Build debian package without .orig file
If you want to create a Debian directory directly in the source package (ie you're packaging your own work, rather than from an upstream release) you could use the --native
option to dh_make
Related Topics
Detecting If The Monitor Is Powered Off
How to Prevent Git from Committing Two Files with Names Differing Only in Case
How to Run Sh File from Another Sh File
Why Strace Shows Eagain (Resource Temporarily Unavailable)
How to Install G++ on Centos Without Root
How to Change Core Pattern Only for a Particular Application
Can "Text File Busy" Happen When Two Processes Trying to Execute a Perl File in The Same Time
Dlopen with Two Shared Libraries, Exporting Symbols
See What Process Last Touched a File
Detect When Reader Closes Named Pipe (Fifo)
Ld_Library_Path: How to Find a Shared Object
Inter-Module Communication in Linux Kernel
Does Anyone Know Where to Define The Hardware, Revision and Serial No. Fields of /Proc/Cpuinfo
Where Do You Send The Kernel Console on an Embedded System
Monitor/Audit File Delete on Linux
How to Print on Stderr with Swift