Patch everything that doesn’t hit or Open source in action
Perhaps many have come across a situation where a program or library from a distribution does not contain some (the one you need) functionality that was added in the next version. Either it contains a bug that was fixed in the next version (or its fix was not included in the main branch), but your distribution kit repository still contains the old version.
It was precisely this bug that I encountered, as well as all users of the JuffEd editor (the new version of which, by the way, was released the other day), using the GNOME Linux environment as a working environment. This bug lies in the fact that when using the autocomplete, its window appears for a moment, after which it disappears, "taking away" the focus. In this example, I will show how you can patch programs from the distribution package yourself.
The described bug is a bug of the QScintilla library, which manifests itself in all programs that use this component (for example, a similar behavior is observed in Eric4). If you do not use any of these programs, but your hands itch, try to install one of them purely for experimental purposes. But, I repeat, the bug appears only under GNOME, and under KDE everything works.
I sent the patch to the developers and did some testing of it, but if they include this patch, then in the next version. And what about those who use not the latest distributions? In this case, the situation is further complicated by the fact that the new version of the library (2.4) is binary incompatible with the previous one (2.3, which is contained, for example, in Ubuntu 9.04), so it’s impossible to simply assemble and install version 2.4 after they solve this problem - Programs built using the "native" version 2.3, when using version 2.4, fall in 100% of cases.
Well, scared? :) And now less words, more work!
We will collect the “native” version, but with the patch we need. I will describe the whole process in the case when we edit something from scratch, and also talk about shorter ways, in case the patch already exists.
So, create a directory for experiments and move on to it:
First, we need the source code for exactly the version that is installed on your system. This is not just done, but very simple:
But for this, along with the main repositories, you should have connected repositories with source codes:
So, we got exactly those source codes from which the package that the repositories are located was collected. Most (if not all) packages have distro-specific patches, which in the case of Debian-based distributions are in the debian / patches subdirectory. These patches are applied before the assembly itself, and our task is to put there a deb patch with the correction we need. For this we need the dpatch utility. Install it (as well as several other utilities that we will need during assembly) and go to the main directory with the program:
We see that in the debian / patch directory there are 3 files: the 00list file and 2 files with the extension .dpatch. As you might guess, the 00list file contains a list of patches, and the remaining files are patches. In order to avoid confusion, I will call those patches that are in the debian / patches directory that are for the dpatch program deb-patches, and just patches will be called regular patches that can be created by diff and which are usually used by patch to making changes.
Those who are interested in the result, but the process itself is not particularly, can download the finished debut patch here , put it in the debian / patches directory and go to the paragraph at the end of this section, which begins with the words “If we now look at the debian / patches directory .... "
Those who are interested in the process themselves read further instructions on how to make such a debug patch yourself.
To create your own debug patch, being in the main program directory, execute the dpatch-edit-patch commandwhere Is the name of the new debug patch. In this case, a temporary copy of the entire source catalog will be created, and our shell will be automatically redirected to it. Here we can edit the source code as we see fit, after which we simply exit this “embedded shell” with the exit command, and the result of all these actions will be the debug patch we need, containing all the changes made. You can edit it either manually or using the patch command (regular patch, not dpatch), applying patches created by someone else.
So, I leave the editing manually behind the scenes, because it can be individual for each (you can remove something unnecessary, or you can simply add “Peace, Labor, May!” or something else to the About dialog), and I'll show you how to use ready-made patches as an example of the case in question, namely to fix auto-completion in QScintilla. Here is the patch I sent to the QScintilla developers. Save it to your disk.
Download the patch
So, now we’ll do everything that I said above with many incomprehensible words with the help of short and understandable commands :) We are in the main source directory of qscintilla2-2.3.2:
If we now look at the debian / patches directory, we will see that there is another file named 03_autocomplete.dpatch. All we have to do is add its name (without the .dpatch extension) to the 00list file. If you forget to do this, the package will compile without our changes and will not be any different from what lies in the repository.
While still in the main source directory, we execute
He will certainly swear that not all dependencies for assembly are satisfied. Install everything that he asks. On a completely clean machine, this requires downloading 46.7 MB of archives, after unpacking which 181 MB of disk space will be taken. If any of this is already installed, then you will have to download less. The lion's share is the development library Qt4 (30.6 MB and 124 MB, respectively).
In the comments below, the arty habruiser rightly noted that dependencies can be set using
and thus you don’t have to list all the required packages by hand.
After installing everything you need, run the assembly again:
Now everything should go without question.
If you did everything right in the previous steps, then after some time the assembly will end (cursing for the lack of a digital signature, but this can be ignored), and several deb packages will appear in the directory one level above. We are interested in one of them: libqscintilla2-3_2.3.2-0ubuntu2_i386.deb. Install it
and [re] run programs that use this library (for example, JuffEd).
Voila! Autocomplete works!
If you have any additions or comments, welcome to comments.
For the laziest - the already assembled and patched package for Ubuntu 9.04 (i386)
UPD1: I apologize, I downloaded the wrong package. If you downloaded the deb, install and nothing is still not working - download again:
$ libqscintilla2-3_2.3.2 the md5sum-patched-1ubuntu2_i386.deb
e5047bb52011d80b06e82fafe5063a73 libqscintilla2-3_2.3.2-patched-1ubuntu2_i386.deb
UPD2: patched a package for Ubuntu 9.10 ( i386)
It was precisely this bug that I encountered, as well as all users of the JuffEd editor (the new version of which, by the way, was released the other day), using the GNOME Linux environment as a working environment. This bug lies in the fact that when using the autocomplete, its window appears for a moment, after which it disappears, "taking away" the focus. In this example, I will show how you can patch programs from the distribution package yourself.
The described bug is a bug of the QScintilla library, which manifests itself in all programs that use this component (for example, a similar behavior is observed in Eric4). If you do not use any of these programs, but your hands itch, try to install one of them purely for experimental purposes. But, I repeat, the bug appears only under GNOME, and under KDE everything works.
I sent the patch to the developers and did some testing of it, but if they include this patch, then in the next version. And what about those who use not the latest distributions? In this case, the situation is further complicated by the fact that the new version of the library (2.4) is binary incompatible with the previous one (2.3, which is contained, for example, in Ubuntu 9.04), so it’s impossible to simply assemble and install version 2.4 after they solve this problem - Programs built using the "native" version 2.3, when using version 2.4, fall in 100% of cases.
Well, scared? :) And now less words, more work!
Cooking ingredients
We will collect the “native” version, but with the patch we need. I will describe the whole process in the case when we edit something from scratch, and also talk about shorter ways, in case the patch already exists.
So, create a directory for experiments and move on to it:
$ mkdir -p experiments/qscintilla
$ cd experiments/qscintilla
First, we need the source code for exactly the version that is installed on your system. This is not just done, but very simple:
$ apt-get source libqscintilla2-3
But for this, along with the main repositories, you should have connected repositories with source codes:
So, we got exactly those source codes from which the package that the repositories are located was collected. Most (if not all) packages have distro-specific patches, which in the case of Debian-based distributions are in the debian / patches subdirectory. These patches are applied before the assembly itself, and our task is to put there a deb patch with the correction we need. For this we need the dpatch utility. Install it (as well as several other utilities that we will need during assembly) and go to the main directory with the program:
$ sudo aptitude install dpatch cdbs fakeroot build-essential patch
$ cd qscintilla2-2.3.2/
Add the main highlight
We see that in the debian / patch directory there are 3 files: the 00list file and 2 files with the extension .dpatch. As you might guess, the 00list file contains a list of patches, and the remaining files are patches. In order to avoid confusion, I will call those patches that are in the debian / patches directory that are for the dpatch program deb-patches, and just patches will be called regular patches that can be created by diff and which are usually used by patch to making changes.
Those who are interested in the result, but the process itself is not particularly, can download the finished debut patch here , put it in the debian / patches directory and go to the paragraph at the end of this section, which begins with the words “If we now look at the debian / patches directory .... "
Those who are interested in the process themselves read further instructions on how to make such a debug patch yourself.
To create your own debug patch, being in the main program directory, execute the dpatch-edit-patch command
So, I leave the editing manually behind the scenes, because it can be individual for each (you can remove something unnecessary, or you can simply add “Peace, Labor, May!” or something else to the About dialog), and I'll show you how to use ready-made patches as an example of the case in question, namely to fix auto-completion in QScintilla. Here is the patch I sent to the QScintilla developers. Save it to your disk.
--- Qt4/SciClasses.cpp 2009-10-16 10:09:48.000000000 -0400
+++ Qt4/SciClasses.cpp 2009-10-16 10:11:01.000000000 -0400
@@ -128,7 +128,7 @@
SciListBox::SciListBox(QWidget *parent, ListBoxQt *lbx_)
: QListWidget(parent), lbx(lbx_)
{
- setWindowFlags(Qt::Tool|Qt::FramelessWindowHint);
+ setWindowFlags(Qt::ToolTip|Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_StaticContents);
setFocusProxy(parent);
Download the patch
So, now we’ll do everything that I said above with many incomprehensible words with the help of short and understandable commands :) We are in the main source directory of qscintilla2-2.3.2:
$ dpatch-edit-patch 03_autocomplete (создаём новый деб-патч и попадаем в каталог с копией исходников)
$ patch -p0 < /path/to/our/qscintilla_autocomplete.patch (патчим исходники существующим патчем)
$ exit (выходим из "виртуального шелла")
If we now look at the debian / patches directory, we will see that there is another file named 03_autocomplete.dpatch. All we have to do is add its name (without the .dpatch extension) to the 00list file. If you forget to do this, the package will compile without our changes and will not be any different from what lies in the repository.
$ echo "03_autocomplete" >> debian/patches/00list
Cook! That is, we collect
While still in the main source directory, we execute
$ dpkg-buildpackage -rfakeroot
He will certainly swear that not all dependencies for assembly are satisfied. Install everything that he asks. On a completely clean machine, this requires downloading 46.7 MB of archives, after unpacking which 181 MB of disk space will be taken. If any of this is already installed, then you will have to download less. The lion's share is the development library Qt4 (30.6 MB and 124 MB, respectively).
$ sudo aptitude install libqt4-dev python-all-dev sip4 python-sip4 python-sip4-dev python-qt4-dev python-qt4
In the comments below, the arty habruiser rightly noted that dependencies can be set using
apt-get build-dep [package name]
and thus you don’t have to list all the required packages by hand.
After installing everything you need, run the assembly again:
$ dpkg-buildpackage -rfakeroot
Now everything should go without question.
If you did everything right in the previous steps, then after some time the assembly will end (cursing for the lack of a digital signature, but this can be ignored), and several deb packages will appear in the directory one level above. We are interested in one of them: libqscintilla2-3_2.3.2-0ubuntu2_i386.deb. Install it
$ sudo dpkg -i ../libqscintilla2-3_2.3.2-0ubuntu2_i386.deb
and [re] run programs that use this library (for example, JuffEd).
Voila! Autocomplete works!
If you have any additions or comments, welcome to comments.
For the laziest - the already assembled and patched package for Ubuntu 9.04 (i386)
UPD1: I apologize, I downloaded the wrong package. If you downloaded the deb, install and nothing is still not working - download again:
$ libqscintilla2-3_2.3.2 the md5sum-patched-1ubuntu2_i386.deb
e5047bb52011d80b06e82fafe5063a73 libqscintilla2-3_2.3.2-patched-1ubuntu2_i386.deb
UPD2: patched a package for Ubuntu 9.10 ( i386)