diff options
author | chrisjbillington | 2021-07-04 14:05:26 +1000 |
---|---|---|
committer | chrisjbillington | 2021-07-04 14:05:26 +1000 |
commit | 8a7f66104b6098499809e266c38005d62807eb93 (patch) | |
tree | 15afdad7ec3bb520edb01fca2ac5d7dd2dc9a970 /remove-orphaned-kernels | |
parent | 329c1a498266aa4b9a08ed6c72377af160db578a (diff) | |
download | aur-8a7f66104b6098499809e266c38005d62807eb93.tar.gz |
Fix bug where explicitly installed package would be uninstalled
Diffstat (limited to 'remove-orphaned-kernels')
-rwxr-xr-x | remove-orphaned-kernels | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/remove-orphaned-kernels b/remove-orphaned-kernels index 15e861ea78d3..b8757c07c06d 100755 --- a/remove-orphaned-kernels +++ b/remove-orphaned-kernels @@ -46,12 +46,19 @@ def is_directly_required(pkg): return True return False +def is_explicitly_installed(pkg): + pkginfo = get_output('pacman', '-Qi', pkg) + reason = pkginfo.split('Install Reason')[1].split(':')[1].rsplit('\n', 1)[0].strip() + return reason == 'Explicitly installed' + +def is_orphan(pkg): + return not (is_explicitly_installed(pkg) or is_directly_required(pkg)) running_kernel = get_output('uname', '-r') running_pkgs = get_output('pacman', '-Qoq', f'{MODULES}/{running_kernel}') all_kernels = [f'{MODULES}/{k}' for k in os.listdir(MODULES)] all_pkgs = get_output('pacman', '-Qoq', *all_kernels).split() -orphaned_packages = [pkg for pkg in all_pkgs if not is_directly_required(pkg)] +orphaned_packages = [pkg for pkg in all_pkgs if is_orphan(pkg)] non_orphaned = [] orphaned_not_running = [] |