unpatch:
dh_testdir @if test -f patch-stamp; then \
patches=debian/patches/*.patch; \ for patch in $$patches;do \
reversepatches="$$patch $$reversepatches"; \
done; \ for patch in $$reversepatches;do \
test -f $$patch||continue; \
echo "Reversing $$patch"; \
patch -suRf -p1 <$$patch||exit 1; \
done; \
rm -f patch-stamp; \
fi
36 对于这种情况,新补丁的制作方法 37 cd udev*/ 38 cp -a . /tmp/old 39 pushd /tmp/old 40 debian/rules patch 41 cp -a . /tmp/new; cd ../new 42 sed -i 's/Linux/Penguin/g' README 43 cd .. 44 diff -Nurp old new > 90_penguins.patch 45 popd 46 mv /tmp/90_penguins.patch debian/patches 47 rm -rf /tmp/old /tmp/new 48 旧补丁的修改方法 49 cp -a . /tmp/old 50 pushd /tmp/old 51 cp -a . /tmp/new 52 cd ../new; patch -p1 <debian/patches/10-selinux-include-udev-h.patch 53 sed -i '1 s/$/***** HELLO WORLD ****/' udev_selinux.c 54 cd .. 55 diff -Nurp old new > 10-selinux-include-udev-h.patch 56 popd 57 mv /tmp/10-selinux-include-udev-h.patch debian/patches 58 rm -rf /tmp/old /tmp/new 59 60 注意:如果原来的包中debian/rules文件没有补丁相关部分,需要自己添 加,但需要注意格式。例如:debian/rules文件中,如果要添加某个操作,比如 patch unpatch 61 patch: patch-stamp 62 patch-stamp: 63 rm xxx 64 xxx 65 unpatch: unpatch-stamp 66 unpatch-stamp: 67 rm xxx 68 xxx 69 70 在别的地方比如 71 build: patch configure 72 clean: clean-stamp unpatch 73 74 patch和unpatch 是不能够写到命令中去的,因为没有这个命令,例如: 75 configure: 76 patch 77 xxx 78 这样会出现make: unpatch: Command not found之类的错误。 79 80 二、CDBS补丁系统 81 对于CDBS补丁系统的包,rules文件关于补丁部分的处理,一般如下: 82 #!/usr/bin/make -f 83 include /usr/share/cdbs/1/rules/debhelper.mk 84 include /usr/share/cdbs/1/class/autotools.mk 85 include /usr/share/cdbs/1/rules/simple-patchsys.mk 86 新补丁的制作和旧补丁的修改方法一样 87 1 进入当前的源码目录 cd (注意是源文件夹,没有经过修改) 88 2 输入命令 cdbs-edit-patch .patch (名字可以随意,但是尽量有 意义,最好前面加上编号,例如 03-simple-readme.patch) 89 屏幕输出大体如下:(以smplayer为例子) 90 91 Cleaning in directory . 92 test -x debian/rules 93 dh_testroot 94 dh_clean 95 /usr/bin/make -k clean 96 make[1]: 正在进入目录 `/tmp/cdbs-new-patch.dEBiHb/smplayer-0.6.1' 97 cd src && make clean 98 make[2]: 正在进入目录 `/tmp/cdbs-new-patch.dEBiHb/smplayer-0.6.1/src' 99 make[2]: *** 没有规则可以创建目标“clean”. 100 make[2]:正在离开目录 `/tmp/cdbs-new-patch.dEBiHb/smplayer-0.6.1/src' 101 make[1]: *** [clean] 错误 2 102 make[1]:正在离开目录 `/tmp/cdbs-new-patch.dEBiHb/smplayer-0.6.1' 103 make: [makefile-clean] 错误 2 (忽略) 104 rm -f debian/stamp-makefile-build 105 rm -f svn_revision.txt src/svn_revision.h 106 make: 没有什么可以做的为 `apply-patches'。 107 108 You are now in a subshell in a cleaned copy of your source package. 109 Please make the changes necessary for the patch test.patch 110 in this directory and exit with status 0 to create/update the patch. 111 Exiting with a non-zero value will cancel the patch modification. 112 113 注意你的当前目录变成类似这样的目录 : /tmp/cdbs-new-patch.dEBiHb/smplayer-0.6.1.new$ 114 115 3 更新代码,或者文件。 116 4 输入 exit 0, 会返回以前的源码包目录。在debian/patches/下 就会生 成你修改的 .patch 文件。 输入exit i(i为非0的数字) 则本次修改取消。 117 这样一个cdbs的补丁文件就做好了。 118 119 三、dpatch补丁系统 120 对于dpatch补丁系统的包,rules文件关于补丁部分处理标志代码如下: 121 patch: patch-stamp 122 patch-stamp: 123 dh_testdir 124 dpatch apply-all 125 touch -r config.h.in aclocal.m4 configure.ac 126 dpatch cat-all -nd >$@ 127 unpatch: 128 dh_testdir 129 dpatch deapply-all 130 rm -rf debian/patched 131 rm -f patch-stamp 132 新补丁的制作和旧补丁的修改方法(一) 133 安装dpatch包 134 mkdir tmp 135 cd tmp 136 cp -a ../- . 137 cp -a --.orig 138 在- 目录中修改需要修改的文件。 139 在debian/patches目录下建立补丁文件 140 diff -Nru -.orig - > patch-file 141 建立dpatch文件 142 dpatch patch-template -p "01_patchname" "patch-file description" < patch-file > 01_patchname.dpatch 143 修改00list( Or 00list.Debian, refers debian/rules patch/unpatch block for details),添加 .dpatch 到文 件尾。 Sometimes need add the patch name to 00list.Debian( e.g.: synaptic), because if in the debian/rules file, when apply patch, it copy the debian/patches/00list.Debian to debian/patches/00list, so any changes of 00list before patching will be overwritted.
144 rm -rf tmp 145 新补丁的制作和旧补丁的修改方法(二) 146 安装dpatch包,使用dpatch-edit-patch命令。 147 dpatch-edit-patch new.dpatch [old.dpatch] 148 会出现以下提示: 149 dpatch-edit-patch: * Copying reference directory /tmp/dpep-ref.DHmFGp/scim-1.4.7 to work directory. 150 151 dpatch-edit-patch: 152 153 Now launching an interactive shell in your work directory. Edit your files. 154 When you are done, exit the shell. When you exit the shell, your patch will be 155 automatically updated based on the changes in your work directory. 156 157 If you wish to abort the process, exit the shell such that it returns an exit 158 code of "230". This is typically done by exiting the shell with the command 159 'exit 230'. 160 在此目录中修改想要修改的文件。 161 键入 exit 退出,补丁自动生成在debian/patches目录中。 162 修改00list,添加 patch 95_newupstreamfix.dpatch 到文件尾。 163 说明: 164 new.dpatch是想要生成的文件,old.dpatch是以存在的补丁文件。 如果你想要修改的文件用到了old.dpatch文件,那么当 165 你编辑此文件时,所显示的内容是打过old.dpatch补丁后的内容。 修改文件之后exit退出,生成new.dpatch文件。 166 当不确定你要修改的文件是否依赖某个补丁时,可以加old.dpatch 参数,如果已确定文件没有依赖其他补丁,可以不加old.dpatch参数。 167 dpatch补丁系统通过debian/patches/00list文件,来查找文件中罗 列的补丁包,并执行补丁命令。
when 修改00list ( Or 00list.Debian: see debian/rules patch block for more ),添加.dpatch 到文件尾。 Sometimes need add the patch name to 00list.Debian( e.g.: synaptic), because if the debian/rules file, when apply patch, it copy the debian/00list.Debian to debian/patches/00list, so any changes of 00list before patching will be overwritted. ( NOT only debian/patches/00list, but ALSO there are debian/patches/00list.Debian, debian/patches/00list.Ubuntu)
168 169 四、quilt补丁系统 170 对于quilt补丁系统的包,rules文件关于补丁部分的处理,标志代码如下: 171 include /usr/share/cdbs/1/rules/patchsys-quilt.mk 172 173 quilt相关的命令参见参考资料 174 这里有一个例子来介绍 175 cd /wherever/you/unpacked/the/source/ 176 mkdir debian/patches 177 export QUILT_PATCHES=debian/patches 178 touch debian/patches/series 179 修改旧补丁 180 quilt push 901_xterm_manpage.diff 181 sed -i 's/Copyright/Copyleft/' xterm.man 182 quilt refresh 901_xterm_manpage.diff 183 quilt pop -a 184 增加新补丁 185 quilt push -a 186 quilt new muhaha.diff 187 quilt add README # you have to do that for all files you modify 188 sed -i '1 s/^/MUHAHA/' README 189 quilt refresh 190 quilt pop -a 191 192 参考资料 193 194 quilt 195 http://www.wzdftpd.net/blog/index.php?2008/02/05/3-quilt-a-patch-management-system-how-to-survive-with-many-patches