Merge e Sync

[Importante]

Requisiti: build-essential, automake, gnupg, lintian, fakeroot, patchutils, debhelper and pbuilder.

Ubuntu is based on the Debian Linux distribution and uses the same package management system (APT). At the beginning of each Ubuntu development cycle, the packages in Ubuntu are updated to those in the Debian unstable branch. However, because Ubuntu is not the same as Debian, some of the packages need to be modified to work in Ubuntu. There might also be bug fixes that Ubuntu developers have introduced into the packages. You can determine whether this has taken place by noting the package version. If the package version includes ubuntu in it (an example would be gimp-2.2.9-3ubuntu2), then the Ubuntu developers have made changes, and it is no longer the same as the Debian package. There are more than 1000 such modified packages in the Universe repository.

At the start of each Ubuntu development cycle, a decision is made regarding these Ubuntu versioned packages. Of course if the Debian version hasn't changed since the last Ubuntu release, then nothing needs to be changed. However, if there is a newer version of the package in Debian, then one of two things should happen. If all of the reasons for Ubuntu modifications (bug fixes, dependencies, etc.) are fixed in the new Debian package, then we can just take the Debian package directly. This decision is called a sync. However, if the new Debian version has the same issues that caused the Ubuntu version to be made, then those changes need to be applied to the new Debian version, too. This decision is called merging.

Tutorial sul merge

Il processo di merge comporta l'analisi dei cambiamenti introdotti sia nel pacchetto sorgente di Debian, sia di quello di Ubuntu al fine di determinare cosa è stato modificato e cosa è invece di competenza di Ubuntu. Consideriamo come esempio un popolare programma per la creazione di CD chiamato xcdroast.

Per cominciare, è necessario creare una cartella che contenga il nostro progetto, ed aprirla:



 mkdir ~/xcdroast

 cd ~/xcdroast

Ora scaricare tutti i pacchetti sorgente necessari in questa cartella:

[Nota]

Questi passaggi possono essere completati anche cercando in packages.debian.org per i pacchetti Debian e in packages.ubuntu.com per i pacchetti Ubuntu.

[Suggerimento]

Un pacchetto che è estremamente utile avere installato quando si effettuano merge (od ogni operazione di creazione di pacchetti per Ubuntu) è devscripts. Se ancora non dovesse essere stato installato, installarlo prima di continuare.

By looking at the Ubuntu changelog you should be able to see which differences to expect between the Ubuntu package and the Debian package from which it was derived. For xcdroast, the Ubuntu changelog can be found at changelogs.ubuntu.com. It says that a .desktop file was fixed and properly installed to close a bug reported in Malone.

Ora si esaminano gli attuali cambiamenti nei pacchetti sorgente:



 debdiff xcdroast_0.98+0alpha15-1.1.dsc xcdroast_0.98+0alpha15-1.1ubuntu1.dsc | \

 	ubuntu.debdiff | less ubuntu.debdiff

The lines that start with - have been removed from the Debian package, and those that start with + have been added to the Ubuntu package.

Questo è ciò che vediamo:

  • In debian/rules è stato utilizzato install al posto di cp per installare l'icona di xcdroast. Inoltre, è presente una nuova linea per l'installazione del file .desktop.

  • In debian/changelog i cambiamenti effettuati sono stati aggiunti alle note del changelog.

  • In debian/dirs usr/share/applications è stata aggiunta per fare in modo che le linee di installazione sopra funzionino correttamente.

  • xcdroast.desktop è stato aggiunto

Adesso sappiamo come è stato modificato il sorgente di Ubuntu. È necessario ora conoscere cosa è stato cambiato nei sorgenti Debian.



 debdiff xcdroast_0.98+0alpha15-1.1.dsc xcdroast_0.98+0alpha15-3.dsc > debian.debdiff

 less debian.debdiff

