如何在 debian 包中应用补丁?

shi*_*ish 7 compiling debian patch package-management

我提交了一个错误报告,并被要求在其中应用补丁并查看它是否有效。我试图找到有关如何去做的文档,但不清楚。

我能弄清楚的最接近的是http://www.thegeekstuff.com/2014/12/patch-command-examples/

我通过 apt-get 在名为 dpkg 的目录下下载了最新的源代码 -

$ sudo apt-get source dpkg 
Run Code Online (Sandbox Code Playgroud)

这是它的样子——

[shirish@debian] - [~/games/dpkg] - [5692]
??[$] pwd

/home/shirish/games/dpkg
Run Code Online (Sandbox Code Playgroud)

那是路径,这里是-

??[shirish@debian] - [~/games/dpkg] - [5691]
??[$] ls

d-m-h-verbose-version-check.patch  dpkg-1.18.15  dpkg_1.18.15.dsc  dpkg_1.18.15.tar.xz
Run Code Online (Sandbox Code Playgroud)

我想在应用补丁之前进行备份并进行试运行,但需要知道我应该期待哪些命令和输出。另外,我通常使用 -

$ fakeroot debian/rules build
$ fakeroot debian/rules binary 
Run Code Online (Sandbox Code Playgroud)

构建本地 deb 包。这够好吗?

更新 1 - 那没有用 -

??[shirish@debian] - [~/games/dpkg] - [5710]
??[$] cd dpkg-1.18.15

??[shirish@debian] - [~/games/dpkg/dpkg-1.18.15] - [5711]
??[$] dch -n "Apply d-m-h fix from #844701."

dch: fatal error at line 569:
debian/changelog is not writable!
Run Code Online (Sandbox Code Playgroud)

那么我是否需要使用 sudo 来获得写访问权限或使用 chmod 来更改权限/权限。我想以正确的方式做到这一点。

更新 2 - 重做整个事情,这次是正确的方式,停留在修补阶段 -

??[shirish@debian] - [~/games] - [5750]
??[$] apt-get source dpkg

Reading package lists... Done
NOTICE: 'dpkg' packaging is maintained in the 'Git' version control system at:
https://anonscm.debian.org/git/dpkg/dpkg.git
Please use:
git clone https://anonscm.debian.org/git/dpkg/dpkg.git
to retrieve the latest (possibly unreleased) updates to the package.
Skipping already downloaded file 'dpkg_1.18.15.dsc'
Skipping already downloaded file 'dpkg_1.18.15.tar.xz'
Need to get 0 B of source archives.
dpkg-source: info: extracting dpkg in dpkg-1.18.15
dpkg-source: info: unpacking dpkg_1.18.15.tar.xz
Run Code Online (Sandbox Code Playgroud)

然后 -

??[shirish@debian] - [~] - [5755]
??[$] cp d-m-h-verbose-version-check.patch games/dpkg-1.18.15 
Run Code Online (Sandbox Code Playgroud)

然后 -

??[shirish@debian] - [~/games/dpkg-1.18.15] - [5758]
??[$] ls

ABOUT-NLS   ChangeLog      configure     debian                             dpkg-split   m4           NEWS         run-script  t-func
aclocal.m4  ChangeLog.old  configure.ac  d-m-h-verbose-version-check.patch  dselect      Makefile.am  po           scripts     THANKS
AUTHORS     check.am       COPYING       doc                                get-version  Makefile.in  README       src         TODO
build-aux   config.h.in    data          dpkg-deb                           lib          man          README.l10n  t           utils
Run Code Online (Sandbox Code Playgroud)

进而 -

??[shirish@debian] - [~/games/dpkg-1.18.15] - [5757]
??[$] patch < ./d-m-h-verbose-version-check.patch

(Stripping trailing CRs from patch; use --binary to disable.)
can't find file to patch at input line 5
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git i/scripts/dpkg-maintscript-helper.sh w/scripts/dpkg-maintscript-helper.sh
|index f20d82647..8db4a4088 100755
|--- i/scripts/dpkg-maintscript-helper.sh
|+++ w/scripts/dpkg-maintscript-helper.sh
--------------------------
File to patch:
Run Code Online (Sandbox Code Playgroud)

现在迷茫怎么办?

更新 3 -

-p1参数做了它并做了剩下的步骤 -

共享构建的最后 5 条奇数行 -

