Patch

From 탱이의 잡동사니
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Overview

Linux utility patch 사용법 정리.

Basic

       patch [options] [originalfile [patchfile]]

       but usually just

       patch -pnum <patchfile

-p

-p 옵션은 패치 적용의 Depth 를 지정하는 옵션이다. 패치파일을 살펴보면 제일 윗줄에 다음과 같이 파일에 관한 정보가 나타나있다. 여기에 맞춰서 -p 옵션을 이용해여 Depth 를 조절하여 패치 파일을 적용하면 된다.

--- config/util/lndir.c     (revision 9)
+++ config/util/lndir.c     (working copy)
@@ -222,6 +222,8 @@ 
                        continue;
                    if (!strcmp (dp->d_name, "CVS.adm"))
                        continue;
+                   if (!strcmp (dp->d_name, ".svn"))
+                       continue;
                }
                ocurdir = rcurdir;
                rcurdir = buf; 

만약 현재 디렉토리에서 적용시킨다면, 다음과 같이 한다. <source lang=bash> $ patch -p0 < /path/to/lndir.diff </source>