Skip to content

Instantly share code, notes, and snippets.

@jrwren
Created February 24, 2022 20:18
Show Gist options
  • Save jrwren/afd83bbeb4e0818858c0d375e8c28a6d to your computer and use it in GitHub Desktop.
Save jrwren/afd83bbeb4e0818858c0d375e8c28a6d to your computer and use it in GitHub Desktop.
an unminimized ubuntu with build-essential, openssl, man, jq
FROM ubuntu:20.04
# Lifted from unminimize.
RUN set -e; if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp ]; then \
echo "Re-enabling installation of all documentation in dpkg..." ;\
if [ -f /etc/dpkg/dpkg.cfg.d/excludes ]; then \
mv /etc/dpkg/dpkg.cfg.d/excludes /etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp ;\
fi ;\
echo "Updating package list and upgrading packages..." ;\
apt-get update ;\
# apt-get upgrade asks for confirmation before upgrading packages to let the user stop here
apt-get upgrade -y ;\
echo "Restoring system documentation..." ;\
echo "Reinstalling packages with files in /usr/share/man/ ..." ;\
# Reinstallation takes place in two steps because a single dpkg --verified
# command generates very long parameter list for "xargs dpkg -S" and may go
# over ARG_MAX. Since many packages have man pages the second download
# handles a much smaller amount of packages.
dpkg -S /usr/share/man/ |sed 's|, |\n|g;s|: [^:]*$||' | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y ;\
echo "Reinstalling packages with system documentation in /usr/share/doc/ .." ;\
# This step processes the packages which still have missing documentation
dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/doc/ {print $2}' | sed 's|/[^/]*$||' | sort |uniq \
| xargs dpkg -S | sed 's|, |\n|g;s|: [^:]*$||' | uniq | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y ;\
echo "Restoring system translations..." ;\
# This step processes the packages which still have missing translations
dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/locale/ {print $2}' | sed 's|/[^/]*$||' | sort |uniq \
| xargs dpkg -S | sed 's|, |\n|g;s|: [^:]*$||' | uniq | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y ;\
if dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/doc/ {exit 1}'; then \
echo "Documentation has been restored successfully." ;\
rm /etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp ;\
else \
echo "There are still files missing from /usr/share/doc/:" ;\
dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/doc/ {print " " $2}' ;\
echo "You may want to try running this script again or you can remove" ;\
echo "/etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp and restore the files manually.";\
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 ;\
# unminimization succeeded, there is no need to mention it in motd
rm -f /etc/update-motd.d/60-unminimize
# Intentionally doing unminimize in a different layer
RUN apt install -y build-essential man openssl jq
@jrwren
Copy link
Author

jrwren commented Feb 24, 2022

https://hub.docker.com/r/jrwren/build-essential

docker pull jrwren/build-essential

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment