Skip to content

Commit

Permalink
Remove use of aptly
Browse files Browse the repository at this point in the history
This just uses apt-ftparchive which simplifies a lot of the test setup.

Signed-off-by: Brian Goff <[email protected]>
  • Loading branch information
cpuguy83 committed Jan 23, 2025
1 parent 3cd4f43 commit 1bdb7b3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 50 deletions.
45 changes: 8 additions & 37 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ ARG INCLUDE_TESTING=0
ARG INCLUDE_STAGING=0


# For jammy which uses zstd compressed packages, but aptly from the distro packages does not.
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.19.12 AS aptly
ENV GOCACHE=/root/.gobuild GOPROXY=direct GOGC=off CGO_ENABLED=0
RUN \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.gobuild \
go install github.com/aptly-dev/aptly@0a1798869a3c37b269f8f34fef41095233cd8750

FROM ${MIRROR}buildpack-deps:bullseye AS git

FROM git AS bats-core
Expand All @@ -36,7 +28,7 @@ RUN git clone ${REPO} . && \
git checkout ${COMMIT} && \
git archive HEAD | tar -C /root/bats -xvf -

FROM git as bats-support
FROM git AS bats-support
RUN mkdir -p /root/bats
WORKDIR /root/src
ARG BATS_SUPPORT_REPO=https://github.com/bats-core/bats-support.git
Expand All @@ -47,7 +39,7 @@ RUN git clone ${REPO} . && \
git checkout ${COMMIT} && \
git archive HEAD | tar -C /root/bats -xvf -

FROM git as bats-assert
FROM git AS bats-assert
RUN mkdir -p /root/bats
WORKDIR /root/src
ARG BATS_ASSERT_REPO=https://github.com/bats-core/bats-assert.git
Expand All @@ -61,28 +53,8 @@ RUN git clone ${REPO} . && \
FROM scratch AS bats
COPY --from=bats-core /root/bats/ /

FROM ${BUSTER_IMG} AS buster
RUN apt-get update && apt-get install -y systemd curl ca-certificates aptly && c_rehash
RUN \
curl -SLf https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb > /tmp/ms.deb && \
dpkg -i /tmp/ms.deb && \
rm /tmp/ms.deb
COPY entrypoint.sh /usr/local/bin/docker-entrypoint.sh
STOPSIGNAL SIGRTMIN+3
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
COPY --from=bats / /opt/bats
ARG INCLUDE_TESTING
ARG INCLUDE_STAGING
RUN if [ "${INCLUDE_TESTING}" = "1" ]; then \
echo "deb [arch=amd64,arm64,armhf,arm64,armhf] https://packages.microsoft.com/debian/10/prod testing main" >> /etc/apt/sources.list.d/microsoft-testing.list; \
fi; \
if [ "${INCLUDE_STAGING}" = "1" ]; then \
echo "deb [arch=amd64,arm64,armhf,arm64,armhf] https://packages.microsoft.com/repos/iotedge-buster buster main" >> /etc/apt/sources.list.d/microsoft-testing.list; \
fi; \
cd /opt/bats && ./install.sh /usr/local

FROM ${BULLSEYE_IMG} AS bullseye
RUN apt-get update && apt-get install -y systemd curl ca-certificates aptly && c_rehash
RUN apt-get update && apt-get install -y systemd curl ca-certificates apt-utils && c_rehash
RUN \
curl -SLf https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb > /tmp/ms.deb && \
dpkg -i /tmp/ms.deb && \
Expand All @@ -104,7 +76,7 @@ RUN if [ "${INCLUDE_TESTING}" = "1" ]; then \
RUN ln -s /lib/systemd/systemd /sbin/init

FROM ${BOOKWORM_IMG} AS bookworm
RUN apt-get update && apt-get install -y systemd curl ca-certificates aptly && c_rehash
RUN apt-get update && apt-get install -y systemd curl ca-certificates apt-utils && c_rehash
RUN \
curl -SLf https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb > /tmp/ms.deb && \
dpkg -i /tmp/ms.deb && \
Expand All @@ -127,7 +99,7 @@ RUN ln -s /lib/systemd/systemd /sbin/init