dh_md5sums -i
dh_builddeb -i
dpkg-deb: building package 'dpkg-dev' in '../dpkg-dev_1.18.15+nmu1_all.deb'.
dpkg-deb: building package 'libdpkg-perl' in '../libdpkg-perl_1.18.15+nmu1_all.deb'.
 dpkg-genchanges  >../dpkg_1.18.15+nmu1_amd64.changes
dpkg-genchanges: info: including full source code in upload
 dpkg-source --after-build dpkg-1.18.15+nmu1
dpkg-source: info: using options from dpkg-1.18.15+nmu1/debian/source/options: --compression=xz
dpkg-buildpackage: info: full upload; Debian-native package (full source is included)
Run Code Online (Sandbox Code Playgroud)

并且已经能够安装最新的-

??[shirish@debian] - [~/games] - [5812]
??[$] sudo dpkg -i dpkg_1.18.15+nmu1_amd64.deb dpkg-dev_1.18.15+nmu1_all.deb dpkg-dbgsym_1.18.15+nmu1_amd64.deb dselect_1.18.15+nmu1_amd64.deb dselect-dbgsym_1.18.15+nmu1_amd64.deb libdpkg-perl_1.18.15+nmu1_all.deb libdpkg-dev_1.18.15+nmu1_amd64.deb

D000001: ensure_diversions: new, (re)loading
D000001: ensure_statoverrides: new, (re)loading
(Reading database ... 1207494 files and directories currently installed.)
Preparing to unpack dpkg_1.18.15+nmu1_amd64.deb ...
D000001: process_archive oldversionstatus=installed
D000001: cmpversions a='0:1.18.15+nmu1' b='0:1.16.1' r=2
D000001: cmpversions a='0:1.18.15+nmu1' b='0:1.16.2' r=2
D000001: ensure_diversions: same, skipping
Unpacking dpkg (1.18.15+nmu1) over (1.18.10) ...
D000001: cmpversions a='0:1.18.15+nmu1' b='0:1.16.2' r=2
D000001: ensure_diversions: same, skipping
D000001: process_archive updating info directory
D000001: generating infodb hashfile
Preparing to unpack dpkg-dev_1.18.15+nmu1_all.deb ...
D000001: process_archive oldversionstatus=unpacked but not configured
D000001: ensure_diversions: same, skipping
Unpacking dpkg-dev (1.18.15+nmu1) over (1.18.15+nmu1) ...
D000001: process_archive updating info directory
D000001: generating infodb hashfile
Preparing to unpack dpkg-dbgsym_1.18.15+nmu1_amd64.deb ...
D000001: process_archive oldversionstatus=unpacked but not configured
Unpacking dpkg-dbgsym (1.18.15+nmu1) over (1.18.15+nmu1) ...
D000001: process_archive updating info directory
D000001: generating infodb hashfile
Preparing to unpack dselect_1.18.15+nmu1_amd64.deb ...
D000001: process_archive oldversionstatus=installed
D000001: ensure_diversions: same, skipping
Unpacking dselect (1.18.15+nmu1) over (1.18.15+nmu1) ...
D000001: process_archive updating info directory
D000001: generating infodb hashfile
Preparing to unpack dselect-dbgsym_1.18.15+nmu1_amd64.deb ...
D000001: process_archive oldversionstatus=installed
Unpacking dselect-dbgsym (1.18.15+nmu1) over (1.18.15+nmu1) ...
D000001: process_archive updating info directory
D000001: generating infodb hashfile
Preparing to unpack libdpkg-perl_1.18.15+nmu1_all.deb ...
D000001: process_archive oldversionstatus=unpacked but not configured
Unpacking libdpkg-perl (1.18.15+nmu1) over (1.18.15+nmu1) ...
D000001: process_archive updating info directory
D000001: generating infodb hashfile
Preparing to unpack libdpkg-dev_1.18.15+nmu1_amd64.deb ...
D000001: process_archive oldversionstatus=installed
Unpacking libdpkg-dev:amd64 (1.18.15+nmu1) over (1.18.15+nmu1) ...
D000001: process_archive updating info directory
D000001: generating infodb hashfile
D000001: process queue pkg dpkg:amd64 queue.len 6 progress 1, try 1
Setting up dpkg (1.18.15+nmu1) ...
D000001: deferred_configure updating conffiles
D000001: ensure_diversions: same, skipping
D000001: process queue pkg dpkg-dev:all queue.len 5 progress 1, try 1
D000001: process queue pkg dpkg-dbgsym:amd64 queue.len 5 progress 2, try 1
Setting up dpkg-dbgsym (1.18.15+nmu1) ...
D000001: deferred_configure updating conffiles
D000001: process queue pkg dselect:amd64 queue.len 4 progress 1, try 1
Setting up dselect (1.18.15+nmu1) ...
D000001: deferred_configure updating conffiles
D000001: process queue pkg dselect-dbgsym:amd64 queue.len 3 progress 1, try 1
Setting up dselect-dbgsym (1.18.15+nmu1) ...
D000001: deferred_configure updating conffiles
D000001: process queue pkg libdpkg-perl:all queue.len 2 progress 1, try 1
Setting up libdpkg-perl (1.18.15+nmu1) ...
D000001: deferred_configure updating conffiles
D000001: process queue pkg libdpkg-dev:amd64 queue.len 1 progress 1, try 1
Setting up libdpkg-dev:amd64 (1.18.15+nmu1) ...
D000001: deferred_configure updating conffiles
D000001: process queue pkg dpkg-dev:all queue.len 0 progress 1, try 1
Setting up dpkg-dev (1.18.15+nmu1) ...
D000001: deferred_configure updating conffiles
Processing triggers for man-db (2.7.5-1) ...
D000001: ensure_diversions: same, skipping
D000001: cmpversions a='0:2016.03.30' b='0:2016.05.24' r=-2
D000001: cmpversions a='0:1.18.15+nmu1' b='0:1.16' r=2
D000001: cmpversions a='0:1.18.15+nmu1' b='0:1.16' r=2
D000001: cmpversions a='0:1.18.15+nmu1' b='0:1.16' r=2
Run Code Online (Sandbox Code Playgroud)

