Perhaps many have come across a situation where the program or library from the distribution does not contain some (necessary) functionality that was added in the next version. Or it contains a bug that was fixed in the next version (or its fix was not included in the main branch), and the old version is still contained in the repository of your distribution.
It was with such a 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 environment under Linux as the working environment. This bug lies in the fact that when using autocomplete, its window appears for a moment, after which it disappears, “taking” the focus behind it. In this example, I will show how you can patch programs from the distribution kit yourself.
The described bug is a bug of the QScintilla library, which manifests itself in all programs that use this component (for example, Eric4 has the same behavior). If you do not use any of these programs, but itching to try - you can install one of them purely for experimental purposes. But, I repeat, the bug only appears under GNOME, and under KDE everything works.
I sent the patch to the developers and conducted some testing of it, but if they include this patch, in the next version. And what about those who do not use 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 will be impossible to simply assemble and install version 2.4 after they solve this problem. - programs compiled using native version 2.3, when using version 2.4, fall in 100% of cases.
Well, scared? :) And now less words, more things!
')
Cooking ingredients
We will build the “native” version, but with the patch we need. I will describe the whole process in case we rule something from scratch, and also talk about shorter paths, in case the patch already exists.
So, create a directory for experiments and go into it:
$ mkdir -p experiments/qscintilla
$ cd experiments/qscintilla
First we need the source code of exactly the version that is installed on your system. This is done not simply, but very simply:
$ apt-get source libqscintilla2-3
But for this, you should have the source repositories on par with the main repositories:
So, we got exactly the source code from which the package that contains the repository was assembled. 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 build itself, and our task is to put a deb patch there with the correction we need. For this we need the dpatch utility. Install it (as well as several other utilities that we will need when building) 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 .dpatch extension. As you might guess, the 00list file contains a list of patches, and the remaining files are patches. To avoid confusion, those patches that are in the debian / patches directory and which are intended for the dpatch program, I will call debuts, and just patches will be called regular fixes that can be created by the diff program and which are usually used by the patch program for making changes.
Those who are interested in the result, and the process itself - not really, 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 in the debian / patches directory .... "
Those who are interested in the process themselves, read further the instructions on how to make such a deb patch independently.
To create your own deb-patch, being in the main program directory run the command dpatch-edit-patch <patch_name>, where <patch_name> is the name of the new deb-patch. This will create a temporary copy of the entire source directory, 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 “nested shell” with the exit command, and the result of all these actions will be the necessary deb-patch containing all the changes made. You can edit both manually and using the patch command (regular patch, not dpatch), applying patches created by someone else.
So, I leave the manual edit behind the scenes, because for everyone, it can be individual (you can remove something unnecessary, or you can simply add to the “Peace, Work, May!” About dialogue) or show you how to use ready-made patches using the example of the case in question, namely to fix autocompletion 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 patch
So, now everything that I told above with many incomprehensible words, we will do with the help of short and clear commands :) We are in the main source directory qscintilla2-2.3.2:
$ dpatch-edit-patch 03_autocomplete ( - )
$ patch -p0 < /path/to/our/qscintilla_autocomplete.patch ( )
$ exit ( " ")
If we now look into the debian / patches directory, we will see that another file appeared there named 03_autocomplete.dpatch. All that remains to be done is to add its name (without the .dpatch extension) to the 00list file. If you forget to do this, the package will assemble without our changes and will not be any different from what is in the repository.
$ echo "03_autocomplete" >> debian/patches/00list
Cook! That is, we collect
Being still in the main source directory, we execute
$ dpkg-buildpackage -rfakeroot
He will surely swear that not all dependencies for the assembly are satisfied. Install everything he asks. On a completely clean machine, you will need to download 46.7 MB of archives, after unpacking which will be occupied by 181 MB on the disk. If you have already installed one of these, then you will have to download less. The lion's share is Qt4 developer libraries (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
habrauser quite rightly
remarked that dependencies can be installed using
apt-get build-dep [package name]
and thus do not have to hand enumerate all the required packages.
After installing all the required run the assembly again:
$ dpkg-buildpackage -rfakeroot
Now everything should go without questions.
If you did everything correctly in the previous stages, then after some time the build will end (cursing for the lack of a digital signature, but this can be ignored), and several deb packages will appear in the directory 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 there are additions or comments - welcome to the comments.
For the laziest, the
already compiled and patched package for Ubuntu 9.04 (i386)
UPD1: sorry, flooded the wrong package. If you downloaded deb, installed it, and still nothing works, download it again:
$ md5sum libqscintilla2-3_2.3.2-patched-1ubuntu2_i386.deb
e5047bb52011d80b06e82fafe5063a73 libqscintilla2-3_2.3.2-patched-1ubuntu2_i386.deb
UPD2: patched
package for Ubuntu 9.10 (i386)