FROM ${BIONIC_IMG} AS bionic
RUN apt-get update && apt-get install -y systemd curl ca-certificates aptly
RUN apt-get update && apt-get install -y systemd curl ca-certificates apt-utils
RUN \
curl -SLf https://packages.microsoft.com/config/ubuntu/18.04/multiarch/packages-microsoft-prod.deb > /tmp/ms.deb && \
dpkg -i /tmp/ms.deb && \
Expand All @@ -147,7 +119,7 @@ RUN if [ "${INCLUDE_TESTING}" = "1" ]; then \
cd /opt/bats && ./install.sh /usr/local

FROM ${FOCAL_IMG} AS focal
RUN apt-get update && apt-get install -y systemd curl ca-certificates aptly
RUN apt-get update && apt-get install -y systemd curl ca-certificates apt-utils
RUN \
curl -SLf https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb > /tmp/ms.deb && \
dpkg -i /tmp/ms.deb && \
Expand All @@ -164,8 +136,7 @@ RUN if [ "${INCLUDE_TESTING}" = "1" ]; then \
RUN ln -s /lib/systemd/systemd /sbin/init

FROM ${JAMMY_IMG} AS jammy
RUN apt-get update && apt-get install -y systemd curl ca-certificates
COPY --link --from=aptly /go/bin/aptly /usr/local/bin/
RUN apt-get update && apt-get install -y systemd curl ca-certificates apt-utils
RUN \
curl -SLf https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb > /tmp/ms.deb && \
dpkg -i /tmp/ms.deb && \
Expand All @@ -182,7 +153,7 @@ RUN if [ "${INCLUDE_TESTING}" = "1" ]; then \
RUN ln -s /lib/systemd/systemd /sbin/init

FROM ${NOBLE_IMG} AS noble
RUN apt-get update && apt-get install -y systemd curl ca-certificates aptly
RUN apt-get update && apt-get install -y systemd curl ca-certificates apt-utils
RUN \
curl -SLf https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb > /tmp/ms.deb && \
dpkg -i /tmp/ms.deb && \
Expand Down
4 changes: 2 additions & 2 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ $(TESTDIR)/$(DISTRO)/installed: $(TESTDIR)/$(DISTRO)/cid $(LOCAL_PKG_DIR)
else
$(TESTDIR)/$(DISTRO)/installed: $(TESTDIR)/$(DISTRO)/cid
endif
id="$$(cat $<)"
docker start $${id}
id="$$(cat $<)"; \
docker start $${id}; \
docker exec \
$(DOCKER_ENV) \
$${id} /opt/moby/install.sh /var/pkg
Expand Down
17 changes: 6 additions & 11 deletions tests/deb/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ prepare_local_apt() {
return
fi

aptly repo create unstable
aptly repo add unstable "${dir}"
aptly publish repo -distribution=moby-local-testing -skip-signing unstable
aptly serve -listen=127.0.0.1:8080 &

echo "waiting for apt server to be ready"
while true; do
curl 127.0.0.1:8080 >/dev/null 2>&1 && break
sleep 1
done
(
cd "${dir}"
apt-ftparchive packages . >Packages
apt-ftparchive release . >Release
)

echo "deb [trusted=yes arch=amd64,armhf,arm64] http://localhost:8080/ moby-local-testing main" >/etc/apt/sources.list.d/local.list
echo "deb [trusted=yes arch=amd64,armhf,arm64] copy:${dir}/ / " >/etc/apt/sources.list.d/local.list
}

install() {
Expand Down Expand Up @@ -75,7 +71,6 @@ install)
"")
prepare_local_apt
install
pkill -9 aptly || true
init
;;
*)
Expand Down

0 comments on commit 1bdb7b3

Please sign in to comment.