If you have been around Linux distributions for any amount of time, you have realized that there are sometimes bugs in programs. In the Debian and Ubuntu distributions, bugs are often fixed through the packaging by patching the source code. Sometimes there are bugs in the packaging itself that can cause difficulties.
To patch the program's source code, you could simply download
the current Ubuntu source package (with
apt-get source) and make the needed
changes. You can then add a new entry to the
debian/changelog
using
dch -i or
dch -v
<version>-<revision> to specify
the new revision. When you run debuild
-S from the source directory you will have a
new source package with a new .diff.gz
in the
parent directory that
contains your changes. A problem with this approach is that
the distinction between source and patches is unclear.
Una soluzione a questo problema è separare le modifiche al codice sorgente in singole patch collocate nella directory debian
. Uno di questi meccanismi di patching è chiamato dpatch. Le patch sono collocate nella directory debian
e hanno uno specifico formato.
Per creare una dpatch, esegui le seguenti operazioni sequenzialmente.
Crea un ambiente di lavoro temporaneo e due copie della directory dei sorgenti corrente:
mkdir tmp cd tmp cp -a ../<pacchetto>-<versione>. cp -a <pacchetto>-<versione> <pacchetto>-<versione>.orig
Effettua le modifiche nella directory <pacchetto>-<versione>
.
Crea una patch usando diff e collocala nella directory debian/patches
:
diff -Nru <pacchetto>-<versione>.orig <pacchetto>-<versione> > patch-file
Crea la dpatch usando il comando dpatch patch-template e un file chiamato 00list
che elenca le dpatch:
dpatch patch-template -p "01_nomepatch" "patch-file descrizione" \ < patch-file > 01_nomepatch.dpatch echo 01_nomepatch.dpatch >00list
Ora puoi collocare 01_nomepatch.dpatch
e 00list
nella directory debian/patches
del tuo pacchetto sorgente:
mkdir ../<pacchetto>-<versione>/debian/patches cp 01_nomepatch.dpatch 00list ../<pacchetto>-<versione>/debian/patches cd .. rm -fr tmp
![]() |
|
Puoi anche modificare una patch preesistente usando dpatch-edit-patch. |
Quando tutte le modifiche sono state apportate, è stata inserito un elemento nel changelog e dpatch è stato aggiunto al file debian/control
(se necessario), puoi ricreare il pacchetto sorgente con debuild -S.
To get your fixed source package uploaded to the Ubuntu repositories, you will need to get your source package sponsored by a person who has upload rights. See la sezione chiamata “Caricamento e revisione” for more details. Sometimes, rather than giving the entire source package (.diff.gz, .dsc, and .orig.tar.gz), it is easier and more efficient to just give the difference between the source package that is currently in the repositories and your fixed source package. A tool has been created to do just that called debdiff. Using debdiff is similar to using diff but is made specifically for packaging. You can debdiff the source package by:
debdiff <vecchiopacchetto>.dsc <nuovopacchetto>.dsc > pacchetto.debdiff
o sul pacchetto binario eseguendo:
debdiff <vecchiopacchetto>.deb <nuovopacchetto>.deb > pacchetto.debdiff
I debdiff sono utilissimi da allegare alle segnalazioni di bug e pronti da consegnare ad uno sponsor per il caricamento.