dell / dkms

Dynamic Kernel Module Support
GNU General Public License v2.0
627 stars 145 forks source link

In the loop, why is it a read-only variable? #426

Open wubo0067 opened 1 week ago

wubo0067 commented 1 week ago

In the function make_tarball, it polls the elements in the array kernelver. Why are intree_module_dir and temp_module_dir read-only type variables?

make_tarball()
{
    ......
    for ((i=0; i<${#kernelver[@]}; i++)); do
        local -r intree_module_dir="$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}"
        local -r temp_module_dir="$temp_dir_name/dkms_main_tree/${kernelver[$i]}"

If it is a read-only variable, then using --all or specifying multiple -k kernel versions, only one kernel version will be packaged.

 ⚡ root@localhost  /usr/src  dkms mktarball -m i40e -v 2.25.9 --all
Marking modules for 4.18.0-425.3.1.el8.x86_64 (x86_64) for archiving...
/usr/sbin/dkms: line 1906: local: intree_module_dir: readonly variable
/usr/sbin/dkms: line 1907: local: temp_module_dir: readonly variable
Marking modules for 4.18.0-425.19.2.el8_7.x86_64 (x86_64) for archiving...

Marking /var/lib/dkms/i40e/2.25.9/source for archiving...
xuzhen commented 1 week ago

There is already a PR for this: https://github.com/dell/dkms/pull/415

wubo0067 commented 1 week ago

The file name also needs to be optimized. If there are multiple -k or --all, it becomes too long, for example: _i40e-2.25.9-kernel4.18.0-425.3.1.el8.x86_64-x86_64-kernel4.18.0-425.19.2.el8_7.x86_64-x8664.dkms.tar

evelikov commented 1 week ago

@wubo0067 as mentioned in the PR, do you mind adding a test so we don't re-introduce this in the future?

I'm not sure what you mean by "The file name also needs to be optimized" - if you can submit a PR that would be appreciated.

wubo0067 commented 1 week ago

@evelikov 1: Honestly, I'm not sure what kind of tests meet your requirements. If you have examples, I can give it a try. 2: Filename optimization refers to the situation where, under -k or -all, if there are multiple kernel patch versions in the system, the generated xxx.dkms.tar filename will be very long. I want to think about how to optimize it and try to make a PR.