source: ntrip/trunk/BNC/docker/build.sh@ 10654

Last change on this file since 10654 was 10654, checked in by wiese, 13 days ago

ADD: build rockylinux

  • Property svn:executable set to *
File size: 2.7 KB
Line 
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
7set -e
8cd "$(dirname $0)/.."
9
10bncvers=$(grep "#define BNCVERSION \"" src/bncversion.h | cut -d " " -f3 | tr -d \")
11if [ -z "$bncvers" ]; then
12 echo "ERROR: could not find bncvers"; exit 1
13fi
14
15# Run image, copy the compiled executable "bncnew" from the container
16# and then remove the container.
17function 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
26function 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
36function buildBookworm () {
37 echo "Build BNC $bncvers for debian 12 (bookworm) ..."
38 [ -f "bncnew" ] && rm bncnew
39 docker build -t bookworm/bnc:v$bncvers -f docker/Dockerfile.bookworm .
40 getBncFromImage "bookworm/bnc:v$bncvers"
41 target=$(realpath "bnc-$bncvers-debian12")
42 mv bncnew $target
43 echo "$target created"
44}
45
46function buildLeap () {
47 echo "Build BNC $bncvers for opensuse (leap) ..."
48 [ -f "bncnew" ] && rm bncnew
49 docker build -t leap/bnc:v$bncvers -f docker/Dockerfile.leap .
50 getBncFromImage "leap/bnc:v$bncvers"
51 target=$(realpath "bnc-$bncvers-leap")
52 mv bncnew $target
53 echo "$target created"
54}
55
56function buildUbi8 () {
57 echo "Build BNC $bncvers for redhat/ubi8 ..."
58 [ -f "bncnew" ] && rm bncnew
59 docker build -t ubi8.6/bnc:v$bncvers -f docker/Dockerfile.ubi8 .
60 getBncFromImage "ubi8.6/bnc:v$bncvers"
61 target=$(realpath "bnc-$bncvers-el8.6")
62 mv bncnew $target
63 echo "$target created"
64}
65
66# rockylinux 9/el9
67function buildRocky () {
68 echo "Build BNC $bncvers for rockylinux ..."
69 [ -f "bncnew" ] && rm bncnew
70 docker build -t rocky9/bnc:v$bncvers -f docker/Dockerfile.rocky9 .
71 getBncFromImage "rocky9/bnc:v$bncvers"
72 target=$(realpath "bnc-$bncvers-rocky9")
73 mv bncnew $target
74 echo "$target created"
75}
76
77case $1 in
78 "bullseye")
79 buildBullseye;
80 ;;
81 "bookworm")
82 buildBookworm;
83 ;;
84 "leap")
85 buildLeap;
86 ;;
87 "ubi")
88 buildUbi8;
89 ;;
90 "rocky")
91 buildRocky;
92 ;;
93 "all")
94 buildBookworm;
95 buildLeap;
96 buildUbi8;
97 ;;
98 *)
99 echo "Usage:"
100 echo " $0 { bullseye | leap | ubi | rocky | all }"
101 echo
102 exit 1;
103 ;;
104esac
105
Note: See TracBrowser for help on using the repository browser.