-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·53 lines (44 loc) · 1.71 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
#!/bin/bash -e
VERSIONS="deb8 1ubuntu1"
function abspath {
echo $(cd "$1" && pwd)
}
srcdir=$(abspath "$1")
outdir=$(abspath "$2")
if [[ -x "$srcdir/build.sh" && "$PWD" != "$srcdir" ]]
then
echo "We have a local build file for this component use that"
cd $srcdir
./build.sh $srcdir $outdir
exit $?
fi
echo "Using global build file to build $(basename $srcdir)"
build_container=$RANDOM
ignore_files="Dockerfile *.deb build.sh *.md .DS_Store .vscode *.pyc"
ignore_files_recursive="$ignore_files"
echo "Building the global build container"
docker pull debian:stretch >/dev/null
docker build --rm -t $build_container . >/dev/null && echo "Finished building $build_container"
# Set the paths and current UID and GID to container (to set correct output permissions)
docker_args="-i -v $srcdir:/source-ro:ro -v $outdir:/output -e USER=$(id -u) -e GROUP=$(id -g)"
UBUNTU_FIXES=0
for debian_version in $VERSIONS
do
if [[ "$debian_version" == *"deb"* ]]
then
ignore="$ignore_files /etc/networkd-dispatcher"
elif [[ "$debian_version" == *"ubuntu"* ]]
then
UBUNTU_FIXES=1
ignore="$ignore_files /etc/network /etc/dhcp"
else
ignore=$ignore_files
fi
echo "Creating the deb package for $debian_version"
echo "Source = $srcdir"
echo "Destination = $outdir"
echo "Ignoring these files and directories = $ignore"
docker run --rm -e APPLY_UBUNTU_FIXES="$UBUNTU_FIXES" -e IGNORE_FILES_AND_DIR="$ignore" -e IGNORE_FILES_AND_DIR_RECURSIVE="$ignore_files_recursive" -e debian_version="$debian_version" $docker_args $build_container bash -c "/build.sh"
done
echo "Deleting temporarty build container : $build_container"
docker rmi --force $build_container &>/dev/null