-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_images.sh
executable file
·61 lines (44 loc) · 1.56 KB
/
build_images.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash -e
ROBORIO_ZIP=$1
if [ "$ROBORIO_ZIP" == "" ]; then
echo "Usage: $0 roborio_image"
exit 1
fi
ROBORIO_ZIP_BASE=$(basename $ROBORIO_ZIP)
# Extract the year/version from it
# -> Assuming format of FRC_roboRIO_2018_v16.zip
if [ "${ROBORIO_ZIP_BASE:0:12}" != "FRC_roboRIO_" ]; then
echo "Error: Expected RIO_IMAGE to begin with 'FRC_roboRIO_'"
exit 1
fi
VERSION="${ROBORIO_ZIP_BASE:12:-4}"
function rm_unpacked {
[ ! -d unpacked ] || rm -rf unpacked
}
trap rm_unpacked EXIT
rm_unpacked
# only build the base image if needed
if [[ "$(docker images -q roborio:$VERSION 2> /dev/null)" == "" ]]; then
# Unpack the roborio image zipfile, ensure we're sane
mkdir unpacked
unzip "$ROBORIO_ZIP" -d unpacked
# there are two files in there, one is a zip file, unzip the zip file
mkdir unpacked/more
unzip unpacked/*.zip -d unpacked/more
# Make sure the file we're looking for is there
if [ ! -f unpacked/more/systemimage.tar.gz ]; then
echo "Error: Expected to find systemimage.tar.gz, did not find it!"
exit 1
fi
# Create a docker image from it
echo "Importing..."
docker import unpacked/more/systemimage.tar.gz roborio:tmp
rm_unpacked
docker build -f Dockerfile.base -t roborio:${VERSION} .
docker rmi roborio:tmp
docker tag roborio:${VERSION} roborio:latest
fi
# Build the build image too
[ -f libfakearmv7l.so ] || wget https://github.com/robotpy/fakearmv7l/releases/download/v1/libfakearmv7l.so
docker build -f Dockerfile.build . -t roborio-build:${VERSION}
docker tag roborio-build:${VERSION} roborio-build:latest