-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·55 lines (46 loc) · 1.89 KB
/
build.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
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
SELF="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$SELF/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
MYDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
cd $MYDIR
TMPDIR=$MYDIR/tmp
mkdir -p $TMPDIR/work
cp Dockerfile.stub $TMPDIR/Dockerfile.tmp
for d in ${MYDIR}/platforms/* ; do
D=$(basename ${d})
done
rm -rf $TMPDIR/mbed-cloud-client-example
cd $TMPDIR/work
git clone http://github.com/PelionIoT/mbed-cloud-client-example
cp $MYDIR/mbed-cloud-client-example-aarch64.patch $TMPDIR/work
# look in platforms folder, and slap all stub files into a single Dockerfile.temp
cd $MYDIR
for d in ${MYDIR}/platforms/* ; do
echo "platform: ${d}"
D=$(basename ${d})
ADDS=tmp/${D}/adds
# this is a directory on the container image
MYPLATFORM=/builder/${D}
CONTAINTER_OUTPUT=/out
mkdir -p $TMPDIR/${D}/adds
if [ -e $MYDIR/platforms/${D}/prebuild.sh ]; then
echo "prebuild for ${D}..."
ADDS=${ADDS} CONTAINTER_OUTPUT=/out bash $MYDIR/platforms/${D}/prebuild.sh
else
echo "No prebuild.sh for platform ${D}"
fi
if [ -e $MYDIR/platforms/${D}/Dockerfile.stub ]; then
# make the generator from the template
$MYDIR/bash-tpl $MYDIR/platforms/${D}/Dockerfile.stub > $TMPDIR/${D}/Dockerfile.stub.out
# run generator to create final stub of Dockerfile
MYDIR=platforms/${D} ADDS=${ADDS} CONTAINTER_OUTPUT=/out MYPLATFORM=${MYPLATFORM} bash $TMPDIR/${D}/Dockerfile.stub.out > $TMPDIR/${D}/Dockerfile.stub.final
cat $TMPDIR/${D}/Dockerfile.stub.final >> $TMPDIR/Dockerfile.tmp
else
echo "No Dockerfile.stub for platform ${D}"
fi
done
docker build . -f $TMPDIR/Dockerfile.tmp --tag izuma-cloud-client-builder:latest