• Re: [gentoo-dev] [PATCH] linux-mod.eclass: Support module compression

    From Ionen Wolkens@21:1/5 to Mike Pagano on Fri Jun 10 12:30:02 2022
    On Thu, Jun 09, 2022 at 06:11:00PM -0400, Mike Pagano wrote:
    The Linux kernel supports the compression of modules utilizing GZIP, XZ
    and ZSTD. Add code into linux-mod.eclass to support this for out of
    tree modules utilizing the compression binary specified in the kernel
    config.

    Note that if the binary which provides the compression is not present on
    the system the kernel would have failed to build with an error
    indicating the missing binaries name.

    Signed-off-by: Mike Pagano <mpagano@gentoo.org>
    ---
    eclass/linux-mod.eclass | 17 ++++++++++++++++-
    1 file changed, 16 insertions(+), 1 deletion(-)

    diff --git a/eclass/linux-mod.eclass b/eclass/linux-mod.eclass
    index 6a820371b..b7c13cbf7 100644
    --- a/eclass/linux-mod.eclass
    +++ b/eclass/linux-mod.eclass
    @@ -711,7 +711,22 @@ linux-mod_src_install() {
    einfo "Installing ${modulename} module"
    cd "${objdir}" || die "${objdir} does not exist"
    insinto "${INSTALL_MOD_PATH}"/lib/modules/${KV_FULL}/${libdir} - doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed"
    +
    + # check here for CONFIG_MODULE_COMPRESS_<compression option> (NONE, GZIP, XZ, ZSTD)
    + # and similarily compress the module being built if != NONE.
    +
    + if linux_chkconfig_present MODULE_COMPRESS_XZ; then
    + xz ${modulename}.${KV_OBJ}
    + doins ${modulename}.${KV_OBJ}.xz || die "doins ${modulename}.${KV_OBJ}.xz failed"
    + elif linux_chkconfig_present MODULE_COMPRESS_GZIP; then
    + gzip ${modulename}.${KV_OBJ}
    + doins ${modulename}.${KV_OBJ}.gz || die "doins ${modulename}.${KV_OBJ}.gz failed"
    + elif linux_chkconfig_present MODULE_COMPRESS_ZSTD; then
    + zstd ${modulename}.${KV_OBJ}
    + doins ${modulename}.${KV_OBJ}.zst || die "doins ${modulename}.${KV_OBJ}.zst failed"
    + else
    + doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed"
    + fi

    This is copied from what the ebuild used to do, but doins already dies
    on its own and report what file failed. Be a good occasion to clean
    that up rather than repeat it.

    What does not die on its own is the compression commands though. doins
    would fail right after, but feels kind of unclear/fragile.

    That aside, I tend to wonder if the kernel build system could be used
    to install (i.e. it'd do compression, signing, etc... at same time,
    and even handle new methods without needing to add them to the eclass).
    But it's not something I looked at for usability, so not picky about
    how to handle this.

    cd "${OLDPWD}"

    generate_modulesd "${objdir}/${modulename}"
    --
    2.35.1





    --
    ionen

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmKjHKUACgkQskQGsLCs QzS/UQgArxJLvlHK7ptromhrF6z6uCt0klyiDHZaoHD7KXmdkOQ79+Kl560L3oIl Bu3Q8RbDeDWaLClYZdp5cSFHIuYFWhMEmhfqvWjofkN9uJ+wjkIEZrHmAeUpLdMy 7ENh5mOG2uI9g0kBe5+vnm75rIZ7Z+GAIay4+qmYh1O9LKSSSzBura2Pith40+o9 qAsz5YS2j3HKqCyldWp9F0mVtnM90dS/uwCxSW6oKUdbt8ao/JUbMO5BVsI5T2Ef LLd3SdOYjipzE/APh3AH+eYT3EUg3eHuC0hhpJU+nBU0jJ0YnJHFXBczwCh5kH0j MEZBoD9yC1H1fRlSB7tWd9BrOW/+FQ==
    =vXe/
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to Ionen Wolkens on Fri Jun 10 12:40:01 2022
    On Fri, Jun 10, 2022 at 06:27:49AM -0400, Ionen Wolkens wrote:
    On Thu, Jun 09, 2022 at 06:11:00PM -0400, Mike Pagano wrote:
    The Linux kernel supports the compression of modules utilizing GZIP, XZ
    and ZSTD. Add code into linux-mod.eclass to support this for out of
    tree modules utilizing the compression binary specified in the kernel config.

    Note that if the binary which provides the compression is not present on the system the kernel would have failed to build with an error
    indicating the missing binaries name.

    Signed-off-by: Mike Pagano <mpagano@gentoo.org>
    ---
    eclass/linux-mod.eclass | 17 ++++++++++++++++-
    1 file changed, 16 insertions(+), 1 deletion(-)

    diff --git a/eclass/linux-mod.eclass b/eclass/linux-mod.eclass
    index 6a820371b..b7c13cbf7 100644
    --- a/eclass/linux-mod.eclass
    +++ b/eclass/linux-mod.eclass
    @@ -711,7 +711,22 @@ linux-mod_src_install() {
    einfo "Installing ${modulename} module"
    cd "${objdir}" || die "${objdir} does not exist"
    insinto "${INSTALL_MOD_PATH}"/lib/modules/${KV_FULL}/${libdir} - doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed"
    +
    + # check here for CONFIG_MODULE_COMPRESS_<compression option> (NONE, GZIP, XZ, ZSTD)
    + # and similarily compress the module being built if != NONE.
    +
    + if linux_chkconfig_present MODULE_COMPRESS_XZ; then
    + xz ${modulename}.${KV_OBJ}
    + doins ${modulename}.${KV_OBJ}.xz || die "doins ${modulename}.${KV_OBJ}.xz failed"
    + elif linux_chkconfig_present MODULE_COMPRESS_GZIP; then
    + gzip ${modulename}.${KV_OBJ}
    + doins ${modulename}.${KV_OBJ}.gz || die "doins ${modulename}.${KV_OBJ}.gz failed"
    + elif linux_chkconfig_present MODULE_COMPRESS_ZSTD; then
    + zstd ${modulename}.${KV_OBJ}
    + doins ${modulename}.${KV_OBJ}.zst || die "doins ${modulename}.${KV_OBJ}.zst failed"
    + else
    + doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed"
    + fi

    This is copied from what the ebuild used to do, but doins already dies
    on its own and report what file failed. Be a good occasion to clean
    that up rather than repeat it.

    What does not die on its own is the compression commands though. doins
    would fail right after, but feels kind of unclear/fragile.

    Actually, could consider the case where the compression command somehow
    left a broken/partial file behind and it gets installed despite error
    return value.


    That aside, I tend to wonder if the kernel build system could be used
    to install (i.e. it'd do compression, signing, etc... at same time,
    and even handle new methods without needing to add them to the eclass).
    But it's not something I looked at for usability, so not picky about
    how to handle this.

    cd "${OLDPWD}"

    generate_modulesd "${objdir}/${modulename}"
    --
    2.35.1





    --
    ionen



    --
    ionen

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmKjHoYACgkQskQGsLCs QzQ7Ywf/WFH81EjKMKjgeHyfLC3uo0BrxXDPhlOPnbBNerCma+iZCSlXwIbKXZLX KFvpDYxAx/5tdAFkbpnAIHwn9HTJ1a9sVK0kifbc0H5j5Ns/kmEdwKTt6Jas7SQc +BGwssuez6JUPn2btqXsYU+lQQuw2PY+YbC6NldePoUUAR0Pyy2SLtvOSi9dpQ8D ga5unI3pbu6+aY6igQ2PKKohS+ilVk5Cp4/N8LPlQF9ni2j1tAT6s7YzzeWPbZwd x9lVVn/0CKJH1tIKC2B96v88PC42vPQs9khz3hY7ChoE/EyEx0eX90F9yYycDTSO AkvEdFl/jyQSH6QumjRmWKw17eEfSw==
    =H1yf
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)