How to build the latest LibreELEC git under gentoo

  • While trying to build the latest git, I've come up with a few patches that may be useful. I've built the RPi/RPi2 and Generic x86_64 targets.

    BUILDING FOR x86_64:

    After running $ PROJECT=Generic ARCH=x86_64 make image, the first error that appears is with Samba:

    cp: cannot overwrite non-directory '(...)/http://LibreELEC.tv/build.LibreELEC-Generic.x86_64-9.0-devel/image/system/usr/lib64' with directory '(...)/http://LibreELEC.tv/build.LibreELEC-Generic.x86_64-9.0-devel/samba-4.7.4/.install_pkg/usr/lib64'

    This is caused by some perl modules. In http://LibreELEC.tv/packages/network/samba/package.mk, there is already a command to remove then:

    Code: LibreELEC.tv/packages/network/samba/package.mk
    rm -rf $INSTALL/usr/share/perl*

    But this is not enough, because while some systems install perl modules into /usr/share/, some install then into /usr/lib*/. Thus I've had to insert the following lines in the package.mk for samba:

    Code: LibreELEC.tv/packages/network/samba/package.mk
    rm -rf $INSTALL/usr/lib64/perl*
    rmdir $INSTALL/usr/lib64

    This will remove the lib64 directory, but only if the only files under it were the perl modules. This way it will fail again if something else install there. This is a bug but I don't know if with samba, gentoo or libreelec, because this causes the perl files to be installed under /usr/lib64/ under the 32-bit raspberry pi builds!

    After continuing the build, the next error is with open-vm-tools about libdnet:

    ../include/config.h:290:5: error: type of 'strlcpy' does not match original declaration [-Werror=lto-type-mismatch]

    This can be fixed by creating the following patch in http://LibreELEC.tv/packages/network/libdnet/patches/00-fix_strlcpy_strlcat.patch:

    This is because the auto configuration files for libdnet had the wrong type defined for strlcpy and strlcat.

    After resuming the build again, yet another errors happens, this time with the slang package, but this will not happen in every gentoo system:

    onig-module.c:27:10: fatal error: oniguruma.h: No such file or directory

    This is caused by having this library installed under /usr in the host. To fix it, simply disable it by adding this line to http://LibreELEC.tv/packages/devel/slang/package.mk:

    Code: LibreELEC.tv/packages/devel/slang/package.mk
    PKG_CONFIGURE_OPTS_TARGET="--without-onig"

    After this, LibreELEC will build successfully!

    BUILDING FOR RASPBERRY PI/RASPBERRY PI 2:

    This time I didn't look deep into the problems, just worked around them.

    The package nss had trouble building, showing the following error:

    Raspbery Pi: ../../../../dist/Linux4.12_arm_armv6zk-libreelec-linux-gnueabi-gcc-7.2.0_glibc_PTH_OPT.OBJ/lib/libfreebl.a: error adding symbols: Archive has no index; run ranlib to add one

    Raspberry Pi 2: ../../../dist/Linux4.12_arm_armv7ve-libreelec-linux-gnueabi-gcc-7.2.0_glibc_PTH_OPT.OBJ/lib/libfreebl.a: error adding symbols: Archive has no index; run ranlib to add one

    All that I did was run ranlib in the libraries:

    Raspberry Pi: LibreELEC.tv $ ./build.LibreELEC-RPi.arm-9.0-devel/toolchain/bin/armv6zk-libreelec-linux-gnueabi-ranlib ./build.LibreELEC-RPi.arm-9.0-devel/nss-3.29.5/dist/Linux4.12_arm_armv6zk-libreelec-linux-gnueabi-gcc-7.2.0_glibc_PTH_OPT.OBJ/lib/libfreebl.a

    Raspberry Pi 2: LibreELEC.tv $ ./build.LibreELEC-RPi2.arm-9.0-devel/toolchain/bin/armv7ve-libreelec-linux-gnueabi-ranlib ./build.LibreELEC-RPi2.arm-9.0-devel/nss-3.29.5/dist/Linux4.12_arm_armv7ve-libreelec-linux-gnueabi-gcc-7.2.0_glibc_PTH_OPT.OBJ/lib/libfreebl.a

    After this, the error kept happening. Here is the list of libraries that I've had to run ranlib on:

    libfreebl.a

    libdbm.a

    libnssckfw.a

    libnssb.a

    libsmime.a

    libssl.a

    libnss.a

    libsectool.a

    libpkcs12.a

    libpkcs7.a

    libcerthi.a

    libcryptohi.a

    libpk11wrap.a

    libsoftokn.a

    libcertdb.a

    libnsspki.a

    libnssdev.a

    libpkixtop.a

    libpkixutil.a

    libpkixsystem.a

    libpkixcrlsel.a

    libpkixmodule.a

    libpkixstore.a

    libpkixparams.a

    libpkixchecker.a

    libpkixpki.a

    libpkixresults.a

    libpkixcertsel.a

    libcrmf.a

    libjar.a

    I couldn't run ranlib in all of them at the same time, because some were not created yet. But after a few, they would all appear and the same time and I could run all the remaining commands in one go.

    That's it! Everything worked perfectly.

    (By the way, the build command is outdated in the wiki for RPi)

    Edited once, last by eluancm: typos (February 2, 2018 at 12:03 AM).

  • well that sounds nice but for a long time i've been running into this squashfs error:

    see my post about this

    i run this on a pretty much up-to-date ~amd64-system.

    i even installed docker to try to compile libreelec inside the "ubuntu-chroot" but after adding several more layers of complexity it does not compile there, either (different errors, not squashfs.)

    do you happen to have any idea about how to fix the squashfs-error?

  • I would recommend setting up a virtual machine running exactly the version documented here. The machine does not need very much RAM (4GB is perfectly sufficient) and you have a well-defined environment. First build will take about three hours, but this amount of time is also wasted quite quickly when investigating weird build problems.

  • THX for your replies and sorry for getting back so late - this is kind of a sparetime-project for me.

    On Gentoo i just never get past the squashfs-error - no matter what i try and docker is a complex beast (which - among other things - made me recompile the kernel MANY times on my gentoo-buildhost).

    But i just successfully built under Debian Buster (the recommended Ubuntu is just not for me) which easily installed in a btrfs-subvol using dev-util/debootstrap from portage. So i'm happy right now and maybe i'll try building on Gentoo some other time.