我想为两个目录树创建一个补丁集,这两个目录树都包含应该被忽略的(绑定)挂载。有没有diff -r
类似于rsync
's 的选项-x, --one-file-system
?还是另一种工具更适合于此?我考虑使用rsync --compare-dest
,但问题是通过这种方式获得的“差异”目录不包含有关文件删除的信息。
背景:我想存储对chroot
ed-into Gentoo stage3 存档所做的修改
rsync
作为一种解决方法,我目前运行两次浪费了大量时间:
ORIG=/path/to/original
MOD=/path/to/modded
# find the modified/added files:
mkdir modded && rsync -axP --prune-empty-dirs --compare-dest=$ORIG $MOD/ modded
# the other way around, includes both deleted and modded files
mkdir deleted && rsync -axP --prune-empty-dirs --compare-dest=$MOD $ORIG/ deleted
# find the modded files and remove them
for i in $(find deleted); do [ -e modded${i#deleted} ] && rm $i; done
# delete the empty directories
find modded delete -type d -empty -delete
# create a list of the deleted files
cd deleted && find -type f > ../deleted.list && cd ..
# tar the modifications
cd modded && tar czf ../modded.tgz && cd ..
rm -rf deleted modded
现在modded.tgz
包含已修改/添加的文件,同时deleted.list
包含已删除文件的名称,因此要应用它们运行
tar xf modded.tgz
while read -r line; do rm $line; done < deleted.list
这可能也可以用来创建补丁文件......