Updated Dockerfiles to use ReleaseEIGHT-daily repo by default
[osm/devops.git] / docker / mk / get_version.sh
1 #!/bin/sh
2 #
3 # Copyright 2020 ETSI
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17
18 RELEASE="ReleaseEIGHT-daily"
19 REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
20 REPOSITORY="testing"
21 REPOSITORY_BASE="http://osm-download.etsi.org/repository/osm/debian"
22 DEBUG=
23
24 while getopts ":r:k:u:R:b:-:dm:p:" o; do
25 case "${o}" in
26 r)
27 REPOSITORY=${OPTARG}
28 ;;
29 R)
30 RELEASE=${OPTARG}
31 ;;
32 k)
33 REPOSITORY_KEY=${OPTARG}
34 ;;
35 u)
36 REPOSITORY_BASE=${OPTARG}
37 ;;
38 d)
39 DEBUG=y
40 ;;
41 p)
42 PACKAGE_NAME=${OPTARG}
43 ;;
44 m)
45 MDG=${OPTARG}
46 ;;
47 -)
48 ;;
49 esac
50 done
51
52 if [ -z "$MDG" ]; then
53 echo "missing MDG"
54 fi
55
56 [ -z "$PACKAGE_NAME" ] && PACKAGE_NAME=$MDG
57
58 if [ -n "$DEBUG" ]; then
59 echo curl $REPOSITORY_BASE/$RELEASE/dists/$REPOSITORY/$MDG/binary-amd64/Packages
60 fi
61
62 curl $REPOSITORY_BASE/$RELEASE/dists/$REPOSITORY/$MDG/binary-amd64/Packages 2>/dev/null | awk -v pkg=$PACKAGE_NAME '{
63 if ( /Package:/ && match($2,sprintf("%s$",tolower(pkg)) ) ) {
64 package=1;
65 } else if (package==1 && match($1,"Version:")) {
66 package=0;
67 printf("%s\n", $2);
68 }
69 }' | head -1