This makes APT be appropriately aggressive about removing packages it added due to `Recommends` or `Depends` if the packages they were added for are removed (even if other packages only have the softer `Suggests` relationship).
Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
| ... | ... |
@@ -118,6 +118,27 @@ if [ -d "$rootfsDir/etc/apt/apt.conf.d" ]; then |
| 118 | 118 |
Acquire::GzipIndexes "true"; |
| 119 | 119 |
Acquire::CompressionTypes::Order:: "gz"; |
| 120 | 120 |
EOF |
| 121 |
+ |
|
| 122 |
+ # update "autoremove" configuration to be aggressive about removing suggests deps that weren't manually installed |
|
| 123 |
+ echo >&2 "+ echo Apt::AutoRemove::SuggestsImportant 'false' > '$rootfsDir/etc/apt/apt.conf.d/docker-autoremove-suggests'" |
|
| 124 |
+ cat > "$rootfsDir/etc/apt/apt.conf.d/docker-autoremove-suggests" <<-'EOF' |
|
| 125 |
+ # Since Docker users are looking for the smallest possible final images, the |
|
| 126 |
+ # following emerges as a very common pattern: |
|
| 127 |
+ |
|
| 128 |
+ # RUN apt-get update \ |
|
| 129 |
+ # && apt-get install -y <packages> \ |
|
| 130 |
+ # && <do some compilation work> \ |
|
| 131 |
+ # && apt-get purge -y --auto-remove <packages> |
|
| 132 |
+ |
|
| 133 |
+ # By default, APT will actually _keep_ packages installed via Recommends or |
|
| 134 |
+ # Depends if another package Suggests them, even and including if the package |
|
| 135 |
+ # that originally caused them to be installed is removed. Setting this to |
|
| 136 |
+ # "false" ensures that APT is appropriately aggressive about removing the |
|
| 137 |
+ # packages it added. |
|
| 138 |
+ |
|
| 139 |
+ # https://aptitude.alioth.debian.org/doc/en/ch02s05s05.html#configApt-AutoRemove-SuggestsImportant |
|
| 140 |
+ Apt::AutoRemove::SuggestsImportant "false"; |
|
| 141 |
+ EOF |
|
| 121 | 142 |
fi |
| 122 | 143 |
|
| 123 | 144 |
if [ -z "$DONT_TOUCH_SOURCES_LIST" ]; then |