How can I ignore files/directories when building debian packages?

12,377

Solution 1

My understanding is that you should not be building a debian package with dpkg-deb --build in the first place. If you use dpkg-buildpackage instead, you won't have to worry about .svn directories being included in your package.

See: http://raphaelhertzog.com/2010/12/17/do-not-build-a-debian-package-with-dpkg-b/

There may be a better method, but here's one I haven't thoroughly tested:

Use dh_make to create a skeleton debian package. Put your files in the directory above the debian directory.

edit the resulting dirs file, and put the paths you are going to move files into, eg:

/opt/mypackage
/usr/local/bin

Then in your rules file, remove the $(MAKE) code and set your install: build section to something like this:

install: build
  dh_testdir
  dh_testroot
  dh_clean -k 
  dh_installdirs

  # Copy files into staging area
  rsync --exclude .svn -a mypackage/ debian/tmp/opt/mypackage/

Solution 2

To exclude files to be put in the source Debian package, you should create the file:

debian/source/options

and enter the options you want to pass to dpkg-source, in your case:

tar-ignore = ".svn/"

See the man page for dpkg-source.

Solution 3

It's worth documenting here that if you're going to use dpkg-buildpackage that it has a -i switch to ignore things. i.e., use -i .svn to ignore the .svn directory.

Share:
12,377

Related videos on Youtube

Thiago Padilha
Author by

Thiago Padilha

computer programmer messing arround with .net/java technologies mostly.

Updated on September 17, 2022

Comments

  • Thiago Padilha
    Thiago Padilha over 1 year

    I have made some debian packages to ease deployment of configurations on new servers and want to put them in SVN source control. The problem is that SVN creates a .svn directory for each subdirectory in the source tree, so I can't build packages on the source tree 'dpkg-deb --build ' because the '.svn' directories will be included in the resulting package. So far when I want to build a package I have to export the directory to a different place and build from there.

    Is there a quick way to making 'dpkg-deb --build' ignore the .svn directories?

  • Franklin Piat
    Franklin Piat almost 9 years
    Note: this is "old school" debhelper. Since debhelper has migrated to dh $@ and the new targets like override_dh_auto_build-indep
  • chrishiestand
    chrishiestand over 8 years
    @FranklinPiat is correct
  • Bruno Bronosky
    Bruno Bronosky over 6 years
    That blog post you linked to basically says, "don't use dpkg -b, instead spend the next 4 hours studying debian.org/doc/manuals/maint-guide" Where's the helloworld version?
  • Alexis Wilke
    Alexis Wilke almost 5 years
    This is slightly wrong. Using ".svn/*" the ".svn" folder is going to be included, still. You should just use ".svn". Also if you need to exclude multiple folders (say "tmp" as well) write one line per exclusion.