Search code examples
buildroot

Install only part of a package in buildroot


I am currently building an autotools-based package for buildroot but I only need some parts of the actual build output (shared libraries and a handful of tools). Is there a way to install only what I need, similar to debian's *.install files when a package should be split up (like a libfoo and libfoo-dev package). If there is no other way, I will have to use the LIBFOO_POST_INSTALL_TARGET_HOOKS but I would like to know if there is a better option.

I know of the LIBFOO_CONFIG_SCRIPTS variable, but this only remove files in the /bin directory and I would like to remove them from other places too (libexec, /var, ...). This method also feels hacky for non-config scripts related to that library.


Solution

  • If there are no autotools configure flags to alter the installation options, one simple method is to patch the Makefile.am as required.

    Here are the steps :

    • Alter the source Makefile.am capturing your changes in a patch(s).
    • Copy your patches to the global patch directory, they will be applied before building the package.
    • Remove the package's output/build directory and rebuild it.
    • At this point, the undesired files will not be installed to the target.

    The more detailed method for doing this is to "make package". Go to the package's src. Run quilt to auto-generate patches for you. Alter the sources (Makefile.am), refresh the patches. Copy the patches back to buildroot's global patch directory. Once done, buildroot will patch Makefile.am then it will generate the appropriate Makefiles and will not install as required.

    Here is an example :

    Assume you have set BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL)/patches"

    make package
    cd output/build/package
    quilt init . # output/build/package/patches now exists
    quilt new 001-Makefile.am.do.not.install.patch
    quilt add src/Makefile.am
    # you edit src/Makefile.am here
    quilt refresh # now patches/001-Makefile.am.do.not.install.patch exists
    mkdir patch/to/global/patches # see BR2_GLOBAL_PATCH_DIR above
    cp patches/*.patch patch/to/global/patches
    cd ../../.. # got back to buildroot root to make
    rm -rf output/build/package
    make package
    

    At this point, your patches should be applied to the src code and the files you removed from the make install process will not be on the target.

    Make sure PACKAGE_AUTORECONF = YES in the package.mk file, it forces buildroot to autoreconf.