Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#194937 - 24/12/2003 13:39 linux question
image
old hand

Registered: 28/04/2002
Posts: 770
Loc: Los Angeles, CA
i want to compare two directories, and tar up any added or changed files/symlinks/devs between the original and the modified. any easy way to do this? i'm basically looking for the same method that roger did with his base.tar.gz pack, so i can implement the changes i've done to the root partition of my empeg to the new alpha.

Top
#194938 - 24/12/2003 14:23 Re: linux question [Re: image]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14496
Loc: Canada
I would write a small shell script for this.

The script should do "diff --brief --recursive olddir newdir" and then parse the output into pathnames, and feed that as a filelist into "xargs tar cvf newdir.tar"

The output of diff will be a bunch of lines that look like this:

Only in olddir: Makefile
Only in newdir: morejunk
Files olddir/README and newdir/README differ


The script will have to convert that into this:

newdir/morejunk
newdir/README


Cheers



Top
#194939 - 25/12/2003 09:53 Re: linux question [Re: mlord]
image
old hand

Registered: 28/04/2002
Posts: 770
Loc: Los Angeles, CA
yeah, i figured that much. time to see how xargs works.

Top
#194940 - 25/12/2003 11:42 Re: linux question [Re: image]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14496
Loc: Canada
xargs is trivial, thank goodness. It just takes a series of pathnames (filenames), one per line on stdin, and appends them to the command line you supply as arguments. As in this example, which you can try out:

ls -1 | xargs echo

or this:

( ls -1 | xargs cat ) >junk

Cheers

Top
#194941 - 26/12/2003 10:17 Re: linux question [Re: mlord]
image
old hand

Registered: 28/04/2002
Posts: 770
Loc: Los Angeles, CA
yeah, i'm now looking at awk / sed to do the parsing of the list. dunno if i can do this as a oneliner anymore, but i'll sure try. also, i guess that diff doesnt list the dev files i installed (for telnetd), but i already have a script to handle that, so no worries. but if anyone already knows of a created script that does this <looks at Roger>, feel free to save me from the effort.

Top
#194942 - 26/12/2003 11:25 Re: linux question [Re: image]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
I'd say that the easiest thing to do would be to modify the source to diff to make its quiet output actually quiet. It's a little wordy now. If you just wanted to solve it for this one problem, it should be pretty easy to just edit out the talkiness. It shouldn't be a lot harder to modify it to make a new option.

Anyway, once you did that you could come up with a one liner. Something like ``newdiff --actually-quiet --recursive --brief | (cd newdir ; xargs tar cf dirdiffs.tar )''


Edited by wfaulk (26/12/2003 11:28)
_________________________
Bitt Faulk

Top
#194943 - 26/12/2003 20:17 Re: linux question [Re: wfaulk]
image
old hand

Registered: 28/04/2002
Posts: 770
Loc: Los Angeles, CA
its sloppy but i got it.

diff --brief --recursive OLDDIR NEWDIR | awk '/Only in NEWDIR/ {print $3 $4}; /differ/ {print $4}' | sed 's/:/\//' | sed 's/NEWDIR/./' | (cd NEWDIR && tar zcf diff.tar.gz)

ugly, but it works. no way to put a dev file in a tar archive, huh? also, it doesn't tar up symbolic links since diff just follows them.


Edited by image (26/12/2003 20:20)

Top
#194944 - 27/12/2003 10:31 Re: linux question [Re: image]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Device nodes go into tar files just fine. Are you getting an error? It'll also store symbolic links, but I'm not sure what you're saying about diff following them.
_________________________
Bitt Faulk

Top
#194945 - 27/12/2003 13:12 Re: linux question [Re: wfaulk]
image
old hand

Registered: 28/04/2002
Posts: 770
Loc: Los Angeles, CA
since sbin is just a symlink to bin, diff detected dupes in both places, and tar duplicated both bin and sbin in the archive.

Top
#194946 - 28/12/2003 15:51 Re: linux question [Re: image]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Oh. I see.
_________________________
Bitt Faulk

Top