Last active
January 15, 2020 22:12
-
-
Save smoser/5823699 to your computer and use it in GitHub Desktop.
apt-go-fast: streamline apt-get by removing things you don't want or need and using eatmydata
This file contains hidden or 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/sh | |
# https://gist.github.com/smoser/5823699 | |
set -e | |
[ "$(id -u)" = "0" ] && sudo="" || sudo="sudo" | |
[ -e "/usr/bin/apt-get.distrib" ] || | |
$sudo dpkg-divert --local --rename --add /usr/bin/apt-get | |
$sudo tee /usr/bin/apt-get >/dev/null <<"EOF" | |
#!/bin/sh | |
a=" $* " | |
emd="eatmydata" | |
if ! command -v eatmydata >/dev/null 2>&1; then | |
emd="" | |
if [ "$(id -u)" = "0" ] && | |
[ "${a#* install }" != "$a" -o "${a#* upgrade }" != "$a" -o \ | |
"${a#* dist-upgrade }" != "$a" ]; then | |
# we are root, this is install, so install emd | |
echo "=== first installing eatmydata ===" 1>&2 | |
out=$(DEBIAN_FRONTEND=noninteractive "$0.distrib" install \ | |
--quiet --assume-yes eatmydata 2>&1) | |
ret=$? | |
if [ $ret -ne 0 ]; then | |
echo "FAILED: $out" 1>&2; | |
echo "failed to install libeatmydata." | |
exit $ret | |
fi | |
emd="eatmydata" | |
fi | |
fi 1>&2 </dev/null | |
exec $emd "$0.distrib" "$@" | |
EOF | |
$sudo chmod 755 /usr/bin/apt-get | |
slists="/etc/apt/sources.list /etc/cloud/templates/sources.list.ubuntu.tmpl" | |
for f in $slists; do | |
[ -f "$f" ] || continue | |
$sudo sed -i.dist "s,^deb-src,#deb-src," "$f" | |
# do not like multiverse or -backports | |
$sudo sed -i -e '/^deb [^ ]\+[ ]\+[^ ]\+[ ]\+multiverse[ ]*$/s,^,#,p' \ | |
-e '/^deb [^ ]\+[ ]\+[^ ]\+-backports\+[ ].*$/s,^,#,' \ | |
"$f" | |
# maybe you dont want to disable security | |
$sudo sed -i "/^deb[^-].*security.ubuntu.com/s/^/#/" "$f" | |
done | |
farchs=$(dpkg --print-foreign-architectures) | |
case "$farchs" in | |
*i386*) | |
{ $sudo dpkg --remove-architecture i386 >/dev/null 2>&1 || | |
$sudo rm /etc/dpkg/dpkg.cfg.d/multiarch; } && | |
echo "got rid of i386" || | |
echo "failed to remove arch i386" | |
;; | |
esac | |
f="/etc/apt/apt.conf.d/99notranslations" | |
if [ ! -f "$f" ]; then | |
echo 'Acquire::Languages "none";' | $sudo tee "$f" >/dev/null; | |
$sudo rm -f /var/lib/apt/lists/*Translation* | |
fi | |
# https://askubuntu.com/questions/823329/how-do-i-disable-fetching-of-dep-11-files | |
f="/etc/apt/apt.conf.d/50appstream" | |
if [ -f "$f" ]; then | |
$sudo rm -f "$f" | |
fi | |
# command-not-found data | |
f="/etc/apt/apt.conf.d/50command-not-found" | |
if [ -f "$f" ]; then | |
$sudo rm -f "$f" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment