blob: 2fae03a58b0da3842eecbc619e5a791b103416c8 [file] [log] [blame]
Mike Marchetti13d76c82018-09-19 15:00:36 -04001#!/bin/sh
beierlma4a37f72020-06-26 12:55:01 -04002#
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#
Mike Marchetti13d76c82018-09-19 15:00:36 -040017
garciadeblasfa81f282020-12-15 00:32:13 +000018RELEASE="ReleaseNINE-daily"
Mike Marchetti13d76c82018-09-19 15:00:36 -040019REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
20REPOSITORY="testing"
21REPOSITORY_BASE="http://osm-download.etsi.org/repository/osm/debian"
22DEBUG=
23
Mike Marchetti9cf41562018-10-01 12:37:59 -040024while getopts ":r:k:u:R:b:-:dm:p:" o; do
Mike Marchetti13d76c82018-09-19 15:00:36 -040025 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 ;;
Mike Marchetti9cf41562018-10-01 12:37:59 -040041 p)
42 PACKAGE_NAME=${OPTARG}
43 ;;
Mike Marchetti13d76c82018-09-19 15:00:36 -040044 m)
45 MDG=${OPTARG}
46 ;;
47 -)
48 ;;
49 esac
50done
51
52if [ -z "$MDG" ]; then
53 echo "missing MDG"
54fi
55
Mike Marchetti9cf41562018-10-01 12:37:59 -040056[ -z "$PACKAGE_NAME" ] && PACKAGE_NAME=$MDG
57
Mike Marchetti13d76c82018-09-19 15:00:36 -040058if [ -n "$DEBUG" ]; then
59 echo curl $REPOSITORY_BASE/$RELEASE/dists/$REPOSITORY/$MDG/binary-amd64/Packages
60fi
61
Mike Marchetti9cf41562018-10-01 12:37:59 -040062curl $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)) ) ) {
Mike Marchetti13d76c82018-09-19 15:00:36 -040064 package=1;
65 } else if (package==1 && match($1,"Version:")) {
66 package=0;
67 printf("%s\n", $2);
68 }
69}' | head -1