Skip to content

Instantly share code, notes, and snippets.

@frap129
Last active February 9, 2022 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frap129/52aecac6e82194e8a8953dd756a0bf03 to your computer and use it in GitHub Desktop.
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.
#!/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