Print this page
XXX Remove nawk(1)


1821 trap cleanup 0
1822 trap cleanup_signal 1 2 3 15
1823 
1824 #
1825 # Generic lock file processing -- make sure that the lock file doesn't
1826 # exist.  If it does, it should name the build host and PID.  If it
1827 # doesn't, then make sure we can create it.  Clean up locks that are
1828 # known to be stale (assumes host name is unique among build systems
1829 # for the workspace).
1830 #
1831 function create_lock {
1832         lockf=$1
1833         lockvar=$2
1834 
1835         ldir=`dirname $lockf`
1836         [ -d $ldir ] || newdir $ldir || exit 1
1837         eval $lockvar=$lockf
1838 
1839         while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do
1840                 basews=`basename $CODEMGR_WS`
1841                 ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid
1842                 if [ "$host" != "$hostname" ]; then
1843                         echo "$MACH build of $basews apparently" \
1844                             "already started by $user on $host as $pid."
1845                         exit 1
1846                 elif kill -s 0 $pid 2>/dev/null; then
1847                         echo "$MACH build of $basews already started" \
1848                             "by $user as $pid."
1849                         exit 1
1850                 else
1851                         # stale lock; clear it out and try again
1852                         rm -f $lockf
1853                 fi
1854         done
1855 }
1856 
1857 #
1858 # Return the list of interesting proto areas, depending on the current
1859 # options.
1860 #
1861 function allprotos {


2421         #
2422         if [ -f $TMPDIR/new_closed ]; then
2423                 return
2424         fi
2425 
2426         if [ -f $TMPDIR/incoming_closed.out ]; then
2427                 printf "\nadded the following changesets to closed repository:\n"
2428                 cat $TMPDIR/incoming_closed.out
2429         fi
2430 }
2431 
2432 type bringover_subversion > /dev/null 2>&1 || function bringover_subversion {
2433         typeset -x PATH=$PATH
2434 
2435         if [[ ! -d $CODEMGR_WS/.svn ]]; then
2436                 staffer svn checkout $BRINGOVER_WS $CODEMGR_WS ||
2437                         touch $TMPDIR/bringover_failed
2438         else
2439                 typeset root
2440                 root=$(staffer svn info $CODEMGR_WS |
2441                         nawk '/^Repository Root:/ {print $NF}')
2442                 if [[ $root != $BRINGOVER_WS ]]; then
2443                         # We fail here because there's no way to update
2444                         # from a named repo.
2445                         cat <<-EOF
2446                         \$BRINGOVER_WS doesn't match repository root:
2447                           \$BRINGOVER_WS:  $BRINGOVER_WS
2448                           Repository root: $root
2449                         EOF
2450                         touch $TMPDIR/bringover_failed
2451                 else
2452                         # If a conflict happens, svn still exits 0.
2453                         staffer svn update $CODEMGR_WS | tee $TMPDIR/pull.out ||
2454                                 touch $TMPDIR/bringover_failed
2455                         if grep "^C" $TMPDIR/pull.out > /dev/null 2>&1; then
2456                                 touch $TMPDIR/bringover_failed
2457                         fi
2458                 fi
2459         fi
2460 }
2461 


2762                         if [ -f "$f" ]; then
2763                                 E2="$E2 -e $f"
2764                         fi
2765                 done
2766 
2767                 if [ -f "$REF_PROTO_LIST" ]; then
2768                         #
2769                         # For builds that copy the IHV proto area (-X), add the
2770                         # IHV proto list to the reference list if the reference
2771                         # was built without -X.
2772                         #
2773                         # For builds that don't copy the IHV proto area, add the
2774                         # IHV proto list to the build's proto list if the
2775                         # reference was built with -X.
2776                         #
2777                         # Use the presence of the first file entry of the cached
2778                         # IHV proto list in the reference list to determine
2779                         # whether it was built with -X or not.
2780                         #
2781                         IHV_REF_PROTO_LIST=$SRC/pkg/proto_list_ihv_$MACH
2782                         grepfor=$(nawk '$1 == "f" { print $2; exit }' \
2783                                 $IHV_REF_PROTO_LIST 2> /dev/null)
2784                         if [ $? = 0 -a -n "$grepfor" ]; then
2785                                 if [ "$X_FLAG" = "y" ]; then
2786                                         grep -w "$grepfor" \
2787                                                 $REF_PROTO_LIST > /dev/null
2788                                         if [ ! "$?" = "0" ]; then
2789                                                 REF_IHV_PROTO="-d $IHV_REF_PROTO_LIST"
2790                                         fi
2791                                 else
2792                                         grep -w "$grepfor" \
2793                                                 $REF_PROTO_LIST > /dev/null
2794                                         if [ "$?" = "0" ]; then
2795                                                 IHV_PROTO_LIST="$IHV_REF_PROTO_LIST"
2796                                         fi
2797                                 fi
2798                         fi
2799                 fi
2800         fi
2801 
2802         if [ "$N_FLAG" != "y" -a -f $SRC/pkgdefs/Makefile ]; then




1821 trap cleanup 0
1822 trap cleanup_signal 1 2 3 15
1823 
1824 #
1825 # Generic lock file processing -- make sure that the lock file doesn't
1826 # exist.  If it does, it should name the build host and PID.  If it
1827 # doesn't, then make sure we can create it.  Clean up locks that are
1828 # known to be stale (assumes host name is unique among build systems
1829 # for the workspace).
1830 #
1831 function create_lock {
1832         lockf=$1
1833         lockvar=$2
1834 
1835         ldir=`dirname $lockf`
1836         [ -d $ldir ] || newdir $ldir || exit 1
1837         eval $lockvar=$lockf
1838 
1839         while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do
1840                 basews=`basename $CODEMGR_WS`
1841                 ls -l $lockf | /usr/xpg4/bin/awk '{print $NF}' | IFS=. read host user pid
1842                 if [ "$host" != "$hostname" ]; then
1843                         echo "$MACH build of $basews apparently" \
1844                             "already started by $user on $host as $pid."
1845                         exit 1
1846                 elif kill -s 0 $pid 2>/dev/null; then
1847                         echo "$MACH build of $basews already started" \
1848                             "by $user as $pid."
1849                         exit 1
1850                 else
1851                         # stale lock; clear it out and try again
1852                         rm -f $lockf
1853                 fi
1854         done
1855 }
1856 
1857 #
1858 # Return the list of interesting proto areas, depending on the current
1859 # options.
1860 #
1861 function allprotos {


2421         #
2422         if [ -f $TMPDIR/new_closed ]; then
2423                 return
2424         fi
2425 
2426         if [ -f $TMPDIR/incoming_closed.out ]; then
2427                 printf "\nadded the following changesets to closed repository:\n"
2428                 cat $TMPDIR/incoming_closed.out
2429         fi
2430 }
2431 
2432 type bringover_subversion > /dev/null 2>&1 || function bringover_subversion {
2433         typeset -x PATH=$PATH
2434 
2435         if [[ ! -d $CODEMGR_WS/.svn ]]; then
2436                 staffer svn checkout $BRINGOVER_WS $CODEMGR_WS ||
2437                         touch $TMPDIR/bringover_failed
2438         else
2439                 typeset root
2440                 root=$(staffer svn info $CODEMGR_WS |
2441                         /usr/xpg4/bin/awk '/^Repository Root:/ {print $NF}')
2442                 if [[ $root != $BRINGOVER_WS ]]; then
2443                         # We fail here because there's no way to update
2444                         # from a named repo.
2445                         cat <<-EOF
2446                         \$BRINGOVER_WS doesn't match repository root:
2447                           \$BRINGOVER_WS:  $BRINGOVER_WS
2448                           Repository root: $root
2449                         EOF
2450                         touch $TMPDIR/bringover_failed
2451                 else
2452                         # If a conflict happens, svn still exits 0.
2453                         staffer svn update $CODEMGR_WS | tee $TMPDIR/pull.out ||
2454                                 touch $TMPDIR/bringover_failed
2455                         if grep "^C" $TMPDIR/pull.out > /dev/null 2>&1; then
2456                                 touch $TMPDIR/bringover_failed
2457                         fi
2458                 fi
2459         fi
2460 }
2461 


2762                         if [ -f "$f" ]; then
2763                                 E2="$E2 -e $f"
2764                         fi
2765                 done
2766 
2767                 if [ -f "$REF_PROTO_LIST" ]; then
2768                         #
2769                         # For builds that copy the IHV proto area (-X), add the
2770                         # IHV proto list to the reference list if the reference
2771                         # was built without -X.
2772                         #
2773                         # For builds that don't copy the IHV proto area, add the
2774                         # IHV proto list to the build's proto list if the
2775                         # reference was built with -X.
2776                         #
2777                         # Use the presence of the first file entry of the cached
2778                         # IHV proto list in the reference list to determine
2779                         # whether it was built with -X or not.
2780                         #
2781                         IHV_REF_PROTO_LIST=$SRC/pkg/proto_list_ihv_$MACH
2782                         grepfor=$(/usr/xpg4/bin/awk '$1 == "f" { print $2; exit }' \
2783                                 $IHV_REF_PROTO_LIST 2> /dev/null)
2784                         if [ $? = 0 -a -n "$grepfor" ]; then
2785                                 if [ "$X_FLAG" = "y" ]; then
2786                                         grep -w "$grepfor" \
2787                                                 $REF_PROTO_LIST > /dev/null
2788                                         if [ ! "$?" = "0" ]; then
2789                                                 REF_IHV_PROTO="-d $IHV_REF_PROTO_LIST"
2790                                         fi
2791                                 else
2792                                         grep -w "$grepfor" \
2793                                                 $REF_PROTO_LIST > /dev/null
2794                                         if [ "$?" = "0" ]; then
2795                                                 IHV_PROTO_LIST="$IHV_REF_PROTO_LIST"
2796                                         fi
2797                                 fi
2798                         fi
2799                 fi
2800         fi
2801 
2802         if [ "$N_FLAG" != "y" -a -f $SRC/pkgdefs/Makefile ]; then