
Segfolts Galculator 2.1.3 or my first ebuild
Hi, # {username}!
Today I want to write about one small problem and its solution. The problem concerns Linux users who, after one of the latest updates, the Galculator began to fall. I can not vouch for the accuracy of the information, but it seems that in some magical way this applies only to Gentoo users (but not all). The problem is unpleasant, but the solution turned out to be very simple. In the official portage, the Galculator will stop falling only after some time, incl. while you can use my solution.
In order to at least somehow fill the article with intelligence, I will show by the example of a specific problem:
1. How to make my ebuild-file.
2. How to organize your repository of ebuilds. It will come in handy just in a similar case, which has become the topic of the article.
In addition, I would be glad if the geno-mentors told me where to read about how to behave in a similar situation. Where is it better to post patches to ebuilds (and is it worth doing at all), how to design these patches, what are the design features, etc.
I will say in advance that the article will be useful and interesting only to those who at least have already assembled a system for themselves on their own.
To get started, here is the link to bug # 463459 in Gentoo Bugzilla: tynts.
Not everyone reproduces the problem. At me - it is perfectly reproduced.
The problem is that when you try to perform some operations in the Galculator, the latter crashes. Gdb provides such a backtrace .
At first I sinned on the multiple emerge of critical packages without rebuilding the world. But then circumstances nevertheless pinned me to the wall and I rebuilt the world. The calculator still crashed.
Googling quickly brought me to the page at the link above. At the end of the discussion, Simon, one of the maintainers of the Galculator, reported that he rewrote the part of the code that used malloc and g_free at the same time (i.e., memory allocation functions located in different libraries). Memory for objects was allocated by functions of one library, and freed by functions of another. It looked believable. The message immediately after confirmed that the problem was precisely that (strictly speaking, this cannot be considered proven; take it by default as "most likely"). However, there is still no release of the calculator, there would be no new ebuild.
However, even before that, it was experimentally found out that disabling the quadmath library solves the problem. This, frankly, is surprising, but it was confirmed on my car. The bad thing is that the Galculator package itself allows you to build yourself without quadmath, and ebuild does not use this feature. It generally does not have a single USE flag. The situation is deadlock and stupid: there is an SVN in which the working version lies; there is even a flag that feeds to the configure script, you can get rid of the problem in a magical way. But there’s no way to take advantage of any of these features without going beyond the Gentoo build system ...
There is no solution only if you only use what the Gentoo repository provides. However, if you even have a little command of Shell and are able to find answers to questions in structured documentation, then the problem is solved.
“Why don't I take and fix the ebuild file for Galculator, adding the necessary functionality to it?” - prompts the inner voice.
Do not do this. The next emerge --sync will overwrite your changes. Intuition suggests that it should be possible to create a local sandbox of builds. And such an opportunity really exists.
If you still do not know what layman is, then read about it. Everything is quite simple. When installing layman, you have an additional ebuild repository working according to a slightly different scheme than the production repository. A detailed explanation of what layman and overlay are not included in my boards. To solve our problem, it is enough to know that, after installing layman, you can safely create your own folder / usr / local / portage / # {username} and drop your assemblies there, no one will grind them.
In this case, the solution to the problem is as follows:
Of the above commands, I will comment on only two.
edit - this command does not call any specific editor. It invokes the editor specified in the EDIT environment variable. If you still have not configured this variable and you do not use the edit command, then part of the blame for global warming lies with you!
ebuild galculator-2.1.3.ebuild digest - with this command we sign our corrections to confirm that the corrections did not occur due to problems with the hard disk or the effect of random editing of configs.
Now about what exactly needs to be written in the ebuild file. In a good way, one would have to issue an entire article on how to write ebuild files. And I would be glad if someone did this for me. I would love to read. But, alas, I have not seen such an accessible and, at the same time, competent article. Therefore, you have to use the original, from the manufacturer . She, however, for a slightly more advanced user would not be bad. For now, I have to give here just a code of what you need to insert.
Initially, the ebuild Galculator does not contain any build instructions. Everything is done in the default manner. We need to change the configuration method. To do this, we will add the src_configure () function to the file, which is called just to configure the package.
ebuilds are just shell scripts. There are certain conventions about the format in which these scripts are written. These conventions ultimately boil down to three things:
1. What list of functions should be declared in the file, which function is called at what moment, and what it is for.
2. What variables should be defined in the file, what are their names and what do they mean (when and how are they used).
In addition, of course, we have libraries that implement template actions. econf - call configure script, elog - display a message in the build log, etc.
In this case, we use the gnome2_src_configure function instead of the standard econf. Apparently, all packages from the gnome2 collection have similar configuration methods, and they wrote a function for them that already calls econf inside. I discovered this simply by looking at an ebuild of a similar package set to the libraries used.
Our main goal is to add the ability to assemble with the option “--disable - quadmath”. --disable- *, --enable- *, --with- * and --without- * are standard configure options. Therefore, for them there should be ready-made wrappers. And they are. There is one wrapper for enable / disable - use_enable. This function will return --enable - # {flag} if “flag” was set in the list of USE flags during assembly, and --disable - # {flag} otherwise. What you need. It remains only to inform the description of the list of flags used by the package that our package uses the quadmath flag and the default value of this flag is disable. It is done like this:
Done.
In fact, Gentoo is a very large, highly organized organization. Like any large, not young organization, it has many generally accepted things that are difficult to get to know when reading manuals. Something is described there, but not all. The Gentoo developer is actually a post. The developer is provided with work mail, a work account on the server, and many other convenient tools. One procedure for accepting developers is worth the whole article if there were people who found this interesting.
I had already moved from a LFS distribution to Gentoo a year ago, and recently I finally decided that this is what I need. Therefore, I want to become an active member of the Gentoo community. If there are Gentoo mentors on the hub, I would be grateful for the opportunity to take me under my patronage for joining the Gentoo Developers.
Good luck
Today I want to write about one small problem and its solution. The problem concerns Linux users who, after one of the latest updates, the Galculator began to fall. I can not vouch for the accuracy of the information, but it seems that in some magical way this applies only to Gentoo users (but not all). The problem is unpleasant, but the solution turned out to be very simple. In the official portage, the Galculator will stop falling only after some time, incl. while you can use my solution.
In order to at least somehow fill the article with intelligence, I will show by the example of a specific problem:
1. How to make my ebuild-file.
2. How to organize your repository of ebuilds. It will come in handy just in a similar case, which has become the topic of the article.
In addition, I would be glad if the geno-mentors told me where to read about how to behave in a similar situation. Where is it better to post patches to ebuilds (and is it worth doing at all), how to design these patches, what are the design features, etc.
I will say in advance that the article will be useful and interesting only to those who at least have already assembled a system for themselves on their own.
Description of the problem
To get started, here is the link to bug # 463459 in Gentoo Bugzilla: tynts.
Not everyone reproduces the problem. At me - it is perfectly reproduced.
The problem is that when you try to perform some operations in the Galculator, the latter crashes. Gdb provides such a backtrace .
At first I sinned on the multiple emerge of critical packages without rebuilding the world. But then circumstances nevertheless pinned me to the wall and I rebuilt the world. The calculator still crashed.
Googling quickly brought me to the page at the link above. At the end of the discussion, Simon, one of the maintainers of the Galculator, reported that he rewrote the part of the code that used malloc and g_free at the same time (i.e., memory allocation functions located in different libraries). Memory for objects was allocated by functions of one library, and freed by functions of another. It looked believable. The message immediately after confirmed that the problem was precisely that (strictly speaking, this cannot be considered proven; take it by default as "most likely"). However, there is still no release of the calculator, there would be no new ebuild.
However, even before that, it was experimentally found out that disabling the quadmath library solves the problem. This, frankly, is surprising, but it was confirmed on my car. The bad thing is that the Galculator package itself allows you to build yourself without quadmath, and ebuild does not use this feature. It generally does not have a single USE flag. The situation is deadlock and stupid: there is an SVN in which the working version lies; there is even a flag that feeds to the configure script, you can get rid of the problem in a magical way. But there’s no way to take advantage of any of these features without going beyond the Gentoo build system ...
Solving a problem or how the Chukchi became a writer
There is no solution only if you only use what the Gentoo repository provides. However, if you even have a little command of Shell and are able to find answers to questions in structured documentation, then the problem is solved.
“Why don't I take and fix the ebuild file for Galculator, adding the necessary functionality to it?” - prompts the inner voice.
Do not do this. The next emerge --sync will overwrite your changes. Intuition suggests that it should be possible to create a local sandbox of builds. And such an opportunity really exists.
If you still do not know what layman is, then read about it. Everything is quite simple. When installing layman, you have an additional ebuild repository working according to a slightly different scheme than the production repository. A detailed explanation of what layman and overlay are not included in my boards. To solve our problem, it is enough to know that, after installing layman, you can safely create your own folder / usr / local / portage / # {username} and drop your assemblies there, no one will grind them.
In this case, the solution to the problem is as follows:
mkdir /usr/local/portage/#{username}
cp -rv /usr/portage/sci-calculators/galculator /usr/local/portage/#{username}
cd /usr/local/portage/#{username}/galculator
edit galculator-2.1.3.ebuild
ebuild galculator-2.1.3.ebuild digest
emerge --unmerge galculator
emerge -av #{username}/galculator
Of the above commands, I will comment on only two.
edit - this command does not call any specific editor. It invokes the editor specified in the EDIT environment variable. If you still have not configured this variable and you do not use the edit command, then part of the blame for global warming lies with you!
ebuild galculator-2.1.3.ebuild digest - with this command we sign our corrections to confirm that the corrections did not occur due to problems with the hard disk or the effect of random editing of configs.
Now about what exactly needs to be written in the ebuild file. In a good way, one would have to issue an entire article on how to write ebuild files. And I would be glad if someone did this for me. I would love to read. But, alas, I have not seen such an accessible and, at the same time, competent article. Therefore, you have to use the original, from the manufacturer . She, however, for a slightly more advanced user would not be bad. For now, I have to give here just a code of what you need to insert.
Initially, the ebuild Galculator does not contain any build instructions. Everything is done in the default manner. We need to change the configuration method. To do this, we will add the src_configure () function to the file, which is called just to configure the package.
src_configure() {
gnome2_src_configure $(use_enable quadmath)
}
ebuilds are just shell scripts. There are certain conventions about the format in which these scripts are written. These conventions ultimately boil down to three things:
1. What list of functions should be declared in the file, which function is called at what moment, and what it is for.
2. What variables should be defined in the file, what are their names and what do they mean (when and how are they used).
In addition, of course, we have libraries that implement template actions. econf - call configure script, elog - display a message in the build log, etc.
In this case, we use the gnome2_src_configure function instead of the standard econf. Apparently, all packages from the gnome2 collection have similar configuration methods, and they wrote a function for them that already calls econf inside. I discovered this simply by looking at an ebuild of a similar package set to the libraries used.
Our main goal is to add the ability to assemble with the option “--disable - quadmath”. --disable- *, --enable- *, --with- * and --without- * are standard configure options. Therefore, for them there should be ready-made wrappers. And they are. There is one wrapper for enable / disable - use_enable. This function will return --enable - # {flag} if “flag” was set in the list of USE flags during assembly, and --disable - # {flag} otherwise. What you need. It remains only to inform the description of the list of flags used by the package that our package uses the quadmath flag and the default value of this flag is disable. It is done like this:
IUSE="-quadmath"
Done.
Afterword
In fact, Gentoo is a very large, highly organized organization. Like any large, not young organization, it has many generally accepted things that are difficult to get to know when reading manuals. Something is described there, but not all. The Gentoo developer is actually a post. The developer is provided with work mail, a work account on the server, and many other convenient tools. One procedure for accepting developers is worth the whole article if there were people who found this interesting.
I had already moved from a LFS distribution to Gentoo a year ago, and recently I finally decided that this is what I need. Therefore, I want to become an active member of the Gentoo community. If there are Gentoo mentors on the hub, I would be grateful for the opportunity to take me under my patronage for joining the Gentoo Developers.
Good luck