Skip to content

Commit b6c292f

Browse files
committed
docker: prepare SD card images, update README.md
Closes #1
1 parent 369a1a3 commit b6c292f

File tree

3 files changed

+60
-9
lines changed

3 files changed

+60
-9
lines changed

Dockerfile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1+
# syntax=docker/dockerfile:1-labs
12
FROM rust:latest AS stage-rust
2-
33
# crosscompile stuff
44
RUN apt update && apt upgrade -y
55
RUN apt install -y gcc-arm-linux-gnueabihf
66
RUN rustup target add arm-unknown-linux-gnueabihf
7-
87
# cloning and building
98
WORKDIR /usr/src/app
109
RUN git clone https://github.com/manio/aa-proxy-rs .
1110
RUN cargo build --release
1211

12+
# injecting aa-proxy-rs into all SD card images
13+
FROM alpine AS stage-sdcards
14+
RUN apk --no-cache add xz
15+
WORKDIR /root
16+
COPY --from=stage-rust /usr/src/app/target/arm-unknown-linux-gnueabihf/release/aa-proxy-rs .
17+
ADD contrib/injector.sh .
18+
ADD contrib/S93aa-proxy-rs .
19+
RUN --security=insecure ./injector.sh
20+
1321
# copy the resulting binary out of container to local dir
1422
FROM scratch AS custom-exporter
1523
COPY --from=stage-rust /usr/src/app/target/arm-unknown-linux-gnueabihf/release/aa-proxy-rs .
24+
COPY --from=stage-sdcards /root/raspberrypi0w-sdcard.img.xz .
25+
COPY --from=stage-sdcards /root/raspberrypi3a-sdcard.img.xz .
26+
COPY --from=stage-sdcards /root/raspberrypi4-sdcard.img.xz .
27+
COPY --from=stage-sdcards /root/raspberrypizero2w-sdcard.img.xz .

README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ not ready with USB connection then we can't send data to the phone and Android w
6464
## Demo
6565
[![asciicast](https://asciinema.org/a/686949.svg)](https://asciinema.org/a/686949)
6666

67-
## Building and installing
67+
## Building
6868
`rpi02w` binaries build by [WirelessAndroidAutoDongle](https://github.com/nisargjhaveri/WirelessAndroidAutoDongle) are for `arm-unknown-linux-gnueabihf` 32-bit architecture, probably
6969
because of usb-gadget module [incompatibility](https://github.com/nisargjhaveri/WirelessAndroidAutoDongle/pull/129).
7070
To be able to properly crosscompile output binary I provided `.cargo/config.toml` with target set for this specific arch.
@@ -79,17 +79,31 @@ arm-unknown-linux-gnueabihf (installed)
7979
```
8080
Besides a `gcc-arm-linux-gnueabihf` package is needed on Debian. This is distro-depended so I recommend to RTFM.
8181

82-
After building you need to transfer the binary to the target filesystem (I am using ssh/scp for this) and start it.
83-
For permanent solution I also modified startup scripts - but how to do it is out of scope of this document.
84-
8582
## Building using Docker
8683
To build with Docker you need to have a [buildx](https://github.com/docker/buildx) and [BuildKit](https://github.com/moby/buildkit).<br>
87-
Then you can e.g. create some output dir and build the binary like this:
84+
Docker container is also preparing an SD card images based on [@nisargjhaveri](https://github.com/nisargjhaveri)'s [latests assets](https://github.com/nisargjhaveri/WirelessAndroidAutoDongle/releases).
85+
It has to loop-mount that images, thus an insecure builder is [needed](https://docs.docker.com/reference/cli/docker/buildx/build/#allow).
86+
To sum it up - the following commands are needed when building for the first time:
8887
```
8988
mkdir out
90-
DOCKER_BUILDKIT=1 docker build --output out .
89+
docker buildx create --use --name insecure-builder --buildkitd-flags '--allow-insecure-entitlement security.insecure'
90+
docker buildx build --builder insecure-builder --allow security.insecure --output out .
9191
```
92-
After successful execution the resulting `aa-proxy-rs` will be in `out` directory.
92+
After successful execution the resulting `aa-proxy-rs` and SD card images will be in `out` directory.
93+
94+
## Installing into target
95+
If you currently using a Raspberry Pi with working _WirelessAndroidAutoDongle_, then you can also manually install `aa-proxy-rs`:
96+
97+
You need to transfer the resulting output binary to the target filesystem and start it. I am using ssh/scp for this, but it should be also possible with `wget`.
98+
You can also do it "offline" by making a changes directly on the SD card: mounting system partition and make necessary changes.
99+
Sample [startup script](https://raw.githubusercontent.com/manio/aa-proxy-rs/refs/heads/main/contrib/S93aa-proxy-rs) is provided for convenience.
100+
101+
Example steps:
102+
- put `aa-proxy-rs` into /usr/bin
103+
- put `S93aa-proxy-rs` into /etc/init.d
104+
- remove or disable /etc/init.d/S93aawgd
105+
106+
Startup parameters (see below) are defined [here](https://github.com/manio/aa-proxy-rs/blob/main/contrib/S93aa-proxy-rs#L10).
93107

94108
## Usage
95109
```

contrib/injector.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
# download official images
4+
for pi in 0w 3a 4 zero2w; do
5+
wget https://github.com/nisargjhaveri/WirelessAndroidAutoDongle/releases/latest/download/raspberrypi${pi}-sdcard.img.xz
6+
done
7+
8+
# unpack
9+
for filename in *xz; do
10+
echo ">>> unpacking $filename..."
11+
unxz $filename
12+
done
13+
14+
# process each image and place an aa-proxy-rs
15+
for filename in *img; do
16+
echo ">>> processing $filename..."
17+
mount -o loop,offset=33554944 $filename /mnt
18+
rm /mnt/etc/init.d/S93aawgd
19+
cp /root/S93aa-proxy-rs /mnt/etc/init.d
20+
cp /root/aa-proxy-rs /mnt/usr/bin
21+
umount /mnt
22+
23+
echo ">>> compressing $filename..."
24+
xz $filename
25+
done

0 commit comments

Comments
 (0)