Page 1 of 1

Issues with the 'find' command and packages

Posted: Sun Feb 15, 2009 11:17 am
by Stevo14
In order to make "installation" of my OS into a disk image simpler, I've decided to make a little package system. Basically each component creates a tarball of itself which is unpacked in the root of my OS's file system.

I'm having problems building the tarball's so that they exclude .svn dir's. Mainly problems with the 'find' command. In my makefile I have the line:

Code: Select all

PKGFILES  := $(shell cd package && find -mindepth 1 \! \( -name '.svn' -prune \) -print)
which is supposed to find all the files in the package directory excluding anything related to svn. Later I have:

Code: Select all

dist: 
	@tar czf fluidium.pkg.tgz -C package $(PKGFILES) 
Which actually creates the package. The problem is that only the .svn directories in the first level are excluded. .svn directories in the second and third levels remain in the tarball. Would someone mind giving me a clue as to how to get the "\( -name '.svn' -prune \)" to apply to more than just the first level directory?

Also, for some reason this method makes it so that the first directory in the archive is simply ".". This really isn't a problem because it expands properly to "./*" when unpacked but it is an annoyance.

Re: Issues with the 'find' command and packages

Posted: Sun Feb 15, 2009 1:40 pm
by JamesM
Hi,

Haven't checked this solution, but this is what I'd do:

Code: Select all

PKGFILES  := $(shell cd package && find -mindepth 1 -print | grep -v ".svn")
Cheers,

James

Re: Issues with the 'find' command and packages

Posted: Sun Feb 15, 2009 9:28 pm
by Solar
Your find works mostly as intended, and excludes all .svn directories. (You can easily check this if you execute it stand-alone.)

Your problem is that it also includes directories - and that tar is recursive. Your find lists all files and directories, and tar includes those directories with all their contents - including .svn subdirectories...

You could add "-type f" to your find to exclude directories. Or you could simply:

Code: Select all

dist:
   @tar czf fluidium.pkg.tgz --exclude .svn -C package *

Re: Issues with the 'find' command and packages

Posted: Tue Feb 17, 2009 9:36 pm
by Stevo14
Solar, your second solution did what I wanted. I just realized that the answer was in the tar man pages all along... #-o

Well, thanks anyway for the help. :)