Gentoo emerge: Failed Running automake

This article is for Gentoo build problem:

Failed Running automake

but basically the problem could occur in any Linux system and the solution is logically the same.
During our @world update our emerge failed on:

>>> Emerging (44 of 95) dev-libs/libmemcached-1.0.18-r3::gentoo
 * libmemcached-1.0.18.tar.gz BLAKE2B SHA512 size 😉 ...                                                                                                            [ ok ]
>>> Unpacking source...
>>> Unpacking libmemcached-1.0.18.tar.gz to /var/tmp/portage/dev-libs/libmemcached-1.0.18-r3/work
>>> Source unpacked in /var/tmp/portage/dev-libs/libmemcached-1.0.18-r3/work
>>> Preparing source in /var/tmp/portage/dev-libs/libmemcached-1.0.18-r3/work/libmemcached-1.0.18 ...
 * Applying debug-disable-enable-1.0.18.patch ...                                                                                                                    [ ok ]
 * Applying continuum-1.0.18.patch ...                                                                                                                               [ ok ]
 * Applying libmemcached-1.0.18-gcc7.patch ...                                                                                                                       [ ok ]
 * Running eautoreconf in '/var/tmp/portage/dev-libs/libmemcached-1.0.18-r3/work/libmemcached-1.0.18' ...
 * Running libtoolize --install --copy --force --automake ...                                                                                                        [ ok ]
 * Running aclocal -I m4 -I libtest/m4 ...                                                                                                                           [ ok ]
 * Running autoconf --force ...                                                                                                                                      [ ok ]
 * Running autoheader ...                                                                                                                                            [ ok ]
 * Running automake --add-missing --copy --foreign --force-missing ...                                                                                               [ !! ]

 * Failed Running automake !
 * 
 * Include in your bugreport the contents of:
 * 
 *   /var/tmp/portage/dev-libs/libmemcached-1.0.18-r3/temp/automake.out

 * ERROR: dev-libs/libmemcached-1.0.18-r3::gentoo failed (prepare phase):
 *   Failed Running automake !
 * 
 * Call stack:
 *     ebuild.sh, line  124:  Called src_prepare
 *   environment, line 2214:  Called eautoreconf
 *   environment, line  714:  Called eautomake
 *   environment, line  668:  Called autotools_run_tool 'automake' '--add-missing' '--copy' '--foreign' '--force-missing'
 *   environment, line  532:  Called die
 * The specific snippet of code:
 *           die "Failed Running $1 !";
 * 
 * If you need support, post the output of `emerge --info '=dev-libs/libmemcached-1.0.18-r3::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-libs/libmemcached-1.0.18-r3::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/dev-libs/libmemcached-1.0.18-r3/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-libs/libmemcached-1.0.18-r3/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-libs/libmemcached-1.0.18-r3/work/libmemcached-1.0.18'
 * S: '/var/tmp/portage/dev-libs/libmemcached-1.0.18-r3/work/libmemcached-1.0.18'

>>> Failed to emerge dev-libs/libmemcached-1.0.18-r3, Log file:

We have installed automake, the dependency is OK, there is no need of new version of automake (the libmemcached did not required to install a new version as a dependency), but still the build process failed!
automake has many different versions installed on the same system and the problem is that one of your currently installed version is too old, so you must upgrade all versions (from the all different branches installed).
First check what versions are installed (equery is part of app-portage/gentoolkit):

root@srv ~ # equery list automake
 * Searching for automake ...
[I--] [??] sys-devel/automake-1.11.3:1.11
[I--] [??] sys-devel/automake-1.12.6:1.12
[I--] [??] sys-devel/automake-1.13.4:1.13
[I--] [??] sys-devel/automake-1.14.1:1.14
[IP-] [  ] sys-devel/automake-1.15.1-r2:1.15
[IP-] [  ] sys-devel/automake-1.16.1-r1:1.16

We have version from branch 1.11, 1.12, 1.13 and 1.14 – one of these version is causing the problem!
Up until now no package required as a dependency 1.15 and 1.16, so we do not have it installed.

Here we upgrade them all to their latest versions in every branch version:

root@srv ~ # emerge -vu sys-devel/automake:1.11 sys-devel/automake:1.12 sys-devel/automake:1.13 sys-devel/automake:1.14

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild     U  ] sys-devel/automake-1.12.6-r2:1.12::gentoo [1.12.6:1.12::gentoo] USE="-test%" 1368 KiB
[ebuild     U  ] sys-devel/automake-1.11.6-r3:1.11::gentoo [1.11.3:1.11::gentoo] USE="-test%" 896 KiB
[ebuild     U  ] sys-devel/automake-1.14.1-r2:1.14::gentoo [1.14.1:1.14::gentoo] USE="-test%" 1455 KiB
[ebuild     U  ] sys-devel/automake-1.13.4-r2:1.13::gentoo [1.13.4:1.13::gentoo] USE="-test%" 1416 KiB

Total: 4 packages (4 upgrades), Size of downloads: 5133 KiB

As you can see we have updated version in every branch! And after updating them the building of libmemcached passed smoothly!
It’s not only in Gentoo, in most Linux distros (such as Ubuntu, CentOS, Manjaro, Mint and so on) have multiple automake version installed, so if you encounter this problem check your automake version installed for their latest versions and also if you miss some of them.

Gentoo update tips when updating packages with blocks and masked files

It’s not so rear to have

blocks or masked files

when using Gentoo emerge system, but it is not complex and in most cases it is easy to resolve

To summarize it up at the beginning and then we are going to show you other articles using these advises here where you’ll see what are the steps we took to resolve the conflicts and masked packages:

  • Use verbose,verbose-conflicts and backtrack with emerge
  • Remove only big GUI packages, which have really big dependency graph like office suites or development IDEs
  • Remove obsolete packages – you do not need them, they can just make problems when updating, because emerge will take into consideration their requirements and dependencies and your update could be impossible!
  • Do not update everything with one line, you could update only the base libraries like QT, which are very important for the Linux GUI in general
  • Include explicitly packages, which block our updates in the emerge line! You could specify packages with the versions.
  • use tools like “equery” (part of app-portage/gentoolkit) for checking dependencies and/or which packages depend on the queried package. You can use it with specific version for the package. “qlist” (part of app-portage/portage-utils) also is a handful tool.
  • Sometimes when updating a group or a package with big dependency graph it is much easier to drop the -“u” update argument and to rebuild some packages with the updates.
  • In rear cases you can use “–nodeps” when updating or installing a new package (we do not need and show this one here!)
  • Do NOT rebuild the entire system with “emerge -v world” every time when you rebuild glibc, gcc, it is not mandatory to do it to have a healthy system.
  • Add or remove USE flags if needed – emerge will show you information about it. Use package.use, package.mask, package.unmask and so on.
  • use qlist to update/re(build) to pull currently installed packages with some name or category (categories)
    emerge -v $(qlist -IC|grep <NAME>)
    

    and for update just add “u” to “-v”:

    emerge -vu $(qlist -IC|grep <NAME>)
    

Keep on reading!

Gentoo updating KDE – package blocks

In continuing our tips for updating big or multiple packages in Gentoo this time we show how to update KDE Platform, Plasma and Apps packages. In Gentoo KDE Desktop GUI is split into three major categories:

  1. kde-frameworks
  2. kde-plasma
  3. kde-apps

How we managed to update in our current situation:

  1. Sometimes when updating a group or a package with big dependency graph it is much easier to drop the -“u” update argument and to rebuild some packages with the updates.
  2. use qlist to update/re(build) to pull currently installed packages with some name or category (categories)
  3. Remove obsolete packages – you do not need them, they can just make problems when updating, because emerge will take into consideration their requirements and dependencies and your update could be impossible!

More on the subject of update tips here: Gentoo update tips when updating packages with blocks and masked files
Keep on reading!

Gentoo updating perl with many masked and blocked packages

After our previous howto Gentoo – update dev-libs/icu on a desktop box with KDE GUI and many masked packages we want to show you another example of how to update perl, which could have hundreds dependencies installed as perl modules. You can check for more details above howto, details about what to do when there are masked and blocked packages, because here we use only some of the options we have the proper ones for this case.
Just to note when updating perl you must reinstall (recompile, rebuild) all the external modules (additional packages) and all perl modules installed with CPAN module (if you do not know what is this, you probably have not used it so no worries).

How we managed to update in our current situation:

  • use qlist to update/re(build) to pull currently installed packages with some name or category (categories)
  • Add or remove USE flags if needed – emerge will show you information about it. Use package.use, package.mask, package.unmask and so on.
  • Use verbose,verbose-conflicts and backtrack with emerge
  • Include explicitly packages, which block our updates in the emerge line! You could specify packages with the versions.

More on the subject of update tips here: Gentoo update tips when updating packages with blocks and masked files
Keep on reading!

Gentoo emerge a packet with a custom option passed to the configure

Gentoo is source based linux distro and each time we want to install a package in fact we compile it with the system program emerge. In most cases we have USE flags for everything we need about a package, but we can further pass custom options directly to the configure script of the package through the emerge program. Using this method we can tune more subtle the configuration stage of a package and still using the package manager of the system, which is always the preferred way!
For example we can install manually additional libraries in /usr/local/ or any other directory and we can use them passing the needed configuration to the configure script of the package. Let’s say we want to use a new feature of latest openssl library, but we do not want to install it globally and re-emerge everything linked to it, so we build it manually in a directory like /usr/local/openssl-1.1.1/ and we want to link our PHP against it, but the PHP is better to be installed by the emerge (the package manager), because it has many features like init script, global default path to configurations and so on. So we can execute the following command:

EXTRA_ECONF="--with-openssl-dir=/usr/local/openssl-1.1.1/" emerge -avt php

you can use EXTRA_ECONF=”” to include options, which do not have USE flags. However there is limitation, EXTRA_ECONF works only for autotools based ./configure scripts when the ebuild is using econf, so packets not using autotools ./configure scripts won’t include the extra options.
It is good practice to make persistent this configuration over builds, so we can use

/etc/portage/package.env

to save the configuration for future building of the package:

echo "EXTRA_ECONF=\"--with-openssl-dir=/usr/local/openssl-1.1.1/\"" > /etc/portage/env/php.conf
echo "dev-lang/php php.conf" > /etc/portage/package.env

Access Violation error, when compiling packets in Gentoo

Sometimes if you try to emerge a package in Gentoo you could receive error in the configure phase of the compilation process. The example below is with the emerging the PHP – dev-lang/php-5.6.33:5.6::gentoo, but could happen with many other packages, which are rather old and probably not maintained or the sandbox or even the portage packages are old.
So here is the error and the compilation stops:

srv ~ # emerge -av --nodeps "<php-7"
...
checking for mmap() using MAP_ANON shared memory support... yes
checking for mmap() using /dev/zero shared memory support... yes
checking for mmap() using shm_open() shared memory support...  * ACCESS DENIED:  open_wr:      /run/test.shm.8811LBKone
no
checking for mmap() using regular file shared memory support... yes
...
checking for mmap() using MAP_ANON shared memory support... yes
checking for mmap() using /dev/zero shared memory support... yes
checking for mmap() using shm_open() shared memory support...  * ACCESS DENIED:  open_wr:      /run/test.shm.180309hAMbj
no
checking for mmap() using regular file shared memory support... yes
....
Thank you for using PHP.
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing libtool commands
config.status: executing default commands
>>> Source configured.
 * --------------------------- ACCESS VIOLATION SUMMARY ---------------------------
 * LOG FILE: "/var/log/sandbox/sandbox-13466.log"
 * 
VERSION 1.0
FORMAT: F - Function called
FORMAT: S - Access Status
FORMAT: P - Path as passed to function
FORMAT: A - Absolute Path (not canonical)
FORMAT: R - Canonical Path
FORMAT: C - Command Line

F: open_wr
S: deny
P: /run/test.shm.21532Xx6ViE
A: /run/test.shm.21532Xx6ViE
R: /run/test.shm.21532Xx6ViE
C: ./conftest 

F: open_wr
S: deny
P: /run/test.shm.31817hurGxH
A: /run/test.shm.31817hurGxH
R: /run/test.shm.31817hurGxH
C: ./conftest 

F: open_wr
S: deny
P: /run/test.shm.8811LBKone
A: /run/test.shm.8811LBKone
R: /run/test.shm.8811LBKone
C: ./conftest 

F: open_wr
S: deny
P: /run/test.shm.180309hAMbj
A: /run/test.shm.180309hAMbj
R: /run/test.shm.180309hAMbj
C: ./conftest 
 * --------------------------------------------------------------------------------

>>> Failed to emerge dev-lang/php-5.6.33, Log file:

>>>  '/var/tmp/portage/dev-lang/php-5.6.33/temp/build.log'

You could try adding “-sandbox” to feature in “/etc/portage/make.conf”

FEATURES="-sandbox"

But

the sandbox feature is very important and should not be disabled by default.

And that’s why sometime when you disable it with “-sandbox” you still get access violation and you still cannot install/compile the package!
The thing is you see the error and you can fix it easily. The important part is the directory, which causes the error, in the above example with “dev-lang/php”, but could be any other Gentoo package, the problem is the writing permission for files in “/run” directory. So open the configuration file

/etc/sandbox.d/00default

and you’ll see the there is a variable called SANDBOX_WRITE, which accept paths. If you add to this variable at the end the directory “/run” or your access violated directory you’ll be able to install/compile your package with no problems, for the above problem the solution was:

SANDBOX_WRITE="/usr/tmp/conftest:/usr/lib/conftest:/usr/lib32/conftest:/usr/lib64/conftest:/usr/tmp/cf:/usr/lib/cf:/usr/lib32/cf:/usr/lib64/cf:/run"