전체 디렉토리에 대한 패치를 작성하여 업데이트하는 방법은 무엇입니까?
이미 여러 스레드가 있다는 것을 알고 있지만, 패치 파일을 생성하기 위해 초기 diff를 수행하는 방법과 패치 파일 을 업데이트하기 위해 해당 패치를 초기 디렉토리에 적용 하는 방법을 정확히 설명한 사람은 없습니다 .
제 경우에는 누구나 웹에서 다운로드 할 수있는 파일 디렉토리가 있습니다. 나는 그 디렉토리를 가져 와서 변경했고, 다른 사람들이 그것을 다운로드 한 디렉토리에 적용하여 내가 수정 한 디렉토리에있는 것을 정확하게 재현 할 수 있도록 패치 파일을 만들고 싶습니다.
도움? 내 패치를 적용하는 방법과 관련하여 상대방에게 무엇을 말해야합니까?
나도 똑같은 문제가 있었는데, 어떻게 절반을 할 수 있는지에 대한 많은 조언이있었습니다. 글쎄, 여기에 내가 패치와 패치 해제를 모두하기 위해 한 일이있다.
패치 파일을 만들려면 :
두 디렉토리의 복사본을 / tmp에 넣어서 패치 파일을 만들거나 용감하다면 한 디렉토리에 나란히 놓을 수 있습니다.
이전 디렉토리와 새 디렉토리에서 적절한 diff를 실행하십시오.
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
사람이 orig / 디렉토리를 가지고 있다면 패치를 실행하여 새 디렉토리를 다시 만들 수 있습니다.
이전 폴더 및 패치 파일에서 새 폴더를 다시 생성하려면 :
orig / 폴더가있는 디렉토리로 패치 파일 이동
이 폴더는 손상 될 수 있으므로 백업을 어딘가에 보관하거나 복사본을 사용하십시오.
patch -s -p0 < file.patch # -s == silent except errors # -p0 == needed to find the proper folder
이 시점에서 orig / 폴더는 new / 내용을 포함하지만 여전히 이전 이름을 가지고 있습니다.
mv orig/ new/ # if the folder names are different
나는 패치 파일을 만들어서 다른 사람에게 보내야 그들이 나의 것과 일치하도록 그들의 디렉토리를 업데이트 할 수 있었다. 그러나 diff 및 patch 에는 많은주의 사항이 있으므로 개념적으로 간단한 것을 파악하는 데 몇 시간이 걸렸습니다. 절대 경로가 상대 경로보다 선호되는 것으로 보이며 많은 옵션이 틈새 사용 사례에서 진화 한 것 같습니다. 마침내 Lakshmanan Ganapathy의 추가 팁과 함께 David H의 답변을 기반으로 솔루션을 찾았습니다 .
- 당신의 백업
directory
에를directory.orig
directory
원하는 상태에 도달하도록 수정- 에서 저장 DIFF
directory.orig
에directory
있는file.patch
이름이받는 사람에 대한 일치하도록
내 메모는 다음과 같습니다.
# to create patch:
# copy <directory> backup to something like <directory>.orig alongside it
cp -r <path_to>/<directory> <path_to>/<directory>.orig
# create/update/delete files/folders in <directory> until desired state is reached
# change working directory to <directory>
cd <path_to>/<directory>
# create patch file alongside <directory>
diff -Naru ../<directory>.orig . > ../file.patch
# -N --new-file Treat absent files as empty.
# -a --text Treat all files as text.
# -r --recursive Recursively compare any subdirectories found.
# -u -U NUM --unified[=NUM] Output NUM (default 3) lines of unified context.
# to apply patch:
# change working directory to <directory>
cd <path_to>/<directory>
patch -s -p0 < <path_to>/file.patch
# -s or --silent or --quiet Work silently, unless an error occurs.
# -pN or --strip=N Strip smallest prefix containing num leading slashes from files.
# to undo patch (note that directories created by patch must be removed manually):
# change working directory to <directory>
cd <path_to>/<directory>
patch -Rs -p0 < <path_to>/file.patch
# -R or --reverse Assume that patch was created with the old and new files swapped.
# -s or --silent or --quiet Work silently, unless an error occurs.
# -pN or --strip=N Strip smallest prefix containing num leading slashes from files.
Check out open source Scarab C++ library: https://github.com/loyso/Scarab
It does exactly what you described. It builds per-file diff using xdelta library and puts it to archive package. You can redistribute that package and apply the difference. There are binaries for Win32.
I'm the author of Scarab project.
참고URL : https://stackoverflow.com/questions/9980186/how-to-create-a-patch-for-a-whole-directory-to-update-it
'Program Tip' 카테고리의 다른 글
Python에서 클래스의 멤버 변수에 액세스합니까? (0) | 2020.11.14 |
---|---|
Python namedtuple을 json으로 직렬화 (0) | 2020.11.14 |
애니메이션이있는 함수가 다른 함수를 실행할 때까지 완료 될 때까지 기다립니다. (0) | 2020.11.14 |
내 gradle 빌드에 로컬 .aar 파일 추가 (0) | 2020.11.14 |
npm 설치시 최대 호출 스택 크기 초과 (0) | 2020.11.14 |