我想为两个目录树创建一个补丁集,这两个目录树都包含应该被忽略的(bind-)挂载。是否有diff -r
选项类似于rsync
的{{1}}?或者是另一种更适合此的工具?我考虑使用-x, --one-file-system
,但问题是“diff” - 以这种方式获得的目录不包含有关文件删除的信息。
背景:我想将对rsync --compare-dest
编辑的修改存储到Gentoo stage3存档中
答案 0 :(得分:0)
作为一种解决方法,我目前通过两次运行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
这也可能用于创建补丁文件而不是......