From 50da07cd71e77f15d60e558786537c281fdb99e0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 30 Jul 2014 20:15:23 -0700 Subject: [PATCH] trim.sh: Remove build-only dependencies with --depclean Use '--with-bdeps=n' to tell Portage to ignore build-time dependencies (e.g. an ebuild's DEPEND). Only the runtime dependencies (an ebuild's RDEPEND and PDEPEND) are taken into acount when selecting packages required by @world. That lets us keep what we need to run the target application, but remove all the build tooling (including GCC), leaving a functional, lightweight image. --- trim.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/trim.sh b/trim.sh index 1091a69..3a68a54 100755 --- a/trim.sh +++ b/trim.sh @@ -49,14 +49,12 @@ trim() #sys-apps/openrc (/sbin/rc) #sys-apps/net-tools (/bin/hostname) #sys-devel/gettext (/usr/bin/envsubst) - # unmerge GCC to break the GCC <-> libc dependency loop docker run -t --name "${CONTAINER}" \ -v "${PWD}/empty-system.py:/tmp/empty-system.py" \ "${IMAGE}" /bin/bash -c " /tmp/empty-system.py && emerge --noreplace app-shells/bash sys-apps/net-tools sys-apps/openrc sys-devel/gettext && - emerge --unmerge sys-devel/gcc && - emerge -v --depclean && + emerge -v --with-bdeps=n --depclean && rm -rf /usr/portage" || die "failed to create ${CONTAINER}" docker export "${CONTAINER}" | docker import - "${IMG}" || -- 2.26.2