In questo debdiff ci sono molte più modifiche rispetto al precedente. Un modo per farsi una migliore idea di cosa è cambiato è vedere quali file siano stati modificati nel debdiff:

grep diff debian.debdiff

Questo ci indica che debian/postinst, debian/rules, debian/changelog, debian/doc-base.manual, debian/control, e debian/menu sono stati modificati nella nuova versione Debian.

Thus we can see that we need to check debian/rules to see if the Ubuntu changes were made. We can also see that debian/dirs was not changed from the old Debian version. Let us now look at the files. We can unpack the source package by using dpkg-source:

dpkg-source -x xcdroast_0.98+0alpha15-3.dsc

Questo comando scompatterà il file xcdroast_0.98+0alpha15.orig.tar.gz, creerà una cartella xcdroast-0.98+0alpha15, ed applicherà i cambiamenti trovati in xcdroast_0.98+0alpha15-3.diff.gz.

Ora entrare nella cartella Debian:

cd xcdroast-0.98+0alpha15/debian

One can see in rules that changes made by Ubuntu were not applied to the new Debian version. This means that:

cp debian/xcdroast.xpm `pwd`/debian/$(PACKAGE)/usr/share/pixmaps

..dovrebbe essere cambiato in:



 #cp debian/xcdroast.xpm `pwd`/debian/$(PACKAGE)/usr/share/pixmaps

 

 #install desktop and icon

 install -D -m 644 $(CURDIR)/debian/xcdroast.desktop \

 	$(CURDIR)/debian/xcdroast/usr/share/applications/xcdroast.desktop

 install -D -m 644 $(CURDIR)/debian/xcdroast.xpm \

 	$(CURDIR)/debian/xcdroast/usr/share/pixmaps/xcdroast.xpm

Ora in dirs, le seguenti linee devono essere aggiunte affinché il file .desktop venga installato.

usr/share/applications

Adesso abbiamo bisogno del file .desktop attuale (salvato come debian/xcdroast.desktop). Da ubuntu.debdiff (o dal pacchetto sorgente Ubuntu), vediamo che è:

[Desktop Entry]
Encoding=UTF-8
Name=X-CD-Roast
Comment=Create a CD
Exec=xcdroast
Icon=xcdroast.xpm
Type=Application
Categories=Application;AudioVideo;

The last change that needs to be made is in changelog. Not only do we need to add what we have just done (merge with Debian), but we should also add in the previous Ubuntu changelog entries. To do this, run dch -i -D dapper and put something to the effect of:

xcdroast (0.98+0alpha15-3ubuntu1) dapper; urgency=low

  * Sincronizza di nuovo con Debian.

Make sure to change the version number to the correct Ubuntu version. Also add:

xcdroast (0.98+0alpha15-1.1ubuntu1) breezy; urgency=low

  * Fix and install existing .desktop file. (Closes Malone #2698)
				
  -- Captain Packager <packager@coolness.com> Sat, 1 Oct 2005 19:39:04 -0400

tra la nota del log della versione 0.98+0alpha15-1.1 e quella della versione 0.98+0alpha15-2.

Ora è possibile compilare e testare i nuovi pacchetti sorgente. Esistono diversi modi per farlo, ma uno per esempio può essere:

cd ..
debuild -S
cd ..
sudo pbuilder build xcdroast_0.98+0alpha15-3ubuntu1.dsc

This will recreate the source package, sign it with your default GPG key, and build the package in a pbuilder environment to make sure it builds correctly. Make sure to always test your packages before submitting patches. The last step is to make a debdiff that can be attached to an existing bug report or given to the MOTUs in the #ubuntu-motu IRC channel. To do this, we get the difference between the Debian unstable source package and the new Ubuntu version:

debdiff xcdroast_0.98+0alpha15-3.dsc xcdroast_0.98+0alpha15-3ubuntu1.dsc > \
 	xcdroast_0.98+0alpha15-3ubuntu1.debdiff