]> git.ipfire.org Git - thirdparty/pdns.git/blob - build-scripts/docker/generate-repo-files.sh
add master support to generate-repo-files.sh
[thirdparty/pdns.git] / build-scripts / docker / generate-repo-files.sh
1 #!/bin/sh
2 #
3 # - `docker build --no-cache --pull --file Dockerfile.auth-41.ubuntu-bionic --tag auth-41.ubuntu-bionic .`
4 # - `docker run -it auth-41.ubuntu-bionic`
5 # - `docker run -it auth-41.ubuntu-bionic /bin/bash`
6 # - `dnsdist --verbose 9.9.9.9`
7 # - `pdns_recursor`
8 # - `pdns_server`
9 #
10 # Remi contributed this snippet:
11 #
12 # #!/bin/bash
13 #
14 # readonly product=dnsdist-15
15 #
16 # for version in centos-6 centos-7 centos-8 debian-buster debian-stretch ubuntu-bionic ubuntu-xenial; do
17 # docker build --no-cache --pull --file Dockerfile.${product}.${version} --tag ${product}.${version} .
18 # done
19 #
20 # for version in centos-6 centos-7 centos-8 debian-buster debian-stretch ubuntu-bionic ubuntu-xenial; do
21 # docker run -it ${product}.${version} dnsdist -v 9.9.9.9
22 # done
23
24 if [ "$1" = "" -o "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]; then
25 echo "Usage: generate-repo-files.sh RELEASE"
26 echo
27 echo " • RELEASE: [ auth-40 | auth-41 | auth-42 | auth-43 | auth-master |"
28 echo " rec-40 | rec-41 | rec-42 | rec-43 | rec-44 | rec-master |"
29 echo " dnsdist-15 | dnsdist-master ]"
30 exit 1
31 fi
32
33
34 write_centos()
35 {
36 OS=centos
37 VERSION=$1
38 PKG=$2
39 CMD=$3
40
41 cat <<EOF > Dockerfile.$RELEASE.$OS-$VERSION
42 FROM $OS:$VERSION
43
44 RUN yum install -y epel-release bind-utils
45 EOF
46
47 if [ "$VERSION" = "6" -o "$VERSION" = "7" ]; then
48 cat <<EOF >> Dockerfile.$RELEASE.$OS-$VERSION
49 RUN yum install -y yum-plugin-priorities
50 EOF
51 elif [ "$RELEASE" = "dnsdist-15" -a "$VERSION" = "8" ]; then
52 cat <<EOF >> Dockerfile.$RELEASE.$OS-$VERSION
53 RUN dnf install -y 'dnf-command(config-manager)'
54 RUN dnf config-manager --set-enabled PowerTools
55 EOF
56 fi
57
58 cat <<EOF >> Dockerfile.$RELEASE.$OS-$VERSION
59 RUN curl -o /etc/yum.repos.d/powerdns-$RELEASE.repo https://repo.powerdns.com/repo-files/$OS-$RELEASE.repo
60 RUN yum install --assumeyes --nobest $PKG
61 EOF
62
63 if [ "$RELEASE" = "rec-43" -o "$RELEASE" = "rec-44" ]; then
64 cat <<EOF >> Dockerfile.$RELEASE.$OS-$VERSION
65
66 RUN mkdir /var/run/pdns-recursor
67 EOF
68 fi
69
70 cat <<EOF >> Dockerfile.$RELEASE.$OS-$VERSION
71
72 CMD $CMD --version
73 EOF
74 }
75
76
77 write_debian_or_ubuntu()
78 {
79 OS=$1
80 VERSION=$2
81 PKG=$3
82 CMD=$4
83
84 cat <<EOF > pdns.list.$RELEASE.$OS-$VERSION
85 deb [arch=amd64] http://repo.powerdns.com/$OS $VERSION-$RELEASE main
86 EOF
87
88 # For the following two maybe only create depending on package, but
89 # it's not really a big deal.
90
91 # if not exists
92 cat <<EOF > dnsdist.debian-and-ubuntu
93 Package: dnsdist*
94 Pin: origin repo.powerdns.com
95 Pin-Priority: 600
96 EOF
97
98 # if not exists
99 cat <<EOF > pdns.debian-and-ubuntu
100 Package: pdns-*
101 Pin: origin repo.powerdns.com
102 Pin-Priority: 600
103 EOF
104
105 cat <<EOF > Dockerfile.$RELEASE.$OS-$VERSION
106 FROM $OS:$VERSION
107
108 RUN apt-get update
109 RUN apt-get install -y curl gnupg dnsutils apt-transport-https
110
111 COPY dnsdist.debian-and-ubuntu /etc/apt/preferences.d/dnsdist
112 COPY pdns.debian-and-ubuntu /etc/apt/preferences.d/pdns
113 COPY pdns.list.$RELEASE.$OS-$VERSION /etc/apt/sources.list.d/pdns.list
114
115 RUN curl https://repo.powerdns.com/FD380FBB-pub.asc | apt-key add -
116 RUN curl https://repo.powerdns.com/CBC8B383-pub.asc | apt-key add -
117 RUN apt-get update
118 RUN apt-get install -y $PKG
119 EOF
120
121 if [ "$RELEASE" = "rec-43" -o "$RELEASE" = "rec-44" ]; then
122 cat <<EOF >> Dockerfile.$RELEASE.$OS-$VERSION
123
124 RUN mkdir /var/run/pdns-recursor
125 EOF
126 fi
127
128 cat <<EOF >> Dockerfile.$RELEASE.$OS-$VERSION
129
130 CMD $CMD --version
131 EOF
132 }
133
134
135 write_debian()
136 {
137 write_debian_or_ubuntu debian $1 $2 $3
138 }
139
140
141 write_ubuntu()
142 {
143 write_debian_or_ubuntu ubuntu $1 $2 $3
144 }
145
146
147 RELEASE=$1
148
149 if [ "$RELEASE" = "auth-40" ]; then
150 write_centos 6 pdns pdns_server
151 write_centos 7 pdns pdns_server
152 write_debian jessie pdns-server pdns_server
153 write_debian stretch pdns-server pdns_server
154 write_ubuntu trusty pdns-server pdns_server
155 write_ubuntu xenial pdns-server pdns_server
156 elif [ "$RELEASE" = "auth-41" ]; then
157 write_centos 6 pdns pdns_server
158 write_centos 7 pdns pdns_server
159 write_debian jessie pdns-server pdns_server
160 write_debian stretch pdns-server pdns_server
161 write_ubuntu trusty pdns-server pdns_server
162 write_ubuntu xenial pdns-server pdns_server
163 write_ubuntu bionic pdns-server pdns_server
164 elif [ "$RELEASE" = "auth-42" -o "$RELEASE" = "auth-43" -o "$RELEASE" = "auth-master" ]; then
165 write_centos 6 pdns pdns_server
166 write_centos 7 pdns pdns_server
167 write_centos 8 pdns pdns_server
168 write_debian stretch pdns-server pdns_server
169 write_debian buster pdns-server pdns_server
170 write_ubuntu xenial pdns-server pdns_server
171 write_ubuntu bionic pdns-server pdns_server
172 elif [ "$RELEASE" = "rec-40" ]; then
173 write_centos 6 pdns-recursor pdns_recursor
174 write_centos 7 pdns-recursor pdns_recursor
175 write_debian jessie pdns-recursor pdns_recursor
176 write_debian stretch pdns-recursor pdns_recursor
177 write_ubuntu trusty pdns-recursor pdns_recursor
178 write_ubuntu xenial pdns-recursor pdns_recursor
179 elif [ "$RELEASE" = "rec-41" ]; then
180 write_centos 6 pdns-recursor pdns_recursor
181 write_centos 7 pdns-recursor pdns_recursor
182 write_debian jessie pdns-recursor pdns_recursor
183 write_debian stretch pdns-recursor pdns_recursor
184 write_ubuntu trusty pdns-recursor pdns_recursor
185 write_ubuntu xenial pdns-recursor pdns_recursor
186 write_ubuntu bionic pdns-recursor pdns_recursor
187 elif [ "$RELEASE" = "rec-42" -o "$RELEASE" = "rec-43" -o "$RELEASE" = "rec-44" -o "$RELEASE" = "rec-master" ]; then
188 write_centos 6 pdns-recursor pdns_recursor
189 write_centos 7 pdns-recursor pdns_recursor
190 write_centos 8 pdns-recursor pdns_recursor
191 write_debian stretch pdns-recursor pdns_recursor
192 write_debian buster pdns-recursor pdns_recursor
193 write_ubuntu xenial pdns-recursor pdns_recursor
194 write_ubuntu bionic pdns-recursor pdns_recursor
195 elif [ "$RELEASE" = "dnsdist-15" -o "$RELEASE" = "dnsdist-master" ]; then
196 write_centos 6 dnsdist dnsdist
197 write_centos 7 dnsdist dnsdist
198 write_centos 8 dnsdist dnsdist
199 write_debian stretch dnsdist dnsdist
200 write_debian buster dnsdist dnsdist
201 write_ubuntu xenial dnsdist dnsdist
202 write_ubuntu bionic dnsdist dnsdist
203 else
204 echo "Invalid release: $RELEASE"
205 exit 1
206 fi