genkernel icon indicating copy to clipboard operation
genkernel copied to clipboard

modularize features

Open timkenhan opened this issue 1 year ago • 24 comments

Makes features (e.g. xfsprogs, e2fsprogs, plymouth, luks, etc) more self-contained thru the new GK_FEATURES variable

Some changes on the ebuild script will be necessary to accommodate this change.

To ensure working initramfs will always be generated, even without GK_FEATURES set, some basic functionalities such as busybox, firmware, and kernel modules will always be included.

I am aware this work is far from finish, and thus am open for input!

Some (minor) blockers:

  • I'm having issues separating NFS & netboot features since it's quite tightly coded with busybox stuff within the script
  • despite dmraid, lvm, luks, and multipath resides on their own, append_data 'devicemanager' "${DMRAID}" "${LVM}" "${LUKS}" "${MULTIPATH}" is on the main file.

timkenhan avatar Sep 19 '23 12:09 timkenhan

@reagentoo @FlyingWaffleDev feel free to toy around with this!

timkenhan avatar Sep 19 '23 12:09 timkenhan

Hi. Thank you for your effort! What are the purposes of these changes?

  1. Reducing the initrd image size?
  2. Accelerate initrd image loading?
  3. Accelerating initrd image generation?
  4. Make code easier to understand?
  5. Improved code stability?
  6. Improve security?

reagentoo avatar Sep 20 '23 06:09 reagentoo

I say making the code easier to understand, especially for adding new features. For example, in the recent implementation of Plymouth feature, @FlyingWaffleDev would need to figure out where to put what within multiple files of which each file can have hundreds of lines. With this change, only one file would need to be added.

The user (or the packager) can also choose which features to have in the genkernel executables. I intend to pair this with USE flag to give Gentoo users ability to pick and choose.

timkenhan avatar Sep 20 '23 07:09 timkenhan

If you are saying only about code easier to understand, why did you make the code generation?

reagentoo avatar Sep 20 '23 07:09 reagentoo

It's not only about making the code easier to understand. It's also about giving users ability to pick and choose features on their executables.

timkenhan avatar Sep 20 '23 07:09 timkenhan

As for the readability, I am making the source files less monolithic, thus letting developers able to do their work without sifting thru hundreds (or thousands) lines of code.

timkenhan avatar Sep 20 '23 07:09 timkenhan

It's also about giving users ability to pick and choose features on their executables.

Does this "choising ability for users" improves at least 1 point out of those six? https://github.com/gentoo/genkernel/pull/52#issuecomment-1727058678

As for the readability, I am making the source files less monolithic, thus letting developers able to do their work without sifting thru hundreds (or thousands) lines of code.

I don't agree. Any genkernel's shell file within 100kb.

reagentoo avatar Sep 20 '23 09:09 reagentoo

i guess it does, but not directly (since if an option is included, it can still be turned off).

100kb is massive for a textfile. Some of the scripts would reach 1k loc.

it is also more prone to conflict we have fewer big files, as compared with many small files.

timkenhan avatar Sep 20 '23 09:09 timkenhan

This should at least let us make some of the large distfiles in the ebuild optional too as they'll be real build system options rather than useless USE flags just toggling a download.

thesamesam avatar Sep 27 '23 04:09 thesamesam

This should at least let us make some of the large distfiles in the ebuild optional too as they'll be real build system options rather than useless USE flags just toggling a download.

To implement this, it is not necessary to do code generation and divide normal-sized sources into a bunch of small files.

reagentoo avatar Sep 27 '23 07:09 reagentoo

This should at least let us make some of the large distfiles in the ebuild optional too as they'll be real build system options rather than useless USE flags just toggling a download.

To implement this, it is not necessary to do code generation and divide normal-sized sources into a bunch of small files.

It is to have USE flags which aren't there for the sake of it. But besides, I agree with the general splitting up of things here. The files are huge and dividing things up (forcing us to think about their interface) is not a bad thing.

thesamesam avatar Sep 27 '23 07:09 thesamesam

forcing us to think about their interface

There is no need to do such code generation for the interface (using awk 🤦‍♂️). It is enough to use smth like:

source ${module}
interface_func_${module}
interface_var+=( "item" )

reagentoo avatar Sep 27 '23 08:09 reagentoo

forcing us to think about their interface

There is no need to do such code generation for the interface (using awk 🤦‍♂️). It is enough to use smth like:

I suggest making more constructive, polite comments.

source ${module}
interface_func_${module}

Sure, propose that then.

thesamesam avatar Sep 27 '23 08:09 thesamesam

@reagentoo: If you read the awk script, you'd see the reason I did the way I did was so that we can generate any section with the same piece of code. There's also no need to install an extra package since awk is required for most system packages anyway. Can I ask what you mean by "no need for the code generation"? What is wrong with awk?

timkenhan avatar Sep 27 '23 08:09 timkenhan

Can I ask what you mean by "no need for the code generation"?

Are there really no other approaches to creating an interface and modules?

What is wrong with awk?

Can you give an examples of a good practice for using awk in this way? Worse than awk - only perl.

reagentoo avatar Sep 27 '23 11:09 reagentoo

Are there really no other approaches to creating an interface and modules?

I guess we can have the master code calling the module code, but that would take further approach. We need to start with some degree of separation to move forward. I'd be open to suggestion on the implementation detail.

Can you give an examples of a good practice for using awk in this way? Worse than awk - only perl.

Please answer the question, what is wrong with awk? I simply need a tool for processing text, and awk simply fulfils my need with its specialized language for text processing. Once again, I am open for suggestion.

timkenhan avatar Sep 28 '23 06:09 timkenhan

Please answer the question, what is wrong with awk?

Everything is fine with awk, just like with perl.

Once again, I am open for suggestion.

I suggest to not use text processing.

I'd be open to suggestion on the implementation detail.

I'm sure that you can get by with the built-in sh/bash capabilities for organizing modules and interfaces (w/o text generation).

reagentoo avatar Sep 28 '23 07:09 reagentoo

@thesamesam lemme know if you have other feedbacks :)

timkenhan avatar Oct 06 '23 14:10 timkenhan

Overall I like the concept you're proposing here. I'm worried about the long-term maintainability of the split implementation. One immediate loss is that we can no longer quickly do shellcheck to detect bugs - because it can only check the output files.

Make also isn't suited to this type of text munging. M4 might work, but I wouldn't wish it on anybody.

robbat2 avatar Oct 10 '23 17:10 robbat2

@robbat2 Thank you for your massive list of feedback! This should deepen my understandin of Makefiles. I'll address them as soon as I can.

What we have here is basically the proof of concept to demonstrate that this can work. To be honest, I find the implementation itself to have a long way to go. The feature file format is far from perfect, but it is one I could come up with. Let me know if you have better ideas!

timkenhan avatar Oct 11 '23 03:10 timkenhan

hi @robbat2, I've made some restructuring changes on the features. I hope that this would suffice to address your concerns above.

timkenhan avatar Oct 17 '23 11:10 timkenhan

Robin's travelling until the end of the month btw (https://dev.gentoo.org/devaway/)

thesamesam avatar Oct 21 '23 13:10 thesamesam

Thanks for the heads-up, @thesamesam!

timkenhan avatar Oct 23 '23 06:10 timkenhan

@thesamesam @robbat2 any word on how we can proceed?

timkenhan avatar Nov 13 '23 06:11 timkenhan