"Fossies" - the Fresh Open Source Software Archive

Member "LinOTP-release-2.10.5.3/ci/deb-upload-check" (24 Jun 2019, 1612 Bytes) of package /linux/misc/LinOTP-release-2.10.5.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env bash
    2 #
    3 # deb-upload-check COMMAND
    4 #
    5 # Executes COMMAND only if the version number of the file in
    6 # ./artifacts/Packages is greater than that of the corresponding
    7 # package in the remote repository, or if the package does not exist
    8 # in the remote repository. Use with “dput” in Gitlab pipelines, as in
    9 #
   10 #   script:
   11 #     ...
   12 #     - deb-upload-check dput ./artifacts/*.changes
   13 #     ...
   14 #
   15 # Use "-r REPO-URL", "-d DIST" (usually "stretch"), "-c COMPONENT"
   16 # (usually "sva3"), and "-a ARCHITECTURE" (usually "amd64") as
   17 # required. The "*.changes" file is assumed to be in "./artifacts";
   18 # use "-A ARTIFACTS-DIR" to override.
   19 #
   20 # 2018-03-27 Anselm Lingnau <anselm.lingnau@keyidentity.com>
   21 set -ex
   22 
   23 OPTIND=1
   24 
   25 repo=http://unknown
   26 dist=stretch
   27 component=linotp
   28 arch=amd64
   29 artifacts=./artifacts
   30 
   31 while getopts "r:d:c:a:A:" opt; do
   32     case "$opt" in
   33     r) repo=$OPTARG
   34        ;;
   35     d) dist=$OPTARG
   36        ;;
   37     c) component=$OPTARG
   38        ;;
   39     a) arch=$OPTARG
   40        ;;
   41     A) artifacts=$OPTARG
   42        ;;
   43     esac
   44 done
   45 
   46 shift $((OPTIND-1))
   47 
   48 [ "$1" = "--" ] && shift
   49 
   50 fn=$(cd "$artifacts"; ls *.changes)
   51 if [ -z "$fn" ]; then
   52     echo >&2 "$0: no *.changes file found in $dir, aborting"
   53     exit 2
   54 fi
   55 
   56 local_version="${fn#*_}"
   57 local_version="${local_version%_*}"
   58 remote_version=$(curl --silent "$repo/dists/$dist/$component/binary-$arch/Packages" \
   59              | sed -ne '/Package: '${fn%%_*}'/,/^$/s/^Version: //p')
   60 
   61 if dpkg --compare-versions "$local_version" gt "$remote_version"; then
   62     if [ $# \> 0 ]; then
   63     exec $@
   64     fi
   65     exit 0
   66 fi
   67 echo >&2 "$0: local $local_version <= remote $remote_version, not uploading"
   68 exit 1