jl6
jl6

Reputation: 6394

Should a source code repository be laid out to match the .deb build directory structure?

I have an existing git repo containing files that I want to package in a .deb. At the moment, my source code is largely located in one flat directory, and I have a build script that copies relevant files into a Debian package build directory. e.g.

myapp.conf
myexecutable

after running build.sh I get:

./build/etc/myapp.conf
./build/usr/bin/myexecutable

and then I build this directory into my .deb.

But can I just cut out this intermediate copying step by maintaining all my source code in a directory structure that mirrors the .deb build directory structure? What are the downsides?

Upvotes: 3

Views: 146

Answers (1)

Sigi
Sigi

Reputation: 1864

I assume you are the mainainer of the software in question.

What you want to do, is to add a debian/ directory to the top level of your package, and create the Debian package files in there. There is a tool for that (dh_make, from the dh-make package).

Use dh_make to create a "Debian native package". "Native" in this context means that the maintainer of the software and the maintainer of the Debian package are the same person (you), as opposed to you packaging someone else's software.

Change into your source directory, and run dh_make -n, then answer the questions on the command line. Afterwards, change into the debian/ directory that has been created and edit the various files. Remove the example files that you don't need (chances are you won't need most of them).

If your project uses make, and you use standard make targets, chances are you won't have much work to do after that. The Debian toolchain is pretty smart about figuring things out for you.

If you use Git for source code management, you should install git-buildpackage and use that for building your packages and making releases. Refer to its documentation.

Your package directory structure should not have to change at all – only the debian/ directory will be added. Debian packages are always build from a "Debian source package", which is the source tree of the software, plus the debian/ directory (and possibly patches, which does not apply in your case since you control the upstream source).

Upvotes: 1

Related Questions