excalibur1234 / pacui

Bash script providing advanced Pacman and Yay/Pikaur/Aurman/Pakku/Trizen/Pacaur/Pamac-cli functionality in a simple UI
GNU General Public License v3.0
168 stars 13 forks source link

func_m: kernel check improvement #25

Closed thefallenrat closed 6 years ago

thefallenrat commented 6 years ago

This commit changes kernel check in func_m :

This commit will hopefully fixes : https://forum.manjaro.org/t/using-pacui-produces-output-related-to-end-of-life-kernels/32550/

Signed-off-by: Rafli Akmal rafliakmaltejakusuma@gmail.com

thefallenrat commented 6 years ago

If you want to test, you can try to disable [core] repo for a while and run the following commands :

installed_kernels=$(pacman -Qsq "^linux" | \
                               grep "linux" | \
                               grep -Ev "sys|util|api|docs|firmware|arch|nvidia|manpages|headers|tools|atm|virtual|rt3|r8|vhba|catalyst|ndiswrapper|bbswitch|broadcom|acpi|spl|zfs|logo|tv|sampler|console" | \
                               sort)

available_kernels=$(pacman -Ssq "^linux" | \
                               grep "linux" | \
                               grep -Ev "sys|util|api|docs|firmware|arch|nvidia|manpages|headers|tools|atm|virtual|rt3|r8|vhba|catalyst|ndiswrapper|bbswitch|broadcom|acpi|spl|zfs|logo|tv|sampler|console" | \
                               sort)

eol_kernels=$(comm -13 <(echo "$available_kernels") <(echo "$installed_kernels"))

echo "$eol_kernels"
excalibur1234 commented 6 years ago

you PR is great, because it makes this option/function compatible with arch linux, too. additionally, it is much shorter.

i see you filtered out all non-kernel packages with a long command. what do you think about using the following command instead (does it work in arch linux)? pacman -Qsq "^linux" | grep "^linux" | grep -v "-" | grep "[0-9]" | sort

p.s.: i will merge this PR tonight and do some testing. even if it does not work, we can break "pacui-git" temporarily. in the AUR, there is also a stable "pacui" version available.

thefallenrat commented 6 years ago

Thank you for your input!

i see you filtered out all non-kernel packages with a long command. what do you think about using the following command instead (does it work in arch linux)? pacman -Qsq "^linux" | grep "^linux" | grep -v "-" | grep "[0-9]" | sort

Sadly no, as they don't have kernel that uses number in it and also they use - right next to linux for almost all of its kernels :

linux
linux-hardened
linux-lts
linux-zen

BUT, I can replace the long string with a variable to make it shorter if you want.. and initialize the variable somewhere

thefallenrat commented 6 years ago

we can break "pacui-git" temporarily

No need to break pacui-git, you may simply create a new branch called devel or something, and I will change target branch for this pull request immediately by simply clicking the "Edit" button

excalibur1234 commented 6 years ago

imho, it is not necessary to create a variable instead of long "grep" command.

i do not like the way to exclude all packages with a similar name to "linux". for example, i have a package installed "linuxdcpp", which was not filtered by your "grep" command, because it is a (broken) AUR package. we would need to adjust that command every time a package with "linux" in its name gets uploaded to the AUR.

what do you think about the following command (which would need less maintenance)? pacman -Qsq "^linux" | egrep "^linux[0-9]*$|^linux$|^linux-hardened$|^linux-lts$|^linux-zen$" this command filters all kernel names in manjaro (^linux[0-9]*$) and all kernel names in arch linux (please add more arch linux kernel names, if you think this is necessary).

thefallenrat commented 6 years ago

what do you think about the following command (which would need less maintenance)? pacman -Qsq "^linux" | egrep "^linux[0-9]*$|^linux$|^linux-hardened$|^linux-lts$|^linux-zen$" this command filters all kernel names in manjaro (^linux[0-9]*$) and all kernel names in arch linux (please add more arch linux kernel names, if you think this is necessary).

Great Idea! But, I have to add another filter as in Manjaro, they have more kernels that are non-number :

linux-rt-lts-manjaro
linux-rt-manjaro
excalibur1234 commented 6 years ago

you are right that adding a new branch is better than breaking the master branch.

i have added a new "devel" branch. please change the target of your PR to that branch as shown here before i can merge it: https://github.com/blog/2224-change-the-base-branch-of-a-pull-request

thefallenrat commented 6 years ago

i have added a new "devel" branch. please change the target of your PR to that branch as shown here before i can merge it: https://github.com/blog/2224-change-the-base-branch-of-a-pull-request

Done!

excalibur1234 commented 6 years ago

can you test, whether the following command also works for the arch linux kernel called "linux" (it should theoretically)? grep -E "^linux[0-9]*$|hardened$|lts$|zen$|rt-lts-manjaro$|rt-manjaro$"

thefallenrat commented 6 years ago

can you test, whether the following command also works for the arch linux kernel called "linux" (it should theoretically)? grep -E "^linux[0-9]*$|hardened$|lts$|zen$|rt-lts-manjaro$|rt-manjaro$"

Yup, it works! And you can even make it shorter than before :

grep -E "^linux[0-9]*$|hardened$|lts$|zen$|rt-(lts-)*manjaro$"
excalibur1234 commented 6 years ago

i have adjusted your code slightly and added comments and code formatting. if you agree, i will merge the devel into master branch.

thanks a lot for improving pacui!

thefallenrat commented 6 years ago

One last thing, can you switch the command inside installed_kernels variable into something like this :

installed_kernels=$(for p in `ls -1 /boot | grep -E '^vmlinuz'`; do pacman -Qoq /boot/$p | sort; done)

This will list all kernels that we have installed, including special kernels that are usually taken from AUR..

~ >>> for p in `ls -1 /boot | grep -E '^vmlinuz'`; do pacman -Qoq /boot/$p | sort; done
linux49
linux-lqx
linux-lts

But, there is one question popped up regarding this method. Will the kernels that resides in /boot will be moved to a new directory for those that uses UEFI for their system? Nvm, it does not...

excalibur1234 commented 6 years ago

this works well in manjaro, thx.

i had to adjust the command slightly, because on my system i have an alias for "ls": https://github.com/excalibur1234/pacui/commit/00306962f962a6ce6cf89f75902227cb40e581a2

Chrysostomus commented 6 years ago

But does checking for EOL kernels make even sense in arch?

thefallenrat commented 6 years ago

Of course not and that is not really my intentions from first place to be honest ( I was trying to fix a bug in that forum thread I linked above).

For checking eol kernels func, I was thinking into something more like :

That's my take anyway

thefallenrat commented 6 years ago

I managed to make the kernel check command sequence not use the grep filter command at all, and I opened a pull request for it:

https://github.com/excalibur1234/pacui/pull/27