-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_image.sh
executable file
·39 lines (28 loc) · 1.1 KB
/
build_image.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -euxo pipefail
SCRIPT_DIR="$(dirname "$(realpath -s "${BASH_SOURCE[0]}")")"
cd "$SCRIPT_DIR"
cd image
cp ../build-ev3/{sling,sinter_host} .
mkdir -p executables
cp ../build-ev3/executables/uuidtob62 executables
# Copy and rename our user executables
cp ../build-ev3/executables/show_qrcode executables/'Show QR Code'
cp ../build-ev3/executables/service_control executables/'Source Academy Settings'
cp kill_source.sh executables/'Kill Source Program'
docker build -t sourceacademy/ev3-source .
TMPDIR=$(mktemp -d)
TARFILE="$TMPDIR/ev3-source.tar"
IMGFILE="$TMPDIR/ev3-source.img"
OUTFILE="$SCRIPT_DIR/ev3-source.img.zip"
bash "$SCRIPT_DIR/brickstrap.sh" create-tar sourceacademy/ev3-source "$TARFILE"
docker rmi sourceacademy/ev3-source
export BRICKSTRAP_IMAGE_FILE_SIZE=$(echo $(($(du -m "$TARFILE" | cut -f1)*6/4+100)) | cut -d. -f1)M
echo 'Using BRICKSTRAP_IMAGE_FILE_SIZE='$BRICKSTRAP_IMAGE_FILE_SIZE
bash "$SCRIPT_DIR/brickstrap.sh" create-image "$TARFILE" "$IMGFILE"
rm "$TARFILE"
pushd "$TMPDIR"
zip -v "$OUTFILE" ev3-source.img
popd
rm -rf "$TMPDIR"
>&2 echo "Image created at $OUTFILE"