8 # we have to do a little fancy footwork to make sure "rootfsDir" becomes the second non-option argument to debootstrap
11 while [ $# -gt 0 ] && [[ "$1" == -* ]]; do
21 debootstrap "${before[@]}" "$suite" "$rootfsDir" "$@"
24 # now for some Docker-specific tweaks
26 # prevent init scripts from running during install/update
27 echo >&2 "+ cat > '$rootfsDir/usr/sbin/policy-rc.d'"
28 cat > "$rootfsDir/usr/sbin/policy-rc.d" <<'EOF'
32 chmod +x "$rootfsDir/usr/sbin/policy-rc.d"
34 # prevent upstart scripts from running during install/update
37 chroot "$rootfsDir" dpkg-divert --local --rename --add /sbin/initctl
38 ln -sf /bin/true "$rootfsDir/sbin/initctl"
41 # shrink the image, since apt makes us fat (wheezy: ~157.5MB vs ~120MB)
42 ( set -x; chroot "$rootfsDir" apt-get clean )
44 # Ubuntu 10.04 sucks... :)
45 if strings "$rootfsDir/usr/bin/dpkg" | grep -q unsafe-io; then
46 # force dpkg not to call sync() after package extraction (speeding up installs)
47 echo >&2 "+ echo force-unsafe-io > '$rootfsDir/etc/dpkg/dpkg.cfg.d/docker-apt-speedup'"
48 echo 'force-unsafe-io' > "$rootfsDir/etc/dpkg/dpkg.cfg.d/docker-apt-speedup"
51 if [ -d "$rootfsDir/etc/apt/apt.conf.d" ]; then
52 # _keep_ us lean by effectively running "apt-get clean" after every install
53 aptGetClean='"rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true";'
54 echo >&2 "+ cat > '$rootfsDir/etc/apt/apt.conf.d/docker-clean'"
55 cat > "$rootfsDir/etc/apt/apt.conf.d/docker-clean" <<-EOF
56 DPkg::Post-Invoke { ${aptGetClean} };
57 APT::Update::Post-Invoke { ${aptGetClean} };
59 Dir::Cache::pkgcache "";
60 Dir::Cache::srcpkgcache "";
63 # remove apt-cache translations for fast "apt-get update"
64 echo >&2 "+ cat > '$rootfsDir/etc/apt/apt.conf.d/docker-no-languages'"
65 echo 'Acquire::Languages "none";' > "$rootfsDir/etc/apt/apt.conf.d/docker-no-languages"
68 if [ -z "$DONT_TOUCH_SOURCES_LIST" ]; then
69 # tweak sources.list, where appropriate
71 if [ -z "$lsbDist" -a -r "$rootfsDir/etc/os-release" ]; then
72 lsbDist="$(. "$rootfsDir/etc/os-release" && echo "$ID")"
74 if [ -z "$lsbDist" -a -r "$rootfsDir/etc/lsb-release" ]; then
75 lsbDist="$(. "$rootfsDir/etc/lsb-release" && echo "$DISTRIB_ID")"
77 if [ -z "$lsbDist" -a -r "$rootfsDir/etc/debian_version" ]; then
82 # updates and security!
83 if [ "$suite" != 'sid' -a "$suite" != 'unstable' ]; then
86 sed -i "p; s/ $suite main$/ ${suite}-updates main/" "$rootfsDir/etc/apt/sources.list"
87 echo "deb http://security.debian.org $suite/updates main" >> "$rootfsDir/etc/apt/sources.list"
92 # add the universe, updates, and security repositories
96 s/ $suite main$/ $suite main universe/; p;
97 s/ $suite main/ ${suite}-updates main/; p;
98 s/ $suite-updates main/ ${suite}-security main/
99 " "$rootfsDir/etc/apt/sources.list"
103 # add the updates repository
104 if [ "$suite" != 'devel' ]; then
107 sed -i "p; s/ $suite main$/ ${suite}-updates main/" "$rootfsDir/etc/apt/sources.list"
112 # add contrib and non-free
115 sed -i "s/ $suite main$/ $suite main contrib non-free/" "$rootfsDir/etc/apt/sources.list"
121 # make sure we're fully up-to-date, too
124 chroot "$rootfsDir" apt-get update
125 chroot "$rootfsDir" apt-get dist-upgrade -y