Skip to content

Commit 1e534da

Browse files
author
Your Name
committed
task test
1 parent 4fe9188 commit 1e534da

File tree

2 files changed

+25
-47
lines changed

2 files changed

+25
-47
lines changed

Taskfile.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ tasks:
164164
VERSION: "0.6.3"
165165
cmds:
166166
- docker build --no-cache -t mock-apt-repo -f test.Dockerfile .
167+
- docker run --rm -it --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --name apt-test-update mock-apt-repo
168+
- docker exec -d apt-test-update /usr/bin/arduino-router
169+
167170

168171
arduino-app-cli:build:local:
169172
desc: "Build the arduino-app-cli locally"

test.Dockerfile

Lines changed: 22 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,46 @@
1-
# 1. Use Debian base
21
FROM debian:trixie
32

4-
ENV DEBIAN_FRONTEND=noninteractive
3+
ENV container docker
4+
STOPSIGNAL SIGRTMIN+3
5+
VOLUME ["/sys/fs/cgroup"]
56

6-
# 2. Install necessary tools
7-
RUN apt update && apt install -y \
8-
dpkg-dev \
9-
apt-utils \
10-
adduser \
7+
# Install systemd + dependencies
8+
RUN apt update && apt install -y systemd systemd-sysv dbus \
9+
dpkg-dev apt-utils adduser gzip \
1110
&& rm -rf /var/lib/apt/lists/*
1211

13-
# 3. Symlink addgroup for minimal system scripts
14-
RUN ln -s /usr/sbin/addgroup /usr/bin/addgroup || true
15-
16-
# 4. Build args for parameterization
12+
# Copy your packages and setup repo (as before)
1713
ARG OLD_PACKAGE_PATH=build/old_package
1814
ARG NEW_PACKAGE_PATH=build
1915
ARG APP_PACKAGE_NAME=arduino-app-cli
2016
ARG ROUTER_PACKAGE_NAME=arduino-router
2117
ARG ARCH=arm64
22-
ARG VERSION=0.6.3
2318

24-
# 5. Copy packages dynamically
2519
COPY ${OLD_PACKAGE_PATH}/${APP_PACKAGE_NAME}*.deb /tmp/old_app.deb
2620
COPY ${NEW_PACKAGE_PATH}/${APP_PACKAGE_NAME}*.deb /tmp/new_app.deb
2721
COPY ${NEW_PACKAGE_PATH}/${ROUTER_PACKAGE_NAME}*.deb /tmp/new_router.deb
2822

29-
# 6. Install old package + router dependency
30-
RUN apt update && apt install -y \
31-
/tmp/old_app.deb \
32-
/tmp/new_router.deb \
33-
&& rm /tmp/old_app.deb
34-
35-
# 7. Setup local APT repo with new packages
36-
RUN mkdir -p /var/www/html/myrepo/dists/trixie/main/binary-${ARCH}
37-
38-
# Rename new packages to match their real package/version/arch
39-
RUN mv /tmp/new_app.deb /var/www/html/myrepo/dists/trixie/main/binary-${ARCH}/${APP_PACKAGE_NAME}_${VERSION}_${ARCH}.deb
40-
RUN mv /tmp/new_router.deb /var/www/html/myrepo/dists/trixie/main/binary-${ARCH}/${ROUTER_PACKAGE_NAME}_0.6.2-1_${ARCH}.deb
23+
RUN apt update && apt install -y /tmp/old_app.deb /tmp/new_router.deb \
24+
&& rm /tmp/old_app.deb \
25+
&& mkdir -p /var/www/html/myrepo/dists/trixie/main/binary-${ARCH} \
26+
&& mv /tmp/new_app.deb /var/www/html/myrepo/dists/trixie/main/binary-${ARCH}/ \
27+
&& mv /tmp/new_router.deb /var/www/html/myrepo/dists/trixie/main/binary-${ARCH}/
4128

42-
# 8. Generate Packages.gz metadata
4329
WORKDIR /var/www/html/myrepo
44-
RUN dpkg-scanpackages dists/trixie/main/binary-arm64 /dev/null | gzip -9c > dists/trixie/main/binary-arm64/Packages.gz
30+
RUN dpkg-scanpackages dists/trixie/main/binary-${ARCH} /dev/null | gzip -9c > dists/trixie/main/binary-${ARCH}/Packages.gz
4531
WORKDIR /
4632

47-
# 9. Configure local APT repo
33+
RUN usermod -s /bin/bash arduino || true
34+
RUN mkdir -p /home/arduino && chown -R arduino:arduino /home/arduino
35+
36+
4837
RUN echo "deb [trusted=yes arch=${ARCH}] file:/var/www/html/myrepo trixie main" \
4938
> /etc/apt/sources.list.d/my-mock-repo.list
5039

51-
# 10. Fix home dir for arduino user (optional)
52-
RUN usermod -s /bin/bash arduino || true
53-
RUN mkdir -p /home/arduino && chown -R arduino:arduino /home/arduino
5440

55-
# 11. Entrypoint: show upgrade availability
56-
RUN echo '#!/bin/bash\n\
57-
set -e\n\
58-
echo "--- Updating APT ---"\n\
59-
apt update\n\
60-
echo "--- Installed version ---"\n\
61-
dpkg -l | grep ${APP_PACKAGE_NAME} || true\n\
62-
echo "--- Upgrade candidate ---"\n\
63-
apt-cache policy ${APP_PACKAGE_NAME}\n\
64-
echo "--- Available upgrades ---"\n\
65-
apt list --upgradable | grep ${APP_PACKAGE_NAME} || echo "No upgrade found"\n\
66-
echo "--- Simulating upgrade ---"\n\
67-
apt upgrade --simulate\n\
68-
' > /entrypoint.sh
41+
VOLUME [ "/sys/fs/cgroup" ]
42+
43+
6944

70-
RUN chmod +x /entrypoint.sh
71-
CMD ["/entrypoint.sh"]
45+
# CMD: systemd must be PID 1
46+
CMD ["/sbin/init"]

0 commit comments

Comments
 (0)