Розбіжності
Тут показані розбіжності між вибраною ревізією та поточною версією сторінки.
Порівняння попередніх версій Попередня ревізія Наступна ревізія | Попередня ревізія | ||
freebsd:diff [2023/06/08 21:10] – [diff patch] Method | freebsd:diff [2025/03/30 13:54] (поточний) – [Мій приклад] Method | ||
---|---|---|---|
Рядок 8: | Рядок 8: | ||
- Запустіть відповідну різницю в двох каталогах, | - Запустіть відповідну різницю в двох каталогах, | ||
- | ```diff -ruN orig/ new/ > file.patch | + | 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 " | + | |
- | # -N == treat absent files as empty``` | + | |
Якщо в користувача є каталог orig/, він може відтворити новий, запустивши patch. | Якщо в користувача є каталог orig/, він може відтворити новий, запустивши patch. | ||
Рядок 21: | Рядок 20: | ||
- Цю папку буде знищено, | - Цю папку буде знищено, | ||
- | `patch -s -p0 < file.patch | + | patch -s -p0 < file.patch |
- | # -s == silent except errors | + | |
- | # -p0 == needed to find the proper folder` | + | |
На цьому етапі папка orig/ містить новий вміст, але все ще має стару назву, тому: | На цьому етапі папка orig/ містить новий вміст, але все ще має стару назву, тому: | ||
Рядок 42: | Рядок 41: | ||
Ось мої нотатки: | Ось мої нотатки: | ||
- | `# to create patch: | + | to create patch: |
- | # copy < | + | |
- | cp -r < | + | cp -r < |
- | # create/ | + | |
- | # change working directory to < | + | |
- | cd < | + | cd < |
- | # create patch file alongside < | + | |
- | diff -Naru ../< | + | diff -Naru ../< |
# -N --new-file Treat absent files as empty. | # -N --new-file Treat absent files as empty. | ||
+ | |||
# -a --text Treat all files as text. | # -a --text Treat all files as text. | ||
+ | |||
# -r --recursive Recursively compare any subdirectories found. | # -r --recursive Recursively compare any subdirectories found. | ||
+ | |||
# -u -U NUM --unified[=NUM] Output NUM (default 3) lines of unified context. | # -u -U NUM --unified[=NUM] Output NUM (default 3) lines of unified context. | ||
- | # to apply patch: | + | |
- | # change working directory to < | + | to apply patch change working directory to < |
- | cd < | + | cd < |
- | patch -s -p0 < < | + | patch -s -p0 < < |
# -s or --silent or --quiet Work silently, unless an error occurs. | # -s or --silent or --quiet Work silently, unless an error occurs. | ||
+ | |||
# -pN or --strip=N Strip smallest prefix containing num leading slashes from files. | # -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): | + | to undo patch (note that directories created by patch must be removed manually): |
- | # change working directory to < | + | |
- | cd < | + | |
- | patch -Rs -p0 < < | + | cd < |
- | # -R or --reverse Assume that patch was created with the old and new files swapped. | + | patch -Rs -p0 < < |
- | # -s or --silent or --quiet Work silently, unless an error occurs. | + | # -R or --reverse Assume that patch was created with the old and new files swapped. |
- | # -pN or --strip=N Strip smallest prefix containing num leading slashes from files.` | + | # -s or --silent or --quiet Work silently, unless an error occurs. |
+ | # -pN or --strip=N Strip smallest prefix containing num leading slashes from files.` | ||
Рядок 91: | Рядок 97: | ||
- -s або –silent або –quiet Працює тихо, якщо не виникає помилка. | - -s або –silent або –quiet Працює тихо, якщо не виникає помилка. | ||
- -pN або –strip=N Вилучає з файлів найменший префікс, | - -pN або –strip=N Вилучає з файлів найменший префікс, | ||
+ | |||
+ | |||
+ | ===== Мій приклад ===== | ||
+ | |||
+ | <code bash> | ||
+ | cd /usr/local/ | ||
+ | cp -a nodeny nodeny.orig | ||
+ | # change nodeny | ||
+ | |||
+ | # make patch | ||
+ | diff -Naru nodeny.orig/ | ||
+ | |||
+ | # apply patch for nodeny.orig | ||
+ | cd / | ||
+ | patch -d . -Efu --posix -p1 < ../ | ||
+ | </ | ||