📜 ⬆️ ⬇️

Galculator Segfolt 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 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, and the solution was very simple. In the official portage Galculator will stop falling only after a while, t.ch. while you can use my solution.

In order to somehow fill the article with intelligence, I will show the example of a specific problem:
1. How to make your ebuild file.
2. How to organize your ebuilds repository. It is useful just in such a case, which became the topic for the article.
')
In addition, I would be happy if the gento-mentors told me where to read about how to behave in a similar situation. Where better to post patches to ebuilds (and whether to do it at all), how to make out these patches, what are the features of design, etc.

I will say in advance that the article will be useful and interesting only to those who at least have already assembled the system themselves.



Description of the problem


To get started, here is a link to bug # 463459 in Gentoo Bugzilla: tynts.
The problem is not reproduced at all. I - perfectly reproduced.

The problem is that when you try to perform some operations in Galculator, the latter falls. Gdb gives such a backtrace .

At first I sinned on multiple emerge of critical packages without rebuilding the world. But then the circumstances still put me against the wall and I rebuilt the world. The calculator still fell.

Googling quickly brought me to the page using the link above. At the end of the discussion, Simon - one of the Galculator maintainers - reported that he rewrote that part of the code that used malloc and g_free at the same time (i.e. memory allocation functions found in different libraries). The memory for objects was allocated by functions of one library, and released by functions of another. It looked believable. The message immediately after confirmed that the problem was precisely this (strictly speaking, this cannot be considered proven; take it in default as “most likely”). However, there is still no release of the calculator, and there would be no new ebuild.

However, even before this, we found out by experience that turning off the quadmath library solves the problem. This, frankly, is surprising, but it was confirmed on my car. The bad thing is that Galculator itself allows you to build yourself without quadmath, and ebuild does not use this feature. He does not have a single USE flag at all. The situation is a dead end and stupid: there is SVN, which is the working version; there is even a flag that feeds the configure script to get rid of the problem in a magical way. But it’s not possible to take advantage of any of these opportunities without going beyond the Gentoo build system ...

Solution of the problem or how the Chukchi became a writer


There is no solution only if you are only using what the Gentoo repository provides. However, if you own a little Shell and know how 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?” Suggests an inner voice.

Do not do this. When you next emerge --sync your changes will fray. Intuition suggests that it should be possible to create a local sandbox of builds. And this opportunity really exists.

If you don’t know what layman is, read about it . Everything is quite simple. When you install layman, you get an additional ebuild repository that works in a slightly different way than the production repository. A detailed explanation of what layman and overlay are is not included in my fees. To solve our problem, it’s enough to know that after installing layman, you can safely create your own / usr / local / portage / # {username} folder 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 


From the given commands I will comment only two.

edit - this command does not call any specific editor. It calls the editor specified in the EDIT environment variable. If you still have not set 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 because of problems with the hard disk drives or the effect of accidentally editing configs.

Now that specifically it is necessary to write to the ebuild file. In a good way, you would have to release a whole article on how to write ebuild files. And I would be glad if someone did it for me. 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 . It, however, for a slightly more advanced user would not be bad. I still have to bring here just the code of what needs to be inserted.

Initially, Galculator's ebuild does not contain any build instructions. Everything is done in a 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 simply shell scripts. There are certain agreements on the format in which these scripts are written. These agreements are ultimately reduced to three things:
1. What list of functions should be declared in the file, which function is called at what moment and what is it intended for.
2. What variables should be defined in the file, what their names are and what they mean (when and how they are used).

In addition, of course, we have libraries that implement template actions. econf - call the configure script, elog - output the message to the build log, etc.

In this case, we use the gnome2_src_configure function instead of the standard econf. Apparently, all the packages from the gnome2 collection have similar configuration methods and they have written a function for them that already calls econf inside. I found this just by looking at an ebuild similar in terms of the package library used.

Our main task is to add the ability to build with the option "--disable - quadmath". --disable- *, --enable- *, --with- * and --without- * are standard configure options. Therefore, for them 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 when building, and --disable - # {flag} otherwise. That is necessary. 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. This is done like this:

 IUSE="-quadmath" 


Is done.

Afterword


In fact, Gentoo is a very large, strictly organized organization. Like any large, not young organization, it has many generally accepted things that are difficult to get acquainted with when reading manuals. It describes something, but not all. Gentoo developer is actually a position. The developer is provided with working mail, a working account on the server and many other convenient tools. One procedure for accepting to developers is worth a whole article if there were people who found this interesting.

I have been moving from a LFS distribution to Gentoo for a year now 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 Habré, I would be grateful for the opportunity to take me under my patronage to join Gentoo Developers.

Good luck!

Source: https://habr.com/ru/post/236205/


All Articles