Skip to content

Commit 4fe9188

Browse files
author
Your Name
committed
test .deb update
1 parent f61b73f commit 4fe9188

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

Taskfile.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ vars:
1212
RUNNER_VERSION: "0.5.0"
1313
VERSION: # if version is not passed we hack the semver by encoding the commit as pre-release
1414
sh: echo "${VERSION:-0.0.0-$(git rev-parse --short HEAD)}"
15+
NEW_PACKAGE:
16+
sh: ls -1 ./build/arduino-app-cli_*.deb 2>/dev/null | head -n 1
17+
GITHUB_TOKEN_FILE: ./github_token.txt
1518

1619
tasks:
1720
init:
@@ -123,6 +126,45 @@ tasks:
123126
echo "Examples successfully cloned."
124127
silent: false
125128

129+
build-image:
130+
desc: "Builds the mock-repo Docker image (requires GITHUB_TOKEN_FILE)"
131+
deps: [build-deb]
132+
vars:
133+
PKG_PATH: '{{.NEW_PACKAGE}}'
134+
cmds:
135+
# --- MODIFIED ---
136+
# Check for both the package and the token file
137+
- |
138+
if [ ! -f "{{.GITHUB_TOKEN_FILE}}" ]; then
139+
echo "Error: GitHub token file not found at {{.GITHUB_TOKEN_FILE}}"
140+
echo "Please create this file and add your GitHub PAT to it."
141+
exit 1
142+
fi
143+
- |
144+
echo "Using package: {{.PKG_PATH}}"
145+
echo "Using GitHub token from: {{.GITHUB_TOKEN_FILE}}"
146+
147+
# Enable BuildKit and pass the secret
148+
DOCKER_BUILDKIT=1 docker build \
149+
--secret id=github_token,src={{.GITHUB_TOKEN_FILE}} \
150+
--build-arg NEW_PACKAGE_PATH={{.PKG_PATH}} \
151+
-t newdeb \
152+
-f test.Dockerfile .
153+
status:
154+
- '[[ -f "{{.PKG_PATH}}" ]]'
155+
- '[[ -f "{{.DOCKERFILE_NAME}}" ]]'
156+
# Re-build if token file changes
157+
- '[[ -f "{{.GITHUB_TOKEN_FILE}}" ]]'
158+
159+
test-deb:
160+
desc: Test the debian package locally
161+
deps:
162+
- build-deb
163+
vars:
164+
VERSION: "0.6.3"
165+
cmds:
166+
- docker build --no-cache -t mock-apt-repo -f test.Dockerfile .
167+
126168
arduino-app-cli:build:local:
127169
desc: "Build the arduino-app-cli locally"
128170
cmds:

test.Dockerfile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# 1. Use Debian base
2+
FROM debian:trixie
3+
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
# 2. Install necessary tools
7+
RUN apt update && apt install -y \
8+
dpkg-dev \
9+
apt-utils \
10+
adduser \
11+
&& rm -rf /var/lib/apt/lists/*
12+
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
17+
ARG OLD_PACKAGE_PATH=build/old_package
18+
ARG NEW_PACKAGE_PATH=build
19+
ARG APP_PACKAGE_NAME=arduino-app-cli
20+
ARG ROUTER_PACKAGE_NAME=arduino-router
21+
ARG ARCH=arm64
22+
ARG VERSION=0.6.3
23+
24+
# 5. Copy packages dynamically
25+
COPY ${OLD_PACKAGE_PATH}/${APP_PACKAGE_NAME}*.deb /tmp/old_app.deb
26+
COPY ${NEW_PACKAGE_PATH}/${APP_PACKAGE_NAME}*.deb /tmp/new_app.deb
27+
COPY ${NEW_PACKAGE_PATH}/${ROUTER_PACKAGE_NAME}*.deb /tmp/new_router.deb
28+
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
41+
42+
# 8. Generate Packages.gz metadata
43+
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
45+
WORKDIR /
46+
47+
# 9. Configure local APT repo
48+
RUN echo "deb [trusted=yes arch=${ARCH}] file:/var/www/html/myrepo trixie main" \
49+
> /etc/apt/sources.list.d/my-mock-repo.list
50+
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
54+
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
69+
70+
RUN chmod +x /entrypoint.sh
71+
CMD ["/entrypoint.sh"]

0 commit comments

Comments
 (0)