debian包中的补丁制作方法
来源:互联网 发布:大数据靠什么盈利 编辑:程序博客网 时间:2024/06/11 00:36
已经存在的包。对于后者,在修改源码的部分,我们参考debian目录下的内容知
道,通常是 以补丁的形式来进行的。然而,为了方便补丁的制作和管理,产生了多种的
补丁系统。在debian/rules文件中,我们会看到该包使用了哪种补丁系统。如果不
了解一下
补丁系统的基本使用,在修改一个自己没有遇到过的补丁系统的包时,会花
费额外的时间来学习。下面就参考手册针对每种补丁系统介绍一下补丁制作方法。
我目前遇到的补丁系统包含以下几种:
一、没有补丁系统
对于没有使用某种补丁系统的包,rules文件关于补丁部分的处理,一般如下:
# Apply patches to the package
patch: patch-stamp
patch-stamp:
dh_testdir
@patches=debian/patches/*.patch;for patch in $$patches;do \
test -f $$patch||continue; \
echo "Applying $$patch"; \
patch -stuN -p1 < $$patch||exit 1; \
done
touch $@
# Remove patches from the package
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
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 <xx/xx/xx> (注意是源文件夹,没有经过修改)
88 2 输入命令 cdbs-edit-patch <xxxx>.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/下 就会生 成你修改的 <xxxx>.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 ../<package>-<version> .
137 cp -a <package>-<version> <package>-<version>.orig
138 在<package>-<version> 目录中修改需要修改的文件。
139 在debian/patches目录下建立补丁文件
140 diff -Nru <package>-<version>.orig <package>-<version> >
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),添加 <created_patch_name>.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 ),添加<patch_name>.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 https://wiki.ubuntu.com/PackagingGuide/Complete
194 quilt
195
- debian包中的补丁制作方法
- (5) Debian系统中的包
- 怎样用quilt管理debian包中的patches
- DEB安装包制作方法
- .deb包制作方法
- deb包制作方法
- RPM包制作方法
- RPM包制作方法
- ubuntu deb安装包制作方法
- [RK3399] OTA 差异包制作方法
- android版微信打飞机无敌补丁分析及其制作方法
- debian rules文件增添的补丁机制
- Debian 6为cairo打LCD 补丁
- Debian 6为cairo打LCD 补丁
- Debian中文字体包
- Debian的包管理工具
- Debian包管理系统
- debian libssl-dev包
- 获取sqlserver中数据库当前连接数
- android部分默认设置的修改
- 给网站添加X-UA-Compatible标签
- 基于内嵌Tomcat的应用开发
- 用lua开发cocos2d-x游戏时做到代码自动补全
- debian包中的补丁制作方法
- Grails的动态查询
- 用ldapsearch验证LDAP认证信息
- C++ auto_ptr智能指针的用法
- java 修改 读取properties文件
- eclipse死机无响应
- C语言内存地址基础
- 关于导入Extjs项目MyEclipse内存溢出
- uboot中对.balignl和0xdeadbeef的理解