#!/bin/bash # automaint -- batch automatic maintainance tool of the autodist suite # Copyright (C) 2013-2014 by Silvan Calarco # # Released under the terms of the GNU GPL release 3 license # VERSION=0.9.7 # First in vector is base arch ARCHS=(i586 arm x86_64) . /etc/autodist/config me=(${0##*/} $VERSION "Sat Mar 20 2011") function usage() { echo "\ ${me[0]} ${me[1]} "$"Copyright (C) 2013 Silvan Calarco "" "$"Released under the terms of the GNU GPL v3 license" echo " "$"Batch automatic maintainance tool of the autodist suite."" "$"Usage"": $me [-s repository -d repository ] [-p repository] [-h] [-v] -d repository "$"Main destination repository -p repository "$"Port repository -s repository "$"Automatic/Staging builds source repository -h "$"Show this help and exit -t "$"Test mode (no change will be made) -v "$"Verbose output " } # for webbuild message function cgi_encodevar() { local string="${1}" local strlen=${#string} local encoded="" for (( pos=0 ; pos&2 exit 1 } for a in `seq 1 ${#ARCHS[*]}`; do echo -n "${pkglist[$a-1]} " >> $tmpfile done allpkgs="`cat $tmpfile | xargs -n 1 | sort -u | xargs`" rm -f $tmpfile for p in ${allpkgs}; do pkgcontinue= needsport= for a in `seq 1 ${#ARCHS[*]}`; do for w in ${warningslist[*]}; do [ "$p" = "$w" ] && { pkgcontinue=1; break; } done [ "$pkgcontinue" ] && break get_pkg_buildinfo $LOCAL_REPS_BASE_DIR/distromatic/$SOURCE_REPOSITORY ${ARCHS[$a-1]} $p [ "$pkg_name" ] || { #echo "$p: looks like a new package; skipping." continue } for o in ${needportlist[*]}; do [ "$p" = "$o" ] && { needsport=1; break; } done [ "$needsport" -a ! "$PORT_REPOSITORY" ] && break spkg_version=$pkg_version spkg_release=$pkg_release get_pkg_buildinfo $LOCAL_REPS_BASE_DIR/distromatic/$DEST_REPOSITORY ${ARCHS[$a-1]} $p if [ "$pkg_version" = "$spkg_version" ]; then if [ "$pkg_release" = "$spkg_release" ]; then echo "$p: same release as upstream; skipping." break fi update_type="release" else OIFS=$IFS IFS='.' read -ra SVER <<< "$spkg_version" read -ra VER <<< "$pkg_version" IFS=$OIFS for i in `seq 1 ${#SVER[*]}`; do [ "${SVER[i-1]}" != "${VER[i-1]}" ] && break done if [ "$i" = "${#SVER[*]}" ]; then if [[ 64#${SVER[i-1]} -gt 64#89 && 64#${VER[i-1]} -lt 64#80 ]]; then [ "$VERBOSE" ] && echo "$p: dubious beta upgrade from ${VER[i-1]} to ${SVER[i-1]}; skipping." break fi update_type="minor" else [ "$VERBOSE" ] && echo "$p: dubious not-minor version update $i/${#SVER[*]}: ${SVER[i-1]} != ${VER[i-1]}; skipping." break fi fi if [ "$needsport" ]; then echo "$p: importing from $SOURCE_REPOSITORY to $PORT_REPOSITORY ($spkg_version-$spkg_release -> $pkg_version-$pkg_release)" if [ ! "$TESTMODE" ]; then autodist-repository import $SOURCE_REPOSITORY $p -d $PORT_REPOSITORY -y >/dev/null if [ $? -eq 0 -a "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=${WEBBUILD_SECRET}&USER_EMAIL=$WEBBUILD_EMAIL&\ MESSAGE=`cgi_encodevar \"imported $p from $SOURCE_REPOSITORY to $PORT_REPOSITORY for porting\"`" >/dev/null fi fi else echo "$p: importing from $SOURCE_REPOSITORY to $DEST_REPOSITORY ($spkg_version-$spkg_release -> $pkg_version-$pkg_release; update type: $update_type)" if [ ! "$TESTMODE" ]; then autodist-repository import $SOURCE_REPOSITORY $p -d $DEST_REPOSITORY -y >/dev/null if [ $? -eq 0 -a "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=${WEBBUILD_SECRET}&USER_EMAIL=$WEBBUILD_EMAIL&\ MESSAGE=`cgi_encodevar \"imported $p from $SOURCE_REPOSITORY to $DEST_REPOSITORY\"`" >/dev/null fi fi fi break done done exit 0