Skip to content

Instantly share code, notes, and snippets.

@sjinks
Last active August 29, 2015 14:07
Show Gist options
  • Save sjinks/d40bc97355314056b62a to your computer and use it in GitHub Desktop.
Save sjinks/d40bc97355314056b62a to your computer and use it in GitHub Desktop.
#!/bin/sh -e
# Prereqs:
# apt-get install lxc lxc-templates --no-install-recommends
#
# For unprivileged container:
# apt-get install --no-install-recommends uidmap
CONTAINER=debian
lxc-create -n "$CONTAINER" -t download -- --dist debian --release wheezy --arch amd64
lxc-start -n "$CONTAINER" -d
lxc-attach -n "$CONTAINER" -- sh -c 'cat > /etc/dpkg/dpkg.cfg.d/50exclude <<EOT
path-exclude=/usr/share/doc/*
path-exclude=/usr/share/man/*
path-exclude=/usr/share/locale/*
path-include=/usr/share/locale/locale.alias
path-include=/usr/share/locale/en/*
path-include=/usr/share/locale/en_US/*
path-include=/usr/share/locale/en_US.UTF-8/*
EOT'
lxc-attach -n "$CONTAINER" -- sh -c 'cat > /etc/apt/apt.conf.d/97nocache <<EOT
Dir::Cache {
srcpkgcache "";
pkgcache "";
}
EOT'
lxc-attach -n "$CONTAINER" -- sh -c 'cat > /etc/apt/apt.conf.d/98compress <<EOT
Acquire::GzipIndexes "true";
Acquire::CompressionTypes::Order:: "gz";
EOT'
lxc-attach -n "$CONTAINER" -- sh -c 'cat > /etc/apt/apt.conf.d/98translations <<EOT
Acquire::Languages "none";
EOT'
lxc-attach -n "$CONTAINER" -- sh -c 'cat > /etc/apt/sources.list <<EOT
deb http://ftp.ua.debian.org/debian stable main contrib
deb http://ftp.debian.org/debian/ wheezy-updates main contrib
deb http://security.debian.org/ wheezy/updates main contrib
EOT'
lxc-attach -n "$CONTAINER" -- apt-get -qq purge debconf-i18n libbsd0 libclass-isa-perl libedit2 libgdbm3 libgssapi-krb5-2 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 liblocale-gettext-perl libssl1.0.0 libswitch-perl libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libui-dialog-perl libwrap0 openssh-client openssh-server perl perl-modules
lxc-attach -n "$CONTAINER" -- apt-get -qq update
lxc-attach -n "$CONTAINER" -- apt-get -qq upgrade
lxc-attach -n "$CONTAINER" -- apt-get -qq install --reinstall dpkg
lxc-attach -n "$CONTAINER" -- apt-get -qq install --reinstall perl-base
lxc-attach -n "$CONTAINER" -- sh -c "dpkg -l | awk '/^ii/ {print \$2}' | grep -Ev 'perl-base|dpkg' | xargs apt-get install -qq --reinstall --no-install-recommends"
lxc-attach -n "$CONTAINER" -- localedef -c --no-archive -f UTF-8 -i en_US en_US.UTF-8
lxc-attach -n "$CONTAINER" -- sh -c 'sed -i -e "0,/^[# ]*en_US.UTF-8 UTF-8 *$/ s/^[# ]*en_US.UTF-8 UTF-8 *$/en_US.UTF-8 UTF-8/" /etc/locale.gen'
lxc-attach -n "$CONTAINER" -- locale-gen en_US.UTF-8
lxc-attach -n "$CONTAINER" -- sh -c 'export LANG=en_US.UTF-8; update-locale LANG=en_US.UTF-8 LC_MESSAGES=POSIX'
lxc-attach -n "$CONTAINER" -- apt-get -qq install dropbear
lxc-attach -n "$CONTAINER" -- apt-get clean
# lxc-attach -n "$CONTAINER" -- apt-get -y --force-yes purge e2fsprogs e2fslibs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment