File generator_pom of Package obs-service-generator_pom

#!/bin/bash

# A wrapper around pom2spec

NAME=""
ARTIFACT=""
VERSION=""

while test $# -gt 0; do
  case $1 in
    *-name)
      NAME="$2"
      shift
    ;;
    *-artifactid)
      ARTIFACT="$2"
      shift
    ;;
    *-version)
      VERSION="$2"
      shift
    ;;
    *-outdir)
      OUTDIR="$2"
      shift
    ;;
    *)
      echo Unknown parameter $1.
      echo 'Usage: generator_qmake [--file $FILE] --outdir $OUT'
      exit 1
    ;;
  esac
  shift
done

if [ -z "$OUTDIR" ]; then
  echo "ERROR: no output directory is given via --outdir parameter!"
  exit 1
fi

if [ -z "$NAME" ]; then
  NAME="${OBS_SERVICE_PACKAGE/.*/}"
fi

if [ -z "$ARTIFACT" ]; then
  ARTIFACT="${OBS_SERVICE_PACKAGE/.*/}"
fi

if [ -z "$VERSION" ]; then
  # not defined, just pick the best?
  VERSION=`/usr/lib/obs/service/pom2spec "$NAME" "$ARTIFACT" |& sed -n 's,^\ -\ \(.*\),\1,p' | sort | head -n 1`
fi

# run the code generator
cd "$OUTDIR" 
/usr/lib/obs/service/pom2spec "$NAME" "$ARTIFACT" "$VERSION" || exit 1

# rename spec file to make diffing easier
mv *.spec ${NAME}.spec

# download files
/usr/lib/obs/service/download_files --outdir .

#cleanup
cd -

# success !
exit 0
openSUSE Build Service is sponsored by