#!/bin/bash # $HeadURL$ $LastChangedRevision$ PROGNAME=`basename $0` SANDPIT=`pwd` . $(ade-config ade_share_prefix)/include/adetestsupport.sh ############################################################################## # # Purpose of test: to verify symlinks are created pointing to the right things # # Bug id: # ############################################################################## # Ensure dates are consistently formatted export LC_ALL=C # Start of support functions filter_variant_text() { UNAMEN=${UNAMEN:-$(uname -n)} # Note how the variable *width* of a hostname - and therefore of the padding # that follows it in column-aligned output - means that we can't change # just to VARIANT-HOSTNAME but *with* padding to # VARIANT-HOSTNAME with fixed width padding. eval "$@" | sed -e 's/[A-Z][a-z][a-z] [A-Z][a-z][a-z] [1-3 ][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [A-Z][A-Z]* [1-2][0-9][0-9][0-9]/Fri Dec 31 23:59:59 GMT 1999/g' \ -e 's/^\(pub\)\( *\)\([^ ]*\)\( *\)\([^ ]*\)$/\1\2VARIANT-KEY-ID\4VARIANT-DATE/' \ -e "s@$SANDPIT@VARIANT-SANDPIT@g" \ -e "s/$UNAMEN */VARIANT-HOSTNAME /g" \ -e "s/$UNAMEN\([^ \t]\)/VARIANT-HOSTNAME\1/g" \ -e "s/20[1-9][0-9][0-1][0-9][0-3][0-9][0-2][0-9][0-5][0-9][0-5][0-9]/VARIANT-TIMESTAMP/g" # return the passed command's return code, not sed's. return ${PIPESTATUS[0]} } perm() { local ITEMS OUT I ITEMS="$1" OUT="$2" [[ "$ITEMS" != "" ]] || { echo "$OUT" && return; } for ((i=0; i<${#ITEMS}; i++ )); do ( perm "${ITEMS:0:i}${ITEMS:i+1}" "$OUT${ITEMS:i:1}" ) done } # End of support functions echo "setting up environment ..." # Ensure DB is created in sandpit export PAA_RCDIR=$SANDPIT/.paa # Force use of non-interactive editor mkdir $SANDPIT/bin echo -e '#!/bin/sh\n\ncat > $1' > $SANDPIT/bin/caton chmod 755 $SANDPIT/bin/caton export EDITOR=$SANDPIT/bin/caton # Ensure user's real shares are not deleted (even though this script doesn't create any) export PAA_STATE_PREFIX=$SANDPIT/var # Central control over paa's verbosity VERBOSE_OPTS="" echo "generating combinations ..." FREEZE_DIR_SUFFIXES=$(perm a/b | grep '^./.$' | sort -u | paste -d' ' -s) INDIRECT_DIR_SUFFIXES="$FREEZE_DIR_SUFFIXES" echo "registering host ..." paa $VERBOSE_OPTS host saturn rpm centos 6 i386 for FREEZE_DIR_SUFFIX in $FREEZE_DIR_SUFFIXES; do for INDIRECT_DIR_SUFFIX in $INDIRECT_DIR_SUFFIXES; do echo "setting up ($FREEZE_DIR_SUFFIX, $INDIRECT_DIR_SUFFIX) ..." # Create repo paa $VERBOSE_OPTS repo centos-6-i386 rpm mirrored true # Configure repo paa $VERBOSE_OPTS editrepo centos-6-i386 <./" mirror_dir "$SANDPIT/mirrors/" freeze_dir "$SANDPIT/$FREEZE_DIR_SUFFIX/." indirect_dir "$SANDPIT/$INDIRECT_DIR_SUFFIX/." mirror_cmd "date > date" layout 6 "." EOF paa $VERBOSE_OPTS mirror centos-6-i386 echo "creating freeze and indirect ..." paa $VERBOSE_OPTS freeze centos-6-i386 paa $VERBOSE_OPTS indirect centos-6-i386 saturn NEWEST-FREEZE echo "inspecting ..." for THING in $INDIRECT_DIR_SUFFIX/*; do if [ -h $THING ]; then printf "%-40s %-60s [ %-20s ]\n" "$THING" "--> $(filter_variant_text "readlink $THING")" "symlink, $({ [ -d $THING ] && echo exists; } || echo missing)" elif [ -d $THING ]; then printf "%-40s %-60s [ %-20s ]\n" "$(filter_variant_text "echo $THING")" "" "directory" else printf "%-40s %-60s [ %-20s ]\n" "$THING" "" "unexpected" fi done echo "cleaning up ..." paa $VERBOSE_OPTS unindirect centos-6-i386 saturn paa $VERBOSE_OPTS unfreeze centos-6-i386 NEWEST-FREEZE paa $VERBOSE_OPTS unmirror centos-6-i386 paa $VERBOSE_OPTS unrepo centos-6-i386 echo done done