|
|
@ -109,12 +109,16 @@ set -e
|
|
|
|
echo "This system has been minimized by removing packages and content that are"
|
|
|
|
echo "This system has been minimized by removing packages and content that are"
|
|
|
|
echo "not required on a system that users do not log into."
|
|
|
|
echo "not required on a system that users do not log into."
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
echo "This script restores the content and packages that are found on a default"
|
|
|
|
echo "This script restores content and packages that are found on a default"
|
|
|
|
echo "Ubuntu server system."
|
|
|
|
echo "Ubuntu server system in order to make this system more suitable for"
|
|
|
|
|
|
|
|
echo "interactive use."
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
echo "Reinstallation of packages may fail due to changes to the system"
|
|
|
|
echo "Reinstallation of packages may fail due to changes to the system"
|
|
|
|
echo "configuration, the presence of third-party packages, or for other"
|
|
|
|
echo "configuration, the presence of third-party packages, or for other"
|
|
|
|
echo "reasons."
|
|
|
|
echo "reasons."
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo "This operation may take some time."
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
read -p "Would you like to continue? [y/N] " REPLY
|
|
|
|
read -p "Would you like to continue? [y/N] " REPLY
|
|
|
|
echo # (optional) move to a new line
|
|
|
|
echo # (optional) move to a new line
|
|
|
|
if [ "$REPLY" != "y" ] && [ "$REPLY" != "Y" ]
|
|
|
|
if [ "$REPLY" != "y" ] && [ "$REPLY" != "Y" ]
|
|
|
@ -153,9 +157,21 @@ if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dp
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$(dpkg-divert --truename /usr/bin/man)" = "/usr/bin/man.REAL" ]; then
|
|
|
|
|
|
|
|
# Remove diverted man binary
|
|
|
|
|
|
|
|
rm -f /usr/bin/man
|
|
|
|
|
|
|
|
dpkg-divert --quiet --remove --rename /usr/bin/man
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$PROJECT" != "ubuntu-base" ]; then
|
|
|
|
|
|
|
|
# ubuntu-minimal is too much for a docker container (it contains
|
|
|
|
|
|
|
|
# systemd and other things)
|
|
|
|
|
|
|
|
cat >> chroot/usr/local/sbin/unminimize <<'EOF'
|
|
|
|
|
|
|
|
|
|
|
|
if ! dpkg-query --show --showformat='${db:Status-Status}\n' ubuntu-minimal 2> /dev/null | grep -q '^installed$'; then
|
|
|
|
if ! dpkg-query --show --showformat='${db:Status-Status}\n' ubuntu-minimal 2> /dev/null | grep -q '^installed$'; then
|
|
|
|
echo "Installing ubuntu-minimal package to provide the familiar Ubuntu minimal system..."
|
|
|
|
echo "Installing ubuntu-minimal package to provide the familiar Ubuntu minimal system..."
|
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y ubuntu-minimal
|
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y ubuntu-minimal ubuntu-standard
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if dpkg-query --show --showformat='${db:Status-Status}\n' ubuntu-server 2> /dev/null | grep -q '^installed$' \
|
|
|
|
if dpkg-query --show --showformat='${db:Status-Status}\n' ubuntu-server 2> /dev/null | grep -q '^installed$' \
|
|
|
@ -163,10 +179,12 @@ if dpkg-query --show --showformat='${db:Status-Status}\n' ubuntu-server 2> /dev/
|
|
|
|
echo "Installing ubuntu-server recommends..."
|
|
|
|
echo "Installing ubuntu-server recommends..."
|
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y landscape-common
|
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y landscape-common
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat >> chroot/usr/local/sbin/unminimize <<'EOF'
|
|
|
|
|
|
|
|
|
|
|
|
# unminimization succeeded, there is no need to mention it in motd
|
|
|
|
# unminimization succeeded, there is no need to mention it in motd
|
|
|
|
rm -f /etc/update-motd.d/60-unminimize
|
|
|
|
rm -f /etc/update-motd.d/60-unminimize
|
|
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
chmod +x chroot/usr/local/sbin/unminimize
|
|
|
|
chmod +x chroot/usr/local/sbin/unminimize
|
|
|
|
|
|
|
|
|
|
|
@ -183,6 +201,18 @@ echo "To restore this content, you can run the 'unminimize' command."
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
chmod +x chroot/etc/update-motd.d/60-unminimize
|
|
|
|
chmod +x chroot/etc/update-motd.d/60-unminimize
|
|
|
|
|
|
|
|
Chroot chroot "dpkg-divert --quiet --add \
|
|
|
|
|
|
|
|
--divert /usr/bin/man.REAL --rename \
|
|
|
|
|
|
|
|
/usr/bin/man"
|
|
|
|
|
|
|
|
cat > chroot/usr/bin/man << EOF
|
|
|
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
echo "This system has been minimized by removing packages and content that are"
|
|
|
|
|
|
|
|
echo "not required on a system that users do not log into."
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo "To restore this content, including manpages, you can run the 'unminimize'"
|
|
|
|
|
|
|
|
echo "command. You will still need to ensure the 'man-db' package is installed."
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x chroot/usr/bin/man
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
Chroot chroot "dpkg-divert --quiet --add \
|
|
|
|
Chroot chroot "dpkg-divert --quiet --add \
|
|
|
|
--divert /usr/sbin/update-initramfs.REAL --rename \
|
|
|
|
--divert /usr/sbin/update-initramfs.REAL --rename \
|
|
|
@ -232,8 +262,13 @@ EOF
|
|
|
|
# remove crufty files that shouldn't be left in an image
|
|
|
|
# remove crufty files that shouldn't be left in an image
|
|
|
|
rm -f chroot/var/cache/debconf/*-old chroot/var/lib/dpkg/*-old
|
|
|
|
rm -f chroot/var/cache/debconf/*-old chroot/var/lib/dpkg/*-old
|
|
|
|
Chroot chroot apt clean
|
|
|
|
Chroot chroot apt clean
|
|
|
|
|
|
|
|
if [ "${PROJECT}:${SUBPROJECT:-}" = "ubuntu-base:minimized" ]; then
|
|
|
|
|
|
|
|
# Save even more size by removing apt lists (that are currently removed
|
|
|
|
|
|
|
|
# downstream anyway)
|
|
|
|
|
|
|
|
rm -rf chroot/var/lib/apt/lists/*
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ -f config/oem-config-preinstalled ]; then
|
|
|
|
if [ -f config/universe-enabled ]; then
|
|
|
|
|
|
|
|
|
|
|
|
# This is cargo-culted almost verbatim (with some syntax changes for
|
|
|
|
# This is cargo-culted almost verbatim (with some syntax changes for
|
|
|
|
# preinstalled being slightly different in what it doesn't ask) from
|
|
|
|
# preinstalled being slightly different in what it doesn't ask) from
|
|
|
@ -455,7 +490,7 @@ for ISO in binary.iso binary.hybrid.iso; do
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
if [ -e "binary/$INITFS/filesystem.dir" ]; then
|
|
|
|
if [ -e "binary/$INITFS/filesystem.dir" ]; then
|
|
|
|
(cd "binary/$INITFS/filesystem.dir/" && tar -c *) | \
|
|
|
|
(cd "binary/$INITFS/filesystem.dir/" && tar -c --xattrs *) | \
|
|
|
|
gzip -9 --rsyncable > "$PREFIX.rootfs.tar.gz"
|
|
|
|
gzip -9 --rsyncable > "$PREFIX.rootfs.tar.gz"
|
|
|
|
chmod 644 "$PREFIX.rootfs.tar.gz"
|
|
|
|
chmod 644 "$PREFIX.rootfs.tar.gz"
|
|
|
|
elif [ -e binary-tar.tar.gz ]; then
|
|
|
|
elif [ -e binary-tar.tar.gz ]; then
|
|
|
@ -492,7 +527,7 @@ EOF
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$PROJECT" = "ubuntu-touch" ] || [ "$PROJECT" = "ubuntu-touch-custom" ]; then
|
|
|
|
if [ "$PROJECT" = "ubuntu-touch" ] || [ "$PROJECT" = "ubuntu-touch-custom" ]; then
|
|
|
|
(cd "binary/$INITFS/custom.dir/" && tar -c *) | \
|
|
|
|
(cd "binary/$INITFS/custom.dir/" && tar -c --xattrs *) | \
|
|
|
|
gzip -9 --rsyncable > "$PREFIX.custom.tar.gz"
|
|
|
|
gzip -9 --rsyncable > "$PREFIX.custom.tar.gz"
|
|
|
|
chmod 644 "$PREFIX.custom.tar.gz"
|
|
|
|
chmod 644 "$PREFIX.custom.tar.gz"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|