[LEDE-DEV] replacing files in base system from a package?

Rafał Miłecki zajec5 at gmail.com
Thu Nov 24 23:14:12 PST 2016


On 16 October 2016 at 01:04, Jo-Philipp Wich <jo at mein.io> wrote:
> let me introduce a not strictly new way but another heavily under
> documented buildroot feature which you can use to implement custom
> modifications to packages which do not require source code edits.
>
> For every processed package Makefile, the buildroot tries to include a a
> Makefile fragment in $(TOPDIR)/overlay/*/$(PKG_DIR_NAME).mk which one
> can use to monkey-patch internals without directly touching the package
> recipes.
>
> For example to amend "base-files" to include a custom banner and
> inittab, you could create an overlay file called
>
>   "overlay/my-example-organization/base-files.mk"
>
> which extends the default Package/base-files/install recipe to copy your
> custom files in the end.

I'm not exactly sure what's the gain from using this method. Normally
I need to fork LEDE repo and modify package/base-files/Makefile. With
your solution I need to fork LEDE repo and add
overlay/my-example-organization/base-files.mk. Both cases require
forking LEDE, maybe with overlay it's just easier to track
my-example-organization changes if you can't use git.

I think a perfect model for organization/company that wants to be LEDE
friendly would be to:
1) Ask them for complete LEDE-upstream support for their device
2) Handle all modifications using an own feed with their packages

This is a pretty clean situation when we know no extra
kernel/main-packages modifications are needed to get device working.
I'd expect overwriting e.g. banner to happen withing sth like
my-example-organization-base-files package.


> Assuming a directory structure like this...
>
>  * overlay/my-example-organization/banner
>  * overlay/my-example-organization/inittab
>  * overlay/my-example-organization/base-files.mk
>
> ... the base-files.mk would need to include something like the following
> code to splicy your custom files into the packaging procedure:
>
> --- 8< ---
> # Figure out the containing dir of this Makefile
> OVERLAY_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
>
> # Declare custom installation commands
> define custom_install_commands
>         @echo "Installing extra files from $(OVERLAY_DIR)"
>         $(INSTALL_DIR) $(1)/etc/config
>         $(INSTALL_DATA) $(OVERLAY_DIR)/banner $(1)/etc/banner
>         $(INSTALL_DATA) $(OVERLAY_DIR)/inittab $(1)/etc/inittab
> endef
>
> # Append custom commands to install recipe,
> # and make sure to include a newline to avoid syntax error
> Package/base-files/install += $(newline)$(custom_install_commands)
> --- >8 ---

The problem I see with this is placing customizations in a LEDE fork
repository. So if one would like to try overlay solution, maybe it'd
be better/cleaner to remove files from base-files?
define custom_install_commands
        @echo "Removing files that will be provided customized"
        rm $(1)/etc/banner
        rm $(1)/etc/inittab
endef

Do you think it'd be a sane usage?



More information about the Lede-dev mailing list