Skip to content

Commit ed4fcb5

Browse files
committed
tmp
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
1 parent 5cd1b76 commit ed4fcb5

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

targets/linux/deb/distro/container.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,14 @@ apt-get update
8888
# Point apt at the empty target dpkg status so it thinks nothing is installed,
8989
# which makes it download the full dependency tree and resolve conflicts properly.
9090
essential=$(dpkg-query -Wf '${Package} ${Essential}\n' | awk '$2 == "yes" {print $1}')
91+
# Get names of local packages so we can exclude them from apt-get install
92+
local_pkgs=$(for f in /var/cache/apt/archives/*.deb; do dpkg-deb -f "$f" Package 2>/dev/null; done | sort -u)
9193
local_deps=$(for f in /var/cache/apt/archives/*.deb; do dpkg-deb -f "$f" Depends 2>/dev/null; done | tr ',' '\n' | sed 's/([^)]*)//g; s/|.*//; s/ //g' | grep -v '^$' | sort -u)
94+
# Filter out deps that are satisfied by local packages (they aren't in apt repos)
95+
echo "$local_pkgs" > /tmp/local_pkg_names
96+
filtered_deps=$(echo "$local_deps" | grep -vxFf /tmp/local_pkg_names || true)
9297
apt-get -o Dir::State::status=/tmp/rootfs/var/lib/dpkg/status \
93-
--yes --download-only install $essential $local_deps
98+
--yes --download-only install $essential $filtered_deps
9499
95100
# Extract all packages into the target rootfs
96101
for f in /var/cache/apt/archives/*.deb; do
@@ -127,6 +132,19 @@ if [ ! -e /tmp/rootfs/usr/bin/sh ]; then
127132
fi
128133
fi
129134
135+
# Remove usrmerge package - our merged-usr fixup above already handles this,
136+
# and usrmerge's postinst fails on overlayfs (which BuildKit uses).
137+
# Create a fake dpkg status entry so dpkg thinks it's installed.
138+
for f in /var/cache/apt/archives/usrmerge_*.deb /var/cache/apt/archives/usr-is-merged_*.deb; do
139+
if [ -f "$f" ]; then
140+
pkg=$(dpkg-deb -f "$f" Package)
141+
ver=$(dpkg-deb -f "$f" Version)
142+
arch=$(dpkg-deb -f "$f" Architecture)
143+
printf 'Package: %s\nStatus: install ok installed\nVersion: %s\nArchitecture: %s\nDescription: faked by dalec\n\n' "$pkg" "$ver" "$arch" >> /tmp/rootfs/var/lib/dpkg/status
144+
rm "$f"
145+
fi
146+
done
147+
130148
cp /var/cache/apt/archives/*.deb /tmp/rootfs/var/cache/apt/archives/
131149
132150
# Copy apt sources from worker into rootfs so the final container can install packages

0 commit comments

Comments
 (0)