Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ The buildpack will do the following:

| Environment Variable | Description |
| -------------------- | ----------- |
| BP_APT_RUNIMAGE_PACKAGES | List of apt packages installed in run-image, if run-image is different from build-image (optional) |

There are no environment variable configuration options.
If set, the variable `BP_APT_RUNIMAGE_PACKAGES` allows to compare installed packages in the run-image and install from `Aptfile` the packages listed and only the needed dependencies.
You can list the packages already installed in the run-image with `apt list --installed 2>/dev/null | grep -v 'Listing...' | awk -F'/' '{print $1}' | sort`.

### Aptfile

Expand Down
15 changes: 14 additions & 1 deletion bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,20 @@ else
curl --silent --show-error --fail -L -z "$PACKAGE_FILE" -o "$PACKAGE_FILE" "$PACKAGE" 2>&1 | indent
else
topic "Fetching .debs for $PACKAGE"
apt-get $APT_OPTIONS -y $APT_FORCE_YES -d install --reinstall "$PACKAGE" | indent
if [[ -z $BP_APT_RUNIMAGE_PACKAGES ]]; then
apt-get $APT_OPTIONS -y $APT_FORCE_YES -d install --reinstall "$PACKAGE" | indent
else
local runtime_installed_packages=$(mktemp)
echo "${BP_APT_RUNIMAGE_PACKAGES}" | sed 's/,/\n/g' | sort >> $runtime_installed_packages
local package_dependencies=$(mktemp)
apt-cache $APT_OPTIONS depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances --no-pre-depends "${PACKAGE}" | grep "^\w" | sort >> $package_dependencies
local needed_packages=$(mktemp)
comm -23 $package_dependencies $runtime_installed_packages | tr '\n' ' ' >> $needed_packages
pushd $APT_CACHE_DIR/archives
apt-get $APT_OPTIONS download $(cat "${needed_packages}") | indent
popd > /dev/null
rm $runtime_installed_packages $package_dependencies $needed_packages
fi
fi
}

Expand Down