最后 -

??[shirish@debian] - [/usr/share/doc/dpkg] - [5815]
??[$] zcat changelog.Debian.gz | less

dpkg (1.18.15+nmu1) UNRELEASED; urgency=medium

  * Non-maintainer upload.
  * Apply d-m-h fix from #844701

 -- shirish <shirish@debian>  Mon, 21 Nov 2016 01:04:02 +0530

dpkg (1.18.15) unstable; urgency=medium
Run Code Online (Sandbox Code Playgroud)

这意味着它已正确安装。

[$] apt-show-versions dpkg dpkg-dbgsym dpkg-dev libdpkg-perl libdpkg-dev dselect dselect-dbgsym                                     
dpkg:amd64 1.18.15+nmu1 newer than version in archive
dpkg-dbgsym:amd64 1.18.15+nmu1 newer than version in archive
dpkg-dev:all 1.18.15+nmu1 newer than version in archive
dselect:amd64 1.18.15+nmu1 newer than version in archive
dselect-dbgsym:amd64 1.18.15+nmu1 newer than version in archive
libdpkg-dev:amd64 1.18.15+nmu1 newer than version in archive
libdpkg-perl:all 1.18.15+nmu1 newer than version in archive
Run Code Online (Sandbox Code Playgroud)

Ste*_*itt 9

从你的情况开始:

cd dpkg-1.18.15
patch -p1 < ../d-m-h-verbose-version-check.patch
Run Code Online (Sandbox Code Playgroud)

将应用补丁。在构建之前,添加一个 NMU 更改日志条目(这将避免您的补丁版本dpkgapt& co.覆盖,但将确保您的版本dpkg在可用时升级到下一个版本):

dch -n "Apply d-m-h fix from #844701."
Run Code Online (Sandbox Code Playgroud)

这将重命名当前目录(因为dpkg是本机包),因此您需要再次更改目录:

cd ../dpkg-1.18.15+nmu1
Run Code Online (Sandbox Code Playgroud)

为了构建,我倾向于使用

dpkg-buildpackage -us -uc
Run Code Online (Sandbox Code Playgroud)

这将.deb在父目录中生成各种文件;你可以dpkg像往常一样安装它们。

debian/rules明确地调用目标也有效;但你不应该使用fakerootfor debian/rules build,只使用fordebian/rules cleandebian/rules binary。)

添加 NMU 更改日志条目还可确保您下载的源保持不变,从而解决您的备份问题。这也意味着重新安装 1.18.15 版将恢复 Debian 版本,而无需您的补丁。