blob: c8dfae85145d2ef2635d8860e158f1f56f81d455 [file] [log] [blame]
Nico Huberc0b52db2022-12-15 12:42:32 +00001FROM debian:bullseye
2
Nico Huberc0b52db2022-12-15 12:42:32 +00003RUN \
4 useradd -p locked -m mani && \
5 apt-get -qq update && \
6 apt-get -qq upgrade && \
7 apt-get -qqy install git python-is-python3 python3-pexpect \
8 python3-distutils genisoimage qemu-system && \
9 apt-get clean
10
11RUN git clone https://github.com/gson1703/anita.git
12RUN cd anita && python setup.py install
13
Nico Huberfb433ba2023-03-04 19:09:47 +000014RUN mkdir -p -m 1777 /ccache
15
Nico Huberc0b52db2022-12-15 12:42:32 +000016ARG DISK_SIZE=1G
17ARG INSTALL_MEM=128M
Nico Huber3ddd6032022-12-11 17:23:22 +000018ARG INST_IMG=http://ftp.de.netbsd.org/pub/NetBSD/NetBSD-7.1/amd64/
Nico Huberc0b52db2022-12-15 12:42:32 +000019USER mani
20RUN cd && mkdir .ccache && chown mani:mani .ccache && \
21 anita --sets kern-GENERIC,modules,base,etc,comp \
22 --disk-size ${DISK_SIZE} --memory-size=${INSTALL_MEM} \
23 install ${INST_IMG} && \
24 rm -rf work-*/download
25
26ARG EXTRA_PKG=""
27ARG RUNTIME_MEM=128M
Nico Huberc3b02dc2023-08-12 01:13:45 +020028ARG ORIGIN=https://review.sourcearcade.org/flashprog.git
Nico Huber3ddd6032022-12-11 17:23:22 +000029ARG PKG_PATH=http://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/7.1/All
Nico Huberc0b52db2022-12-15 12:42:32 +000030RUN cd && anita --persist --memory-size=${RUNTIME_MEM} --run \
31"echo 'dhcpcd' >init && \
32 echo 'export PKG_PATH=${PKG_PATH}' >>init && \
33 . ./init && \
Nico Huberbad19ae2023-03-01 17:24:28 +000034 pkg_add gmake git-base ccache pkg-config meson \
Nico Huber76afdac2022-12-11 17:22:19 +000035 pciutils libusb1 libusb-compat libftdi \
Nico Huberc0b52db2022-12-15 12:42:32 +000036 ${EXTRA_PKG} && \
37 git config --global --add http.sslVerify false && \
Nico Huberc3b02dc2023-08-12 01:13:45 +020038 git clone ${ORIGIN} flashprog" \
Nico Huberc0b52db2022-12-15 12:42:32 +000039 boot ${INST_IMG}
40
41RUN cd && dd if=/dev/zero bs=1M count=64 of=cache.img && \
Nico Huberea88f212022-12-11 17:19:36 +000042 anita --vmm-args \
43 '-drive file=cache.img,index=1,media=disk,format=raw' \
44 --persist \
Nico Huberc0b52db2022-12-15 12:42:32 +000045 --memory-size=${RUNTIME_MEM} --run \
46"if [ \$(uname -m) = i386 -o \$(uname -m) = amd64 ]; then \
47 bdev=wd1d; \
48 else \
49 bdev=wd1c; \
50 fi; \
51 newfs -I \${bdev} && \
52 mkdir .ccache && \
53 mount /dev/\${bdev} .ccache && \
54 ccache -M 60M && \
55 umount .ccache && \
56 echo 'manitest() {' >>init && \
57 echo ' fsck -y -t ffs /dev/'\${bdev} >>init && \
58 echo ' mount /dev/'\${bdev}' ~/.ccache' >>init && \
Nico Huberc3b02dc2023-08-12 01:13:45 +020059 echo ' (cd ~/flashprog && eval \" \$*\")' >>init && \
Nico Huberc0b52db2022-12-15 12:42:32 +000060 echo ' ret=\$?' >>init && \
61 echo ' umount ~/.ccache' >>init && \
62 echo ' return \$ret' >>init && \
63 echo '}' >>init" \
64 boot ${INST_IMG} && \
65 gzip cache.img
66
67COPY anita-wrapper.sh /home/mani/mani-wrapper.sh
68ENV INST_IMG ${INST_IMG}
69ENV MEM_SIZE ${RUNTIME_MEM}
70ENTRYPOINT ["/bin/sh", "/home/mani/mani-wrapper.sh"]