#!/bin/sh

continuous_integration_mode=
[ "$1" = '--continuous' ] && continuous_integration_mode=--continuous
[ "$1" = '-c' ] && continuous_integration_mode=--continuous

set -e

. autorepo-config

. parentlock-sh-functions
# remove if use your own trap
parentlock_set_unlock_workdir_trap_on_int_term_exit

parentlock_lock_workdir_or_exit

#rm -rf $AUTOREPO_HOME/OUT
#autorepo-genrepo # should be run once per repository
set -v
autorepo-rm-out-dups > $AUTOREPO_HOME/dups.log 2>&1
[ -s $AUTOREPO_HOME/dups.log ] && cat $AUTOREPO_HOME/dups.log || rm -f cat $AUTOREPO_HOME/dups.log
autorepo-rotate-bad-ugly
autorepo-mass-build $continuous_integration_mode
autorepo-merge-good
autorepo-purge --purge -q > $AUTOREPO_HOME/purge.log
autorepo-relink-srpms
autorepo-make-filelists
autorepo-genrepo
if [ -s $AUTOREPO_HOME/purge.log ]; then cat $AUTOREPO_HOME/purge.log; else rm -f $AUTOREPO_HOME/purge.log; fi
autorepo-repo-unmets

parentlock_unlock_workdir_safe
