Skip to content

Instantly share code, notes, and snippets.

@cyanidium
Created October 19, 2014 17:51
Show Gist options
  • Save cyanidium/c87229c534a15852127a to your computer and use it in GitHub Desktop.
Save cyanidium/c87229c534a15852127a to your computer and use it in GitHub Desktop.
For Arch Linux. If you're trying to keep your installed package count under control this might help sort out what you need installed and what was installed by something else.
#!/bin/sh
#
# This script will change any explicity/manually installed packages that are
# dependended on by other packages into packages installed as dependencies. The
# idea is to minimise the manually installed packages throughout upgrades.
#
PACMAN=yaourt
TEMPDIR=$(mktemp -d /tmp/packages.XXXXXXXXXX)
${PACMAN} -Qe > ${TEMPDIR}/manual.lst
${PACMAN} -Qet > ${TEMPDIR}/needed.lst
sort ${TEMPDIR}/manual.lst > ${TEMPDIR}/manual.srt
sort ${TEMPDIR}/needed.lst > ${TEMPDIR}/needed.srt
comm -3 ${TEMPDIR}/manual.srt ${TEMPDIR}/needed.srt | cut -d' ' -f1 | cut -d'/' -f2 > ${TEMPDIR}/really-deps.srt
exit
if [ ! -z $(cat ${TEMPDIR}/really-deps.srt) ]; then
${PACMAN} --noconfirm --asdeps -S $(cat ${TEMPDIR}/really-deps.srt)
fi
rm ${TEMPDIR}/manual.lst ${TEMPDIR}/needed.lst ${TEMPDIR}/manual.srt ${TEMPDIR}/needed.srt ${TEMPDIR}/really-deps.srt
rmdir ${TEMPDIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment