如何为整个目录创建补丁以进行更新? [英] How to create a patch for a whole directory to update it?

查看:115
本文介绍了如何为整个目录创建补丁以进行更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道已经有多个线程,但是没有人完全解释如何执行初始差异来创建补丁文件,然后如何将该补丁应用到初始目录中。



在我的情况下,有一个文件目录,任何人都可以从网上下载。我已经对该目录进行了更改,并希望创建一个补丁文件,以便其他人可以将其应用到下载的目录中,以完全重现修改后的目录中的内容。



有帮助吗?关于如何应用我的补丁程序,我需要告诉其他人什么?

解决方案

我也遇到了同样的问题-关于如何做到一半的很多建议。好吧,这是我为使修补程序和未修补程序都能正常工作而要做的事情:



要创建补丁文件:


  1. 将两个目录的副本放入/ tmp中,因此我们可以创建补丁
    文件,或者如果勇敢的话,将它们并排放置在一个目录中。 / p>


  2. 在新旧两个目录上运行适当的差异:

      diff -ruN orig / new /> file.patch 
    #-r ==递归,子目录
    #-u ==统一样式,如果您的系统缺少它或收件人
    #可能没有,请使用- c
    #-N ==将缺席文件视为空


如果某人拥有orig /目录,则可以通过运行补丁来重新创建新目录。



要从旧文件夹中重新创建新文件夹,并补丁文件:


  1. 将补丁文件移动到orig /文件夹所在的目录


  2. 此文件夹将被破坏,因此请将其备份在某个位置,或者
    使用副本。

     补丁-s -p0< file.patch 
    #-s ==保持静音,但错误
    #-p0 ==需要找到正确的文件夹


  3. 这时,orig /文件夹包含了new /内容,但是
    仍然使用旧名称,因此:

      mv orig / new /#如果文件夹名称不同



I know there are several threads on this already, but no one has fully explained exactly how to perform the initial diff to create the patch file, then how to apply that patch to the initial directory to update it.

In my case, there is a directory of files that anyone can download from the web. I have taken that directory and made changes to it, and want to create a patch file such that others can apply it to the downloaded directory to reproduce exactly what I have in my modified directory.

Help? What do I need to tell the other person with respect to how to apply my patch?

解决方案

I just had this same problem - lots of advice on how to half do it. Well, here is what I did to get both the patching and unpatching to work:

To Create the Patch File:

  1. Put copies of both directories in say /tmp, so we can create the patch file, or if brave, get them side by side - in one directory.

  2. Run an appropriate diff on the two directories, old and new:

    diff -ruN orig/ new/ > file.patch
    # -r == recursive, so do subdirectories
    # -u == unified style, if your system lacks it or if recipient
    #       may not have it, use "-c"
    # -N == treat absent files as empty
    

If a person has the orig/ directory, they can recreate the new one by running patch.

To Recreate the new folder from old folder and patch file:

  1. Move the patch file to a directory where the orig/ folder exists

  2. This folder will get clobbered, so keep a backup of it somewhere, or use a copy.

    patch -s -p0 < file.patch
    # -s == silent except errors
    # -p0 == needed to find the proper folder
    

  3. At this point, the orig/ folder contains the new/ content, but still has its old name, so:

    mv orig/ new/    # if the folder names are different
    

这篇关于如何为整个目录创建补丁以进行更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