cómo aplicar un parche en un package Debian?

Puse un informe de errores y me pidieron que aplicara el parche y ver si funciona. Intenté encontrar documentation sobre cómo hacerlo, pero no está claro.

Lo más cerca que he podido averiguar es http://www.thegeekstuff.com/2014/12/patch-command-examples/ .

Descargué la última fuente a través de apt-get bajo un directory llamado dpkg –

$ sudo apt-get source dpkg 

Así es como se ve –

 [shirish@debian] - [~/games/dpkg] - [5692] └─[$] pwd /home/shirish/games/dpkg 

Ese es el path y aquí está –

 ┌─[shirish@debian] - [~/games/dpkg] - [5691] └─[$] ls dmh-verbose-version-check.patch dpkg-1.18.15 dpkg_1.18.15.dsc dpkg_1.18.15.tar.xz 

Me gustaría hacer una copy de security y hacer una ejecución en seco antes de aplicar el parche, pero necesito saber qué commands y salida debo esperar. Además, suelo usar –

 $ fakeroot debian/rules build $ fakeroot debian/rules binary 

para build un package de Deb local. ¿Es esto lo suficientemente bueno?

Actualización 1 – Eso no funcionó –

 ┌─[shirish@debian] - [~/games/dpkg] - [5710] └─[$] cd dpkg-1.18.15 ┌─[shirish@debian] - [~/games/dpkg/dpkg-1.18.15] - [5711] └─[$] dch -n "Apply dmh fix from #844701." dch: fatal error at line 569: debian/changelog is not writable! 

Entonces, necesito usar sudo para tener acceso de escritura O usar chmod para cambiar los derechos / permissions. Quiero hacerlo de la manera correcta.

Actualización 2 : Redicé todo el asunto, de la manera correcta esta vez, atascado en la etapa de reparación –

 ┌─[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 

Entonces –

 ┌─[shirish@debian] - [~] - [5755] └─[$] cp dmh-verbose-version-check.patch games/dpkg-1.18.15 

Entonces –

 ┌─[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 dmh-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 

y entonces –

 ┌─[shirish@debian] - [~/games/dpkg-1.18.15] - [5757] └─[$] patch < ./dmh-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: 

ahora confundido qué hacer?

Actualización 3

Lo hice con el parámetro -p1 e hice los pasos restantes –

Compartiendo las últimas 5 líneas impares de la compilation –

 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) 

y hemos podido instalar la más nueva –

 ┌─[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 configunetworking 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 configunetworking 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 configunetworking 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: defernetworking_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: defernetworking_configure updating conffiles D000001: process queue pkg dselect:amd64 queue.len 4 progress 1, try 1 Setting up dselect (1.18.15+nmu1) ... D000001: defernetworking_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: defernetworking_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: defernetworking_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: defernetworking_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: defernetworking_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 

Y por último –

 ┌─[shirish@debian] - [/usr/share/doc/dpkg] - [5815] └─[$] zcat changelog.Debian.gz | less dpkg (1.18.15+nmu1) UNRELEASED; urgency=medium * Non-maintainer upload. * Apply dmh fix from #844701 -- shirish <shirish@debian> Mon, 21 Nov 2016 01:04:02 +0530 dpkg (1.18.15) unstable; urgency=medium 

Esto significa que se instaló correctamente.

 [$] 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 

Comenzando con la situación que tienes:

 cd dpkg-1.18.15 patch -p1 < ../dmh-verbose-version-check.patch 

aplicará el parche. Antes de comstackr, agregue una input de logging de cambios de NMU (esto evitará que sobrescribir la versión parchada de dpkg por apt & co., Pero asegurará que su versión se actualice a la próxima versión de dpkg cuando esté disponible):

 dch -n "Apply dmh fix from #844701." 

Esto cambiará el nombre del directory actual (porque dpkg es un package nativo), por lo que debe cambiar los directorys nuevamente:

 cd ../dpkg-1.18.15+nmu1 

Para build, tiendo a usar

 dpkg-buildpackage -us -uc 

Eso producirá los diversos files .deb en el directory principal; puedes instalarlos usando dpkg como de costumbre.

(Llamar explícitamente a los objectives de debian/rules también funciona, pero no debe usar fakeroot para la debian/rules build , solo para debian/rules clean y debian/rules binary ).

Agregar una input de logging de cambios de NMU también asegura que la fuente que ha descargado no se haya tocado, lo que soluciona sus problemas de copy de security. También significa que la reinstallation de la versión 1.18.15 restaurará la versión de Debian, sin su parche.