Last active
February 9, 2022 19:28
-
-
Save frap129/52aecac6e82194e8a8953dd756a0bf03 to your computer and use it in GitHub Desktop.
Script to ask user if depencies that were explicitly installed should be marked as dependencies.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
explicitPkgs="$(pacman -Qeq)" | |
# Create list of all dependencies, whether explicitly installed or not | |
allDeps="" | |
for pkg in $explicitPkgs; do | |
allDeps+=" $(pactree -u $pkg | awk 'NR>1')" | |
done | |
depsList="$(echo $allDeps | tr ' ' '\n' | sort | uniq)" | |
# Create new list containing literal dependencies installed explicitly | |
explicitDeps="$(echo $depsList $explicitPkgs | tr ' ' '\n' | sort | uniq -d)" | |
# Ask user if each package should be marked as a dependency | |
for pkg in $explicitDeps; do | |
while true; do | |
read -p "Change $pkg install type from explicit to dependency? [yn] " yn | |
case $yn in | |
[Yy]* ) sudo pacman -D --asdeps $pkg; break;; | |
[Nn]* ) break;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment