Skip to content

Instantly share code, notes, and snippets.

@rwcitek
Created December 19, 2014 23:02
Show Gist options
  • Save rwcitek/808f591afaef09025296 to your computer and use it in GitHub Desktop.
Save rwcitek/808f591afaef09025296 to your computer and use it in GitHub Desktop.
Finding DEB packages that should be held back because they will require a reboot to take effect.
# finding DEB packages that should be held back because they will require a reboot to take effect
# get latest state of packages
apt-get clean && apt-get update && apt-get -dy upgrade
# find those needing reboot
cd /var/cache/apt/archives/ && rm -rf DEBIAN
for i in *.deb ; do
echo == ${i}
dpkg-deb -e ${i}
2> /dev/null grep -i -q -e reboot DEBIAN/postinst && echo ${i} hold
rm -rf DEBIAN
done
# examine those requiring reboot
i=zfoo
rm -rf DEBIAN ; dpkg-deb -e ${i}
# list listening services
netstat -plnt | LANG=C sort -t/ -k2,2
# upgrade (dry-run) packages, excluding those needing a reboot (or any others, e.g. those restarting a critical service)
# remove or change the '-s' option to '-y' to do actual upgrade
ls *.deb | xargs -n 1 dpkg-deb --show --showformat='${Package}\n' | grep -v -e zfoo| xargs apt-get -s install
# check what still needs upgrading
apt-get clean && apt-get update && apt-get -s upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment