File update.sh of Package simple-ccsm

#!/bin/sh

oscmodule=$(basename $PWD)

if [ ! -d $oscmodule ]; then
  echo "git checkout folder $oscmodule does not exist. Aborting..."
  exit 1
fi

pushd $oscmodule; status=$(git pull); git submodule update; commitid=$(git log | head -n1); popd
if [ "$status" != "Already up-to-date." ]; then
  if [ -n "$(head -n4 $oscmodule.changes  | tail -n1 | grep commit)" ]; then
    # The last changelog entry already was an automatic forward... let's not pullute too much.
    sed -i 1,5d $oscmodule.changes
  fi
  tar cjf $oscmodule.tar.bz2 $oscmodule
  osc vc -m "Forward to $commitid"
  osc ci -m "Forward to $commitid" --skip-validation
fi