1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # Build BNC from sources for multiple operating systems
|
---|
4 | # On redhat/centos install "dnf install podman-docker"
|
---|
5 | # Wiese, 2022
|
---|
6 |
|
---|
7 | set -e
|
---|
8 | cd "$(dirname $0)/.."
|
---|
9 |
|
---|
10 | bncvers=$(grep "#define BNCVERSION \"" src/bncversion.h | cut -d " " -f3 | tr -d \")
|
---|
11 | if [ -z "$bncvers" ]; then
|
---|
12 | echo "ERROR: could not find bncvers"; exit 1
|
---|
13 | fi
|
---|
14 |
|
---|
15 | # Run image, copy the compiled executable "bncnew" from the container
|
---|
16 | # and then remove the container.
|
---|
17 | function getBncFromImage () {
|
---|
18 | local image="$1"
|
---|
19 | local imgID=$(docker images --format "{{.ID}}" $image)
|
---|
20 | local con=$(docker create $imgID)
|
---|
21 | docker cp $con:/tmp/BNC/bnc bncnew
|
---|
22 | docker rm $con
|
---|
23 | [ -s "bncnew" ] || { echo "executable \"bncnew\" does not exist"; exit 1; }
|
---|
24 | }
|
---|
25 |
|
---|
26 | function buildBullseye () {
|
---|
27 | echo "Build BNC $bncvers for debian 11 (bullseye) ..."
|
---|
28 | [ -f "bncnew" ] && rm bncnew
|
---|
29 | docker build -t bullseye/bnc:v$bncvers -f docker/Dockerfile.bullseye .
|
---|
30 | getBncFromImage "bullseye/bnc:v$bncvers"
|
---|
31 | target=$(realpath "bnc-$bncvers-debian11")
|
---|
32 | mv bncnew $target
|
---|
33 | echo "$target created"
|
---|
34 | }
|
---|
35 |
|
---|
36 | function buildLeap () {
|
---|
37 | echo "Build BNC $bncvers for opensuse (leap) ..."
|
---|
38 | [ -f "bncnew" ] && rm bncnew
|
---|
39 | docker build -t leap/bnc:v$bncvers -f docker/Dockerfile.leap .
|
---|
40 | getBncFromImage "leap/bnc:v$bncvers"
|
---|
41 | target=$(realpath "bnc-$bncvers-leap")
|
---|
42 | mv bncnew $target
|
---|
43 | echo "$target created"
|
---|
44 | }
|
---|
45 |
|
---|
46 | function buildUbi8 () {
|
---|
47 | echo "Build BNC $bncvers for redhat/ubi8 ..."
|
---|
48 | [ -f "bncnew" ] && rm bncnew
|
---|
49 | docker build -t ubi8.6/bnc:v$bncvers -f docker/Dockerfile.ubi8 .
|
---|
50 | getBncFromImage "ubi8.6/bnc:v$bncvers"
|
---|
51 | target=$(realpath "bnc-$bncvers-el8.6")
|
---|
52 | mv bncnew $target
|
---|
53 | echo "$target created"
|
---|
54 | }
|
---|
55 |
|
---|
56 | case $1 in
|
---|
57 | "bullseye")
|
---|
58 | buildBullseye;
|
---|
59 | ;;
|
---|
60 | "leap")
|
---|
61 | buildLeap;
|
---|
62 | ;;
|
---|
63 | "ubi")
|
---|
64 | buildUbi8;
|
---|
65 | ;;
|
---|
66 | "all")
|
---|
67 | buildBullseye;
|
---|
68 | buildLeap;
|
---|
69 | buildUbi8;
|
---|
70 | ;;
|
---|
71 | *)
|
---|
72 | echo "Usage:"
|
---|
73 | echo " $0 { bullseye | leap | ubi | all }"
|
---|
74 | echo
|
---|
75 | exit 1;
|
---|
76 | ;;
|
---|
77 | esac
|
---|
78 |
|
---|