Print this page
    
 4680 nightly and bldenv need to set LC_ALL if they want to fully override the locale
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/tools/scripts/nightly.sh
          +++ new/usr/src/tools/scripts/nightly.sh
   1    1  #!/bin/ksh -p
   2    2  #
   3    3  # CDDL HEADER START
   4    4  #
   5    5  # The contents of this file are subject to the terms of the
   6    6  # Common Development and Distribution License (the "License").
   7    7  # You may not use this file except in compliance with the License.
   8    8  #
   9    9  # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10   10  # or http://www.opensolaris.org/os/licensing.
  11   11  # See the License for the specific language governing permissions
  12   12  # and limitations under the License.
  13   13  #
  14   14  # When distributing Covered Code, include this CDDL HEADER in each
  15   15  # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16   16  # If applicable, add the following below this CDDL HEADER, with the
  17   17  # fields enclosed by brackets "[]" replaced with your own identifying
  18   18  # information: Portions Copyright [yyyy] [name of copyright owner]
  19   19  #
  20   20  # CDDL HEADER END
  21   21  #
  22   22  
  23   23  #
  24   24  # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  25   25  # Copyright 2008, 2010, Richard Lowe
  26   26  # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  27   27  # Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
  28   28  #
  29   29  # Based on the nightly script from the integration folks,
  30   30  # Mostly modified and owned by mike_s.
  31   31  # Changes also by kjc, dmk.
  32   32  #
  33   33  # BRINGOVER_WS may be specified in the env file.
  34   34  # The default is the old behavior of CLONE_WS
  35   35  #
  36   36  # -i on the command line, means fast options, so when it's on the
  37   37  # command line (only), lint and check builds are skipped no matter what
  38   38  # the setting of their individual flags are in NIGHTLY_OPTIONS.
  39   39  #
  40   40  # LINTDIRS can be set in the env file, format is a list of:
  41   41  #
  42   42  #       /dirname-to-run-lint-on flag
  43   43  #
  44   44  #       Where flag is:  y - enable lint noise diff output
  45   45  #                       n - disable lint noise diff output
  46   46  #
  47   47  #       For example: LINTDIRS="$SRC/uts n $SRC/stand y $SRC/psm y"
  48   48  #
  49   49  # OPTHOME  may be set in the environment to override /opt
  50   50  #
  51   51  
  52   52  #
  53   53  # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
  54   54  # under certain circumstances, which can really screw things up; unset it.
  55   55  #
  56   56  unset CDPATH
  57   57  
  58   58  # Get the absolute path of the nightly script that the user invoked.  This
  59   59  # may be a relative path, and we need to do this before changing directory.
  60   60  nightly_path=`whence $0`
  61   61  
  62   62  #
  63   63  # Keep track of where we found nightly so we can invoke the matching
  64   64  # which_scm script.  If that doesn't work, don't go guessing, just rely
  65   65  # on the $PATH settings, which will generally give us either /opt/onbld
  66   66  # or the user's workspace.
  67   67  #
  68   68  WHICH_SCM=$(dirname $nightly_path)/which_scm
  69   69  if [[ ! -x $WHICH_SCM ]]; then
  70   70          WHICH_SCM=which_scm
  71   71  fi
  72   72  
  73   73  function fatal_error
  74   74  {
  75   75          print -u2 "nightly: $*"
  76   76          exit 1
  77   77  }
  78   78  
  79   79  #
  80   80  # Function to do a DEBUG and non-DEBUG build. Needed because we might
  81   81  # need to do another for the source build, and since we only deliver DEBUG or
  82   82  # non-DEBUG packages.
  83   83  #
  84   84  # usage: normal_build
  85   85  #
  86   86  function normal_build {
  87   87  
  88   88          typeset orig_p_FLAG="$p_FLAG"
  89   89          typeset crypto_signer="$CODESIGN_USER"
  90   90  
  91   91          suffix=""
  92   92  
  93   93          # non-DEBUG build begins
  94   94  
  95   95          if [ "$F_FLAG" = "n" ]; then
  96   96                  set_non_debug_build_flags
  97   97                  CODESIGN_USER="$crypto_signer" \
  98   98                      build "non-DEBUG" "$suffix-nd" "-nd" "$MULTI_PROTO"
  99   99          else
 100  100                  echo "\n==== No non-DEBUG $open_only build ====\n" >> "$LOGFILE"
 101  101          fi
 102  102  
 103  103          # non-DEBUG build ends
 104  104  
 105  105          # DEBUG build begins
 106  106  
 107  107          if [ "$D_FLAG" = "y" ]; then
 108  108                  set_debug_build_flags
 109  109                  CODESIGN_USER="$crypto_signer" \
 110  110                      build "DEBUG" "$suffix" "" "$MULTI_PROTO"
 111  111          else
 112  112                  echo "\n==== No DEBUG $open_only build ====\n" >> "$LOGFILE"
 113  113          fi
 114  114  
 115  115          # DEBUG build ends
 116  116  
 117  117          p_FLAG="$orig_p_FLAG"
 118  118  }
 119  119  
 120  120  #
 121  121  # usage: run_hook HOOKNAME ARGS...
 122  122  #
 123  123  # If variable "$HOOKNAME" is defined, insert a section header into 
 124  124  # our logs and then run the command with ARGS
 125  125  #
 126  126  function run_hook {
 127  127          HOOKNAME=$1
 128  128          eval HOOKCMD=\$$HOOKNAME
 129  129          shift
 130  130  
 131  131          if [ -n "$HOOKCMD" ]; then 
 132  132                  (
 133  133                          echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n"
 134  134                          ( $HOOKCMD "$@" 2>&1 )
 135  135                          if [ "$?" -ne 0 ]; then
 136  136                                  # Let exit status propagate up
 137  137                                  touch $TMPDIR/abort
 138  138                          fi
 139  139                  ) | tee -a $mail_msg_file >> $LOGFILE
 140  140  
 141  141                  if [ -f $TMPDIR/abort ]; then
 142  142                          build_ok=n
 143  143                          echo "\nAborting at request of $HOOKNAME" |
 144  144                                  tee -a $mail_msg_file >> $LOGFILE
 145  145                          exit 1
 146  146                  fi
 147  147          fi
 148  148  }
 149  149  
 150  150  # Return library search directive as function of given root.
 151  151  function myldlibs {
 152  152          echo "-L$1/lib -L$1/usr/lib"
 153  153  }
 154  154  
 155  155  # Return header search directive as function of given root.
 156  156  function myheaders {
 157  157          echo "-I$1/usr/include"
 158  158  }
 159  159  
 160  160  #
 161  161  # Function to do the build, including package generation.
 162  162  # usage: build LABEL SUFFIX ND MULTIPROTO
 163  163  # - LABEL is used to tag build output.
 164  164  # - SUFFIX is used to distinguish files (e.g., DEBUG vs non-DEBUG,
 165  165  #   open-only vs full tree).
 166  166  # - ND is "-nd" (non-DEBUG builds) or "" (DEBUG builds).
 167  167  # - If MULTIPROTO is "yes", it means to name the proto area according to
 168  168  #   SUFFIX.  Otherwise ("no"), (re)use the standard proto area.
 169  169  #
 170  170  function build {
 171  171          LABEL=$1
 172  172          SUFFIX=$2
 173  173          ND=$3
 174  174          MULTIPROTO=$4
 175  175          INSTALLOG=install${SUFFIX}-${MACH}
 176  176          NOISE=noise${SUFFIX}-${MACH}
 177  177          PKGARCHIVE=${PKGARCHIVE_ORIG}${SUFFIX}
 178  178  
 179  179          ORIGROOT=$ROOT
 180  180          [ $MULTIPROTO = no ] || export ROOT=$ROOT$SUFFIX
 181  181  
 182  182          export ENVLDLIBS1=`myldlibs $ROOT`
 183  183          export ENVCPPFLAGS1=`myheaders $ROOT`
 184  184  
 185  185          this_build_ok=y
 186  186          #
 187  187          #       Build OS-Networking source
 188  188          #
 189  189          echo "\n==== Building OS-Net source at `date` ($LABEL) ====\n" \
 190  190                  >> $LOGFILE
 191  191  
 192  192          rm -f $SRC/${INSTALLOG}.out
 193  193          cd $SRC
 194  194          /bin/time $MAKE -e install 2>&1 | \
 195  195              tee -a $SRC/${INSTALLOG}.out >> $LOGFILE
 196  196  
 197  197          echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file
 198  198          egrep ":" $SRC/${INSTALLOG}.out |
 199  199                  egrep -e "(^${MAKE}:|[  ]error[:        \n])" | \
 200  200                  egrep -v "Ignoring unknown host" | \
 201  201                  egrep -v "cc .* -o error " | \
 202  202                  egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \
 203  203                  >> $mail_msg_file
 204  204          if [[ -s $TMPDIR/build_errs${SUFFIX} ]]; then
 205  205                  build_ok=n
 206  206                  this_build_ok=n
 207  207          fi
 208  208          grep "bootblock image is .* bytes too big" $SRC/${INSTALLOG}.out \
 209  209                  >> $mail_msg_file
 210  210          if [ "$?" = "0" ]; then
 211  211                  build_ok=n
 212  212                  this_build_ok=n
 213  213          fi
 214  214  
 215  215          echo "\n==== Build warnings ($LABEL) ====\n" >>$mail_msg_file
 216  216          egrep -i warning: $SRC/${INSTALLOG}.out \
 217  217                  | egrep -v '^tic:' \
 218  218                  | egrep -v "symbol (\`|')timezone' has differing types:" \
 219  219                  | egrep -v "parameter <PSTAMP> set to" \
 220  220                  | egrep -v "Ignoring unknown host" \
 221  221                  | egrep -v "redefining segment flags attribute for" \
 222  222                  | tee $TMPDIR/build_warnings${SUFFIX} >> $mail_msg_file
 223  223          if [[ -s $TMPDIR/build_warnings${SUFFIX} ]]; then
 224  224                  build_ok=n
 225  225                  this_build_ok=n
 226  226          fi
 227  227  
 228  228          echo "\n==== Ended OS-Net source build at `date` ($LABEL) ====\n" \
 229  229                  >> $LOGFILE
 230  230  
 231  231          echo "\n==== Elapsed build time ($LABEL) ====\n" >>$mail_msg_file
 232  232          tail -3  $SRC/${INSTALLOG}.out >>$mail_msg_file
 233  233  
 234  234          if [ "$i_FLAG" = "n" ]; then
 235  235                  rm -f $SRC/${NOISE}.ref
 236  236                  if [ -f $SRC/${NOISE}.out ]; then
 237  237                          mv $SRC/${NOISE}.out $SRC/${NOISE}.ref
 238  238                  fi
 239  239                  grep : $SRC/${INSTALLOG}.out \
 240  240                          | egrep -v '^/' \
 241  241                          | egrep -v '^(Start|Finish|real|user|sys|./bld_awk)' \
 242  242                          | egrep -v '^tic:' \
 243  243                          | egrep -v '^mcs' \
 244  244                          | egrep -v '^LD_LIBRARY_PATH=' \
 245  245                          | egrep -v 'ar: creating' \
 246  246                          | egrep -v 'ar: writing' \
 247  247                          | egrep -v 'conflicts:' \
 248  248                          | egrep -v ':saved created' \
 249  249                          | egrep -v '^stty.*c:' \
 250  250                          | egrep -v '^mfgname.c:' \
 251  251                          | egrep -v '^uname-i.c:' \
 252  252                          | egrep -v '^volumes.c:' \
 253  253                          | egrep -v '^lint library construction:' \
 254  254                          | egrep -v 'tsort: INFORM:' \
 255  255                          | egrep -v 'stripalign:' \
 256  256                          | egrep -v 'chars, width' \
 257  257                          | egrep -v "symbol (\`|')timezone' has differing types:" \
 258  258                          | egrep -v 'PSTAMP' \
 259  259                          | egrep -v '|%WHOANDWHERE%|' \
 260  260                          | egrep -v '^Manifying' \
 261  261                          | egrep -v 'Ignoring unknown host' \
 262  262                          | egrep -v 'Processing method:' \
 263  263                          | egrep -v '^Writing' \
 264  264                          | egrep -v 'spellin1:' \
 265  265                          | egrep -v '^adding:' \
 266  266                          | egrep -v "^echo 'msgid" \
 267  267                          | egrep -v '^echo ' \
 268  268                          | egrep -v '\.c:$' \
 269  269                          | egrep -v '^Adding file:' \
 270  270                          | egrep -v 'CLASSPATH=' \
 271  271                          | egrep -v '\/var\/mail\/:saved' \
 272  272                          | egrep -v -- '-DUTS_VERSION=' \
 273  273                          | egrep -v '^Running Mkbootstrap' \
 274  274                          | egrep -v '^Applet length read:' \
 275  275                          | egrep -v 'bytes written:' \
 276  276                          | egrep -v '^File:SolarisAuthApplet.bin' \
 277  277                          | egrep -v -i 'jibversion' \
 278  278                          | egrep -v '^Output size:' \
 279  279                          | egrep -v '^Solo size statistics:' \
 280  280                          | egrep -v '^Using ROM API Version' \
 281  281                          | egrep -v '^Zero Signature length:' \
 282  282                          | egrep -v '^Note \(probably harmless\):' \
 283  283                          | egrep -v '::' \
 284  284                          | egrep -v -- '-xcache' \
 285  285                          | egrep -v '^\+' \
 286  286                          | egrep -v '^cc1: note: -fwritable-strings' \
 287  287                          | egrep -v 'svccfg-native -s svc:/' \
 288  288                          | sort | uniq >$SRC/${NOISE}.out
 289  289                  if [ ! -f $SRC/${NOISE}.ref ]; then
 290  290                          cp $SRC/${NOISE}.out $SRC/${NOISE}.ref
 291  291                  fi
 292  292                  echo "\n==== Build noise differences ($LABEL) ====\n" \
 293  293                          >>$mail_msg_file
 294  294                  diff $SRC/${NOISE}.ref $SRC/${NOISE}.out >>$mail_msg_file
 295  295          fi
 296  296  
 297  297          #
 298  298          #       Re-sign selected binaries using signing server
 299  299          #       (gatekeeper builds only)
 300  300          #
 301  301          if [ -n "$CODESIGN_USER" -a "$this_build_ok" = "y" ]; then
 302  302                  echo "\n==== Signing proto area at `date` ====\n" >> $LOGFILE
 303  303                  signing_file="${TMPDIR}/signing"
 304  304                  rm -f ${signing_file}
 305  305                  export CODESIGN_USER
 306  306                  signproto $SRC/tools/codesign/creds 2>&1 | \
 307  307                          tee -a ${signing_file} >> $LOGFILE
 308  308                  echo "\n==== Finished signing proto area at `date` ====\n" \
 309  309                      >> $LOGFILE
 310  310                  echo "\n==== Crypto module signing errors ($LABEL) ====\n" \
 311  311                      >> $mail_msg_file
 312  312                  egrep 'WARNING|ERROR' ${signing_file} >> $mail_msg_file
 313  313                  if (( $? == 0 )) ; then
 314  314                          build_ok=n
 315  315                          this_build_ok=n
 316  316                  fi
 317  317          fi
 318  318  
 319  319          #
 320  320          #       Building Packages
 321  321          #
 322  322          if [ "$p_FLAG" = "y" -a "$this_build_ok" = "y" ]; then
 323  323                  if [ -d $SRC/pkg ]; then
 324  324                          echo "\n==== Creating $LABEL packages at `date` ====\n" \
 325  325                                  >> $LOGFILE
 326  326                          echo "Clearing out $PKGARCHIVE ..." >> $LOGFILE
 327  327                          rm -rf $PKGARCHIVE >> "$LOGFILE" 2>&1
 328  328                          mkdir -p $PKGARCHIVE >> "$LOGFILE" 2>&1
 329  329  
 330  330                          rm -f $SRC/pkg/${INSTALLOG}.out
 331  331                          cd $SRC/pkg
 332  332                          /bin/time $MAKE -e install 2>&1 | \
 333  333                              tee -a $SRC/pkg/${INSTALLOG}.out >> $LOGFILE
 334  334  
 335  335                          echo "\n==== package build errors ($LABEL) ====\n" \
 336  336                                  >> $mail_msg_file
 337  337  
 338  338                          egrep "${MAKE}|ERROR|WARNING" $SRC/pkg/${INSTALLOG}.out | \
 339  339                                  grep ':' | \
 340  340                                  grep -v PSTAMP | \
 341  341                                  egrep -v "Ignoring unknown host" | \
 342  342                                  tee $TMPDIR/package >> $mail_msg_file
 343  343                          if [[ -s $TMPDIR/package ]]; then
 344  344                                  build_extras_ok=n
 345  345                                  this_build_ok=n
 346  346                          fi
 347  347                  else
 348  348                          #
 349  349                          # Handle it gracefully if -p was set but there so
 350  350                          # no pkg directory.
 351  351                          #
 352  352                          echo "\n==== No $LABEL packages to build ====\n" \
 353  353                                  >> $LOGFILE
 354  354                  fi
 355  355          else
 356  356                  echo "\n==== Not creating $LABEL packages ====\n" >> $LOGFILE
 357  357          fi
 358  358  
 359  359          ROOT=$ORIGROOT
 360  360  }
 361  361  
 362  362  # Usage: dolint /dir y|n
 363  363  # Arg. 2 is a flag to turn on/off the lint diff output
 364  364  function dolint {
 365  365          if [ ! -d "$1" ]; then
 366  366                  echo "dolint error: $1 is not a directory"
 367  367                  exit 1
 368  368          fi
 369  369  
 370  370          if [ "$2" != "y" -a "$2" != "n" ]; then
 371  371                  echo "dolint internal error: $2 should be 'y' or 'n'"
 372  372                  exit 1
 373  373          fi
 374  374  
 375  375          lintdir=$1
 376  376          dodiff=$2
 377  377          base=`basename $lintdir`
 378  378          LINTOUT=$lintdir/lint-${MACH}.out
 379  379          LINTNOISE=$lintdir/lint-noise-${MACH}
 380  380          export ENVLDLIBS1=`myldlibs $ROOT`
 381  381          export ENVCPPFLAGS1=`myheaders $ROOT`
 382  382  
 383  383          set_debug_build_flags
 384  384  
 385  385          #
 386  386          #       '$MAKE lint' in $lintdir
 387  387          #
 388  388          echo "\n==== Begin '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
 389  389  
 390  390          # remove old lint.out
 391  391          rm -f $lintdir/lint.out $lintdir/lint-noise.out
 392  392          if [ -f $lintdir/lint-noise.ref ]; then
 393  393                  mv $lintdir/lint-noise.ref ${LINTNOISE}.ref
 394  394          fi
 395  395  
 396  396          rm -f $LINTOUT
 397  397          cd $lintdir
 398  398          #
 399  399          # Remove all .ln files to ensure a full reference file
 400  400          #
 401  401          rm -f Nothing_to_remove \
 402  402              `find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \) \
 403  403                  -prune -o -type f -name '*.ln' -print `
 404  404  
 405  405          /bin/time $MAKE -ek lint 2>&1 | \
 406  406              tee -a $LINTOUT >> $LOGFILE
 407  407  
 408  408          echo "\n==== '$MAKE lint' of $base ERRORS ====\n" >> $mail_msg_file
 409  409  
 410  410          grep "$MAKE:" $LINTOUT |
 411  411                  egrep -v "Ignoring unknown host" | \
 412  412                  tee $TMPDIR/lint_errs >> $mail_msg_file
 413  413          if [[ -s $TMPDIR/lint_errs ]]; then
 414  414                  build_extras_ok=n
 415  415          fi
 416  416  
 417  417          echo "\n==== Ended '$MAKE lint' of $base at `date` ====\n" >> $LOGFILE
 418  418  
 419  419          echo "\n==== Elapsed time of '$MAKE lint' of $base ====\n" \
 420  420                  >>$mail_msg_file
 421  421          tail -3  $LINTOUT >>$mail_msg_file
 422  422  
 423  423          rm -f ${LINTNOISE}.ref
 424  424          if [ -f ${LINTNOISE}.out ]; then
 425  425                  mv ${LINTNOISE}.out ${LINTNOISE}.ref
 426  426          fi
 427  427          grep : $LINTOUT | \
 428  428                  egrep -v '^(real|user|sys)' |
 429  429                  egrep -v '(library construction)' | \
 430  430                  egrep -v ': global crosschecks' | \
 431  431                  egrep -v 'Ignoring unknown host' | \
 432  432                  egrep -v '\.c:$' | \
 433  433                  sort | uniq > ${LINTNOISE}.out
 434  434          if [ ! -f ${LINTNOISE}.ref ]; then
 435  435                  cp ${LINTNOISE}.out ${LINTNOISE}.ref
 436  436          fi
 437  437  
 438  438          if [ "$dodiff" != "n" ]; then
 439  439                  echo "\n==== lint warnings $base ====\n" \
 440  440                          >>$mail_msg_file
 441  441                  # should be none, though there are a few that were filtered out
 442  442                  # above
 443  443                  egrep -i '(warning|lint):' ${LINTNOISE}.out \
 444  444                          | sort | uniq | tee $TMPDIR/lint_warns >> $mail_msg_file
 445  445                  if [[ -s $TMPDIR/lint_warns ]]; then
 446  446                          build_extras_ok=n
 447  447                  fi
 448  448                  echo "\n==== lint noise differences $base ====\n" \
 449  449                          >> $mail_msg_file
 450  450                  diff ${LINTNOISE}.ref ${LINTNOISE}.out \
 451  451                          >> $mail_msg_file
 452  452          fi
 453  453  }
 454  454  
 455  455  #
 456  456  # Build and install the onbld tools.
 457  457  #
 458  458  # usage: build_tools DESTROOT
 459  459  #
 460  460  # returns non-zero status if the build was successful.
 461  461  #
 462  462  function build_tools {
 463  463          DESTROOT=$1
 464  464  
 465  465          INSTALLOG=install-${MACH}
 466  466  
 467  467          echo "\n==== Building tools at `date` ====\n" \
 468  468                  >> $LOGFILE
 469  469  
 470  470          rm -f ${TOOLS}/${INSTALLOG}.out
 471  471          cd ${TOOLS}
 472  472          /bin/time $MAKE TOOLS_PROTO=${DESTROOT} -e install 2>&1 | \
 473  473              tee -a ${TOOLS}/${INSTALLOG}.out >> $LOGFILE
 474  474  
 475  475          echo "\n==== Tools build errors ====\n" >> $mail_msg_file
 476  476  
 477  477          egrep ":" ${TOOLS}/${INSTALLOG}.out |
 478  478                  egrep -e "(${MAKE}:|[   ]error[:        \n])" | \
 479  479                  egrep -v "Ignoring unknown host" | \
 480  480                  egrep -v warning | tee $TMPDIR/tools_errors >> $mail_msg_file
 481  481  
 482  482          if [[ -s $TMPDIR/tools_errors ]]; then
 483  483                  return 1
 484  484          fi
 485  485          return 0
 486  486  }
 487  487  
 488  488  #
 489  489  # Set up to use locally installed tools.
 490  490  #
 491  491  # usage: use_tools TOOLSROOT
 492  492  #
 493  493  function use_tools {
 494  494          TOOLSROOT=$1
 495  495  
 496  496          #
 497  497          # If we're not building ON workspace, then the TOOLSROOT
 498  498          # settings here are clearly ignored by the workspace
 499  499          # makefiles, prepending nonexistent directories to PATH is
 500  500          # harmless, and we clearly do not wish to override
 501  501          # ONBLD_TOOLS.
 502  502          #
 503  503          # If we're building an ON workspace, then the prepended PATH
 504  504          # elements should supercede the preexisting ONBLD_TOOLS paths,
 505  505          # and we want to override ONBLD_TOOLS to catch the tools that
 506  506          # don't have specific path env vars here.
 507  507          #
 508  508          # So the only conditional behavior is overriding ONBLD_TOOLS,
 509  509          # and we check for "an ON workspace" by looking for
 510  510          # ${TOOLSROOT}/opt/onbld.
 511  511          #
 512  512  
 513  513          STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs
 514  514          export STABS
 515  515          CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs
 516  516          export CTFSTABS
 517  517          GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets
 518  518          export GENOFFSETS
 519  519  
 520  520          CTFCONVERT=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfconvert
 521  521          export CTFCONVERT
 522  522          CTFMERGE=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfmerge
 523  523          export CTFMERGE
 524  524  
 525  525          CTFCVTPTBL=${TOOLSROOT}/opt/onbld/bin/ctfcvtptbl
 526  526          export CTFCVTPTBL
 527  527          CTFFINDMOD=${TOOLSROOT}/opt/onbld/bin/ctffindmod
 528  528          export CTFFINDMOD
 529  529  
 530  530          if [ "$VERIFY_ELFSIGN" = "y" ]; then
 531  531                  ELFSIGN=${TOOLSROOT}/opt/onbld/bin/elfsigncmp
 532  532          else
 533  533                  ELFSIGN=${TOOLSROOT}/opt/onbld/bin/${MACH}/elfsign
 534  534          fi
 535  535          export ELFSIGN
 536  536  
 537  537          PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}"
 538  538          PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}"
 539  539          export PATH
 540  540  
 541  541          if [ -d "${TOOLSROOT}/opt/onbld" ]; then
 542  542                  ONBLD_TOOLS=${TOOLSROOT}/opt/onbld
 543  543                  export ONBLD_TOOLS
 544  544          fi
 545  545  
 546  546          echo "\n==== New environment settings. ====\n" >> $LOGFILE
 547  547          echo "STABS=${STABS}" >> $LOGFILE
 548  548          echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE
 549  549          echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE
 550  550          echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE
 551  551          echo "CTFCVTPTBL=${CTFCVTPTBL}" >> $LOGFILE
 552  552          echo "CTFFINDMOD=${CTFFINDMOD}" >> $LOGFILE
 553  553          echo "ELFSIGN=${ELFSIGN}" >> $LOGFILE
 554  554          echo "PATH=${PATH}" >> $LOGFILE
 555  555          echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE
 556  556  }
 557  557  
 558  558  function staffer {
 559  559          if [ $ISUSER -ne 0 ]; then
 560  560                  "$@"
 561  561          else
 562  562                  arg="\"$1\""
 563  563                  shift
 564  564                  for i
 565  565                  do
 566  566                          arg="$arg \"$i\""
 567  567                  done
 568  568                  eval su $STAFFER -c \'$arg\'
 569  569          fi
 570  570  }
 571  571  
 572  572  #
 573  573  # Verify that the closed bins are present
 574  574  #
 575  575  function check_closed_bins {
 576  576          if [[ ! -d "$ON_CLOSED_BINS" ]]; then
 577  577                  echo "ON_CLOSED_BINS must point to the closed binaries tree."
 578  578                  build_ok=n
 579  579                  exit 1
 580  580          fi
 581  581  }
 582  582  
 583  583  #
 584  584  # wrapper over wsdiff.
 585  585  # usage: do_wsdiff LABEL OLDPROTO NEWPROTO
 586  586  #
 587  587  function do_wsdiff {
 588  588          label=$1
 589  589          oldproto=$2
 590  590          newproto=$3
 591  591  
 592  592          wsdiff="wsdiff"
 593  593          [ "$t_FLAG" = y ] && wsdiff="wsdiff -t"
 594  594  
 595  595          echo "\n==== Getting object changes since last build at `date`" \
 596  596              "($label) ====\n" | tee -a $LOGFILE >> $mail_msg_file
 597  597          $wsdiff -s -r ${TMPDIR}/wsdiff.results $oldproto $newproto 2>&1 | \
 598  598                      tee -a $LOGFILE >> $mail_msg_file
 599  599          echo "\n==== Object changes determined at `date` ($label) ====\n" | \
 600  600              tee -a $LOGFILE >> $mail_msg_file
 601  601  }
 602  602  
 603  603  #
 604  604  # Functions for setting build flags (DEBUG/non-DEBUG).  Keep them
 605  605  # together.
 606  606  #
 607  607  
 608  608  function set_non_debug_build_flags {
 609  609          export RELEASE_BUILD ; RELEASE_BUILD=
 610  610          unset EXTRA_OPTIONS
 611  611          unset EXTRA_CFLAGS
 612  612  }
 613  613  
 614  614  function set_debug_build_flags {
 615  615          unset RELEASE_BUILD
 616  616          unset EXTRA_OPTIONS
 617  617          unset EXTRA_CFLAGS
 618  618  }
 619  619  
 620  620  
 621  621  MACH=`uname -p`
 622  622  
 623  623  if [ "$OPTHOME" = "" ]; then
 624  624          OPTHOME=/opt
 625  625          export OPTHOME
 626  626  fi
 627  627  
 628  628  USAGE='Usage: nightly [-in] [+t] [-V VERS ] <env_file>
 629  629  
 630  630  Where:
 631  631          -i      Fast incremental options (no clobber, lint, check)
 632  632          -n      Do not do a bringover
 633  633          +t      Use the build tools in $ONBLD_TOOLS/bin
 634  634          -V VERS set the build version string to VERS
 635  635  
 636  636          <env_file>  file in Bourne shell syntax that sets and exports
 637  637          variables that configure the operation of this script and many of
 638  638          the scripts this one calls. If <env_file> does not exist,
 639  639          it will be looked for in $OPTHOME/onbld/env.
 640  640  
 641  641  non-DEBUG is the default build type. Build options can be set in the
 642  642  NIGHTLY_OPTIONS variable in the <env_file> as follows:
 643  643  
 644  644          -A      check for ABI differences in .so files
 645  645          -C      check for cstyle/hdrchk errors
 646  646          -D      do a build with DEBUG on
 647  647          -F      do _not_ do a non-DEBUG build
 648  648          -G      gate keeper default group of options (-au)
 649  649          -I      integration engineer default group of options (-ampu)
 650  650          -M      do not run pmodes (safe file permission checker)
 651  651          -N      do not run protocmp
 652  652          -R      default group of options for building a release (-mp)
 653  653          -U      update proto area in the parent
 654  654          -V VERS set the build version string to VERS
 655  655          -f      find unreferenced files
 656  656          -i      do an incremental build (no "make clobber")
 657  657          -l      do "make lint" in $LINTDIRS (default: $SRC y)
 658  658          -m      send mail to $MAILTO at end of build
 659  659          -n      do not do a bringover
 660  660          -p      create packages
 661  661          -r      check ELF runtime attributes in the proto area
 662  662          -t      build and use the tools in $SRC/tools (default setting)
 663  663          +t      Use the build tools in $ONBLD_TOOLS/bin
 664  664          -u      update proto_list_$MACH and friends in the parent workspace;
 665  665                  when used with -f, also build an unrefmaster.out in the parent
 666  666          -w      report on differences between previous and current proto areas
 667  667  '
 668  668  #
 669  669  #       A log file will be generated under the name $LOGFILE
 670  670  #       for partially completed build and log.`date '+%F'`
 671  671  #       in the same directory for fully completed builds.
 672  672  #
 673  673  
 674  674  # default values for low-level FLAGS; G I R are group FLAGS
 675  675  A_FLAG=n
 676  676  C_FLAG=n
 677  677  D_FLAG=n
 678  678  F_FLAG=n
 679  679  f_FLAG=n
 680  680  i_FLAG=n; i_CMD_LINE_FLAG=n
 681  681  l_FLAG=n
 682  682  M_FLAG=n
 683  683  m_FLAG=n
 684  684  N_FLAG=n
 685  685  n_FLAG=n
 686  686  p_FLAG=n
 687  687  r_FLAG=n
 688  688  t_FLAG=y
 689  689  U_FLAG=n
 690  690  u_FLAG=n
 691  691  V_FLAG=n
 692  692  w_FLAG=n
 693  693  W_FLAG=n
 694  694  #
 695  695  build_ok=y
 696  696  build_extras_ok=y
 697  697  
 698  698  #
 699  699  # examine arguments
 700  700  #
 701  701  
 702  702  OPTIND=1
 703  703  while getopts +intV:W FLAG
 704  704  do
 705  705          case $FLAG in
 706  706            i )   i_FLAG=y; i_CMD_LINE_FLAG=y
 707  707                  ;;
 708  708            n )   n_FLAG=y
 709  709                  ;;
 710  710           +t )   t_FLAG=n
 711  711                  ;;
 712  712            V )   V_FLAG=y
 713  713                  V_ARG="$OPTARG"
 714  714                  ;;
 715  715            W )   W_FLAG=y
 716  716                  ;;
 717  717           \? )   echo "$USAGE"
 718  718                  exit 1
 719  719                  ;;
 720  720          esac
 721  721  done
 722  722  
 723  723  # correct argument count after options
 724  724  shift `expr $OPTIND - 1`
 725  725  
 726  726  # test that the path to the environment-setting file was given
 727  727  if [ $# -ne 1 ]; then
 728  728          echo "$USAGE"
 729  729          exit 1
  
    | 
      ↓ open down ↓ | 
    729 lines elided | 
    
      ↑ open up ↑ | 
  
 730  730  fi
 731  731  
 732  732  # check if user is running nightly as root
 733  733  # ISUSER is set non-zero if an ordinary user runs nightly, or is zero
 734  734  # when root invokes nightly.
 735  735  /usr/bin/id | grep '^uid=0(' >/dev/null 2>&1
 736  736  ISUSER=$?;      export ISUSER
 737  737  
 738  738  #
 739  739  # force locale to C
      740 +LANG=C;         export LANG
      741 +LC_ALL=C;       export LC_ALL
 740  742  LC_COLLATE=C;   export LC_COLLATE
 741  743  LC_CTYPE=C;     export LC_CTYPE
 742  744  LC_MESSAGES=C;  export LC_MESSAGES
 743  745  LC_MONETARY=C;  export LC_MONETARY
 744  746  LC_NUMERIC=C;   export LC_NUMERIC
 745  747  LC_TIME=C;      export LC_TIME
 746  748  
 747  749  # clear environment variables we know to be bad for the build
 748  750  unset LD_OPTIONS
 749  751  unset LD_AUDIT          LD_AUDIT_32             LD_AUDIT_64
 750  752  unset LD_BIND_NOW       LD_BIND_NOW_32          LD_BIND_NOW_64
 751  753  unset LD_BREADTH        LD_BREADTH_32           LD_BREADTH_64
 752  754  unset LD_CONFIG         LD_CONFIG_32            LD_CONFIG_64
 753  755  unset LD_DEBUG          LD_DEBUG_32             LD_DEBUG_64
 754  756  unset LD_DEMANGLE       LD_DEMANGLE_32          LD_DEMANGLE_64
 755  757  unset LD_FLAGS          LD_FLAGS_32             LD_FLAGS_64
 756  758  unset LD_LIBRARY_PATH   LD_LIBRARY_PATH_32      LD_LIBRARY_PATH_64
 757  759  unset LD_LOADFLTR       LD_LOADFLTR_32          LD_LOADFLTR_64
 758  760  unset LD_NOAUDIT        LD_NOAUDIT_32           LD_NOAUDIT_64
 759  761  unset LD_NOAUXFLTR      LD_NOAUXFLTR_32         LD_NOAUXFLTR_64
 760  762  unset LD_NOCONFIG       LD_NOCONFIG_32          LD_NOCONFIG_64
 761  763  unset LD_NODIRCONFIG    LD_NODIRCONFIG_32       LD_NODIRCONFIG_64
 762  764  unset LD_NODIRECT       LD_NODIRECT_32          LD_NODIRECT_64
 763  765  unset LD_NOLAZYLOAD     LD_NOLAZYLOAD_32        LD_NOLAZYLOAD_64
 764  766  unset LD_NOOBJALTER     LD_NOOBJALTER_32        LD_NOOBJALTER_64
 765  767  unset LD_NOVERSION      LD_NOVERSION_32         LD_NOVERSION_64
 766  768  unset LD_ORIGIN         LD_ORIGIN_32            LD_ORIGIN_64
 767  769  unset LD_PRELOAD        LD_PRELOAD_32           LD_PRELOAD_64
 768  770  unset LD_PROFILE        LD_PROFILE_32           LD_PROFILE_64
 769  771  
 770  772  unset CONFIG
 771  773  unset GROUP
 772  774  unset OWNER
 773  775  unset REMOTE
 774  776  unset ENV
 775  777  unset ARCH
 776  778  unset CLASSPATH
 777  779  unset NAME
 778  780  
 779  781  #
 780  782  # To get ONBLD_TOOLS from the environment, it must come from the env file.
 781  783  # If it comes interactively, it is generally TOOLS_PROTO, which will be
 782  784  # clobbered before the compiler version checks, which will therefore fail.
 783  785  #
 784  786  unset ONBLD_TOOLS
 785  787  
 786  788  #
 787  789  #       Setup environmental variables
 788  790  #
 789  791  if [ -f /etc/nightly.conf ]; then
 790  792          . /etc/nightly.conf
 791  793  fi    
 792  794  
 793  795  if [ -f $1 ]; then
 794  796          if [[ $1 = */* ]]; then
 795  797                  . $1
 796  798          else
 797  799                  . ./$1
 798  800          fi
 799  801  else
 800  802          if [ -f $OPTHOME/onbld/env/$1 ]; then
 801  803                  . $OPTHOME/onbld/env/$1
 802  804          else
 803  805                  echo "Cannot find env file as either $1 or $OPTHOME/onbld/env/$1"
 804  806                  exit 1
 805  807          fi
 806  808  fi
 807  809  
 808  810  # contents of stdenv.sh inserted after next line:
 809  811  # STDENV_START
 810  812  # STDENV_END
 811  813  
 812  814  # Check if we have sufficient data to continue...
 813  815  [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
 814  816  if  [[ "${NIGHTLY_OPTIONS}" == ~(F)n ]] ; then
 815  817          # Check if the gate data are valid if we don't do a "bringover" below
 816  818          [[ -d "${CODEMGR_WS}" ]] || \
 817  819                  fatal_error "Error: ${CODEMGR_WS} is not a directory."
 818  820          [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || \
 819  821                  fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
 820  822  fi
 821  823  
 822  824  #
 823  825  # place ourselves in a new task, respecting BUILD_PROJECT if set.
 824  826  #
 825  827  if [ -z "$BUILD_PROJECT" ]; then
 826  828          /usr/bin/newtask -c $$
 827  829  else
 828  830          /usr/bin/newtask -c $$ -p $BUILD_PROJECT
 829  831  fi
 830  832  
 831  833  ps -o taskid= -p $$ | read build_taskid
 832  834  ps -o project= -p $$ | read build_project
 833  835  
 834  836  #
 835  837  # See if NIGHTLY_OPTIONS is set
 836  838  #
 837  839  if [ "$NIGHTLY_OPTIONS" = "" ]; then
 838  840          NIGHTLY_OPTIONS="-aBm"
 839  841  fi
 840  842  
 841  843  #
 842  844  # If BRINGOVER_WS was not specified, let it default to CLONE_WS
 843  845  #
 844  846  if [ "$BRINGOVER_WS" = "" ]; then
 845  847          BRINGOVER_WS=$CLONE_WS
 846  848  fi
 847  849  
 848  850  #
 849  851  # If BRINGOVER_FILES was not specified, default to usr
 850  852  #
 851  853  if [ "$BRINGOVER_FILES" = "" ]; then
 852  854          BRINGOVER_FILES="usr"
 853  855  fi
 854  856  
 855  857  check_closed_bins
 856  858  
 857  859  #
 858  860  # Note: changes to the option letters here should also be applied to the
 859  861  #       bldenv script.  `d' is listed for backward compatibility.
 860  862  #
 861  863  NIGHTLY_OPTIONS=-${NIGHTLY_OPTIONS#-}
 862  864  OPTIND=1
 863  865  while getopts +ABCDdFfGIilMmNnpRrtUuwW FLAG $NIGHTLY_OPTIONS
 864  866  do
 865  867          case $FLAG in
 866  868            A )   A_FLAG=y
 867  869                  ;;
 868  870            B )   D_FLAG=y
 869  871                  ;; # old version of D
 870  872            C )   C_FLAG=y
 871  873                  ;;
 872  874            D )   D_FLAG=y
 873  875                  ;;
 874  876            F )   F_FLAG=y
 875  877                  ;;
 876  878            f )   f_FLAG=y
 877  879                  ;;
 878  880            G )   u_FLAG=y
 879  881                  ;;
 880  882            I )   m_FLAG=y
 881  883                  p_FLAG=y
 882  884                  u_FLAG=y
 883  885                  ;;
 884  886            i )   i_FLAG=y
 885  887                  ;;
 886  888            l )   l_FLAG=y
 887  889                  ;;
 888  890            M )   M_FLAG=y
 889  891                  ;;
 890  892            m )   m_FLAG=y
 891  893                  ;;
 892  894            N )   N_FLAG=y
 893  895                  ;;
 894  896            n )   n_FLAG=y
 895  897                  ;;
 896  898            p )   p_FLAG=y
 897  899                  ;;
 898  900            R )   m_FLAG=y
 899  901                  p_FLAG=y
 900  902                  ;;
 901  903            r )   r_FLAG=y
 902  904                  ;;
 903  905           +t )   t_FLAG=n
 904  906                  ;;
 905  907            U )   if [ -z "${PARENT_ROOT}" ]; then
 906  908                          echo "PARENT_ROOT must be set if the U flag is" \
 907  909                              "present in NIGHTLY_OPTIONS."
 908  910                          exit 1
 909  911                  fi
 910  912                  NIGHTLY_PARENT_ROOT=$PARENT_ROOT
 911  913                  if [ -n "${PARENT_TOOLS_ROOT}" ]; then
 912  914                          NIGHTLY_PARENT_TOOLS_ROOT=$PARENT_TOOLS_ROOT
 913  915                  fi
 914  916                  U_FLAG=y
 915  917                  ;;
 916  918            u )   u_FLAG=y
 917  919                  ;;
 918  920            w )   w_FLAG=y
 919  921                  ;;
 920  922            W )   W_FLAG=y
 921  923                  ;;
 922  924           \? )   echo "$USAGE"
 923  925                  exit 1
 924  926                  ;;
 925  927          esac
 926  928  done
 927  929  
 928  930  if [ $ISUSER -ne 0 ]; then
 929  931          # Set default value for STAFFER, if needed.
 930  932          if [ -z "$STAFFER" -o "$STAFFER" = "nobody" ]; then
 931  933                  STAFFER=`/usr/xpg4/bin/id -un`
 932  934                  export STAFFER
 933  935          fi
 934  936  fi
 935  937  
 936  938  if [ -z "$MAILTO" -o "$MAILTO" = "nobody" ]; then
 937  939          MAILTO=$STAFFER
 938  940          export MAILTO
 939  941  fi
 940  942  
 941  943  PATH="$OPTHOME/onbld/bin:$OPTHOME/onbld/bin/${MACH}:/usr/ccs/bin"
 942  944  PATH="$PATH:$OPTHOME/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ucb"
 943  945  PATH="$PATH:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
 944  946  export PATH
 945  947  
 946  948  # roots of source trees, both relative to $SRC and absolute.
 947  949  relsrcdirs="."
 948  950  abssrcdirs="$SRC"
 949  951  
 950  952  PROTOCMPTERSE="protocmp.terse -gu"
 951  953  POUND_SIGN="#"
 952  954  # have we set RELEASE_DATE in our env file?
 953  955  if [ -z "$RELEASE_DATE" ]; then
 954  956          RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
 955  957  fi
 956  958  BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
 957  959  BASEWSDIR=$(basename $CODEMGR_WS)
 958  960  DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
 959  961  
 960  962  # we export POUND_SIGN, RELEASE_DATE and DEV_CM to speed up the build process
 961  963  # by avoiding repeated shell invocations to evaluate Makefile.master
 962  964  # definitions.
 963  965  export POUND_SIGN RELEASE_DATE DEV_CM
 964  966  
 965  967  maketype="distributed"
 966  968  if [[ -z "$MAKE" ]]; then
 967  969          MAKE=dmake
 968  970  elif [[ ! -x "$MAKE" ]]; then
 969  971          echo "\$MAKE is set to garbage in the environment"
 970  972          exit 1  
 971  973  fi
 972  974  # get the dmake version string alone
 973  975  DMAKE_VERSION=$( $MAKE -v )
 974  976  DMAKE_VERSION=${DMAKE_VERSION#*: }
 975  977  # focus in on just the dotted version number alone
 976  978  DMAKE_MAJOR=$( echo $DMAKE_VERSION | \
 977  979          sed -e 's/.*\<\([^.]*\.[^   ]*\).*$/\1/' )
 978  980  # extract the second (or final) integer
 979  981  DMAKE_MINOR=${DMAKE_MAJOR#*.}
 980  982  DMAKE_MINOR=${DMAKE_MINOR%%.*}
 981  983  # extract the first integer
 982  984  DMAKE_MAJOR=${DMAKE_MAJOR%%.*}
 983  985  CHECK_DMAKE=${CHECK_DMAKE:-y}
 984  986  # x86 was built on the 12th, sparc on the 13th.
 985  987  if [ "$CHECK_DMAKE" = "y" -a \
 986  988       "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/12" -a \
 987  989       "$DMAKE_VERSION" != "Sun Distributed Make 7.3 2003/03/13" -a \( \
 988  990       "$DMAKE_MAJOR" -lt 7 -o \
 989  991       "$DMAKE_MAJOR" -eq 7 -a "$DMAKE_MINOR" -lt 4 \) ]; then
 990  992          if [ -z "$DMAKE_VERSION" ]; then
 991  993                  echo "$MAKE is missing."
 992  994                  exit 1
 993  995          fi
 994  996          echo `whence $MAKE`" version is:"
 995  997          echo "  ${DMAKE_VERSION}"
 996  998          cat <<EOF
 997  999  
 998 1000  This version may not be safe for use, if you really want to use this version
 999 1001  anyway add the following to your environment to disable this check:
1000 1002  
1001 1003    CHECK_DMAKE=n
1002 1004  EOF
1003 1005          exit 1
1004 1006  fi
1005 1007  export PATH
1006 1008  export MAKE
1007 1009  
1008 1010  if [ "${SUNWSPRO}" != "" ]; then
1009 1011          PATH="${SUNWSPRO}/bin:$PATH"
1010 1012          export PATH
1011 1013  fi
1012 1014  
1013 1015  hostname=$(uname -n)
1014 1016  if [[ $DMAKE_MAX_JOBS != +([0-9]) || $DMAKE_MAX_JOBS -eq 0 ]]
1015 1017  then
1016 1018          maxjobs=
1017 1019          if [[ -f $HOME/.make.machines ]]
1018 1020          then
1019 1021                  # Note: there is a hard tab and space character in the []s
1020 1022                  # below.
1021 1023                  egrep -i "^[    ]*$hostname[    \.]" \
1022 1024                          $HOME/.make.machines | read host jobs
1023 1025                  maxjobs=${jobs##*=}
1024 1026          fi
1025 1027  
1026 1028          if [[ $maxjobs != +([0-9]) || $maxjobs -eq 0 ]]
1027 1029          then
1028 1030                  # default
1029 1031                  maxjobs=4
1030 1032          fi
1031 1033  
1032 1034          export DMAKE_MAX_JOBS=$maxjobs
1033 1035  fi
1034 1036  
1035 1037  DMAKE_MODE=parallel;
1036 1038  export DMAKE_MODE
1037 1039  
1038 1040  if [ -z "${ROOT}" ]; then
1039 1041          echo "ROOT must be set."
1040 1042          exit 1
1041 1043  fi
1042 1044  
1043 1045  #
1044 1046  # if -V flag was given, reset VERSION to V_ARG
1045 1047  #
1046 1048  if [ "$V_FLAG" = "y" ]; then
1047 1049          VERSION=$V_ARG
1048 1050  fi
1049 1051  
1050 1052  TMPDIR="/tmp/nightly.tmpdir.$$"
1051 1053  export TMPDIR
1052 1054  rm -rf ${TMPDIR}
1053 1055  mkdir -p $TMPDIR || exit 1
1054 1056  chmod 777 $TMPDIR
1055 1057  
1056 1058  #
1057 1059  # Keep elfsign's use of pkcs11_softtoken from looking in the user home
1058 1060  # directory, which doesn't always work.   Needed until all build machines
1059 1061  # have the fix for 6271754
1060 1062  #
1061 1063  SOFTTOKEN_DIR=$TMPDIR
1062 1064  export SOFTTOKEN_DIR
1063 1065  
1064 1066  #
1065 1067  # Tools should only be built non-DEBUG.  Keep track of the tools proto
1066 1068  # area path relative to $TOOLS, because the latter changes in an
1067 1069  # export build.
1068 1070  #
1069 1071  # TOOLS_PROTO is included below for builds other than usr/src/tools
1070 1072  # that look for this location.  For usr/src/tools, this will be
1071 1073  # overridden on the $MAKE command line in build_tools().
1072 1074  #
1073 1075  TOOLS=${SRC}/tools
1074 1076  TOOLS_PROTO_REL=proto/root_${MACH}-nd
1075 1077  TOOLS_PROTO=${TOOLS}/${TOOLS_PROTO_REL};        export TOOLS_PROTO
1076 1078  
1077 1079  unset   CFLAGS LD_LIBRARY_PATH LDFLAGS
1078 1080  
1079 1081  # create directories that are automatically removed if the nightly script
1080 1082  # fails to start correctly
1081 1083  function newdir {
1082 1084          dir=$1
1083 1085          toadd=
1084 1086          while [ ! -d $dir ]; do
1085 1087                  toadd="$dir $toadd"
1086 1088                  dir=`dirname $dir`
1087 1089          done
1088 1090          torm=
1089 1091          newlist=
1090 1092          for dir in $toadd; do
1091 1093                  if staffer mkdir $dir; then
1092 1094                          newlist="$ISUSER $dir $newlist"
1093 1095                          torm="$dir $torm"
1094 1096                  else
1095 1097                          [ -z "$torm" ] || staffer rmdir $torm
1096 1098                          return 1
1097 1099                  fi
1098 1100          done
1099 1101          newdirlist="$newlist $newdirlist"
1100 1102          return 0
1101 1103  }
1102 1104  newdirlist=
1103 1105  
1104 1106  [ -d $CODEMGR_WS ] || newdir $CODEMGR_WS || exit 1
1105 1107  
1106 1108  # since this script assumes the build is from full source, it nullifies
1107 1109  # variables likely to have been set by a "ws" script; nullification
1108 1110  # confines the search space for headers and libraries to the proto area
1109 1111  # built from this immediate source.
1110 1112  ENVLDLIBS1=
1111 1113  ENVLDLIBS2=
1112 1114  ENVLDLIBS3=
1113 1115  ENVCPPFLAGS1=
1114 1116  ENVCPPFLAGS2=
1115 1117  ENVCPPFLAGS3=
1116 1118  ENVCPPFLAGS4=
1117 1119  PARENT_ROOT=
1118 1120  
1119 1121  export ENVLDLIBS3 ENVCPPFLAGS1 ENVCPPFLAGS2 ENVCPPFLAGS3 ENVCPPFLAGS4 \
1120 1122          ENVLDLIBS1 ENVLDLIBS2 PARENT_ROOT
1121 1123  
1122 1124  PKGARCHIVE_ORIG=$PKGARCHIVE
1123 1125  
1124 1126  #
1125 1127  # Juggle the logs and optionally send mail on completion.
1126 1128  #
1127 1129  
1128 1130  function logshuffle {
1129 1131          LLOG="$ATLOG/log.`date '+%F.%H:%M'`"
1130 1132          if [ -f $LLOG -o -d $LLOG ]; then
1131 1133                  LLOG=$LLOG.$$
1132 1134          fi
1133 1135          mkdir $LLOG
1134 1136          export LLOG
1135 1137  
1136 1138          if [ "$build_ok" = "y" ]; then
1137 1139                  mv $ATLOG/proto_list_${MACH} $LLOG
1138 1140  
1139 1141                  if [ -f $ATLOG/proto_list_tools_${MACH} ]; then
1140 1142                          mv $ATLOG/proto_list_tools_${MACH} $LLOG
1141 1143                  fi
1142 1144  
1143 1145                  if [ -f $TMPDIR/wsdiff.results ]; then
1144 1146                          mv $TMPDIR/wsdiff.results $LLOG
1145 1147                  fi
1146 1148  
1147 1149                  if [ -f $TMPDIR/wsdiff-nd.results ]; then
1148 1150                          mv $TMPDIR/wsdiff-nd.results $LLOG
1149 1151                  fi
1150 1152          fi
1151 1153  
1152 1154          #
1153 1155          # Now that we're about to send mail, it's time to check the noise
1154 1156          # file.  In the event that an error occurs beyond this point, it will
1155 1157          # be recorded in the nightly.log file, but nowhere else.  This would
1156 1158          # include only errors that cause the copying of the noise log to fail
1157 1159          # or the mail itself not to be sent.
1158 1160          #
1159 1161  
1160 1162          exec >>$LOGFILE 2>&1
1161 1163          if [ -s $build_noise_file ]; then
1162 1164                  echo "\n==== Nightly build noise ====\n" |
1163 1165                      tee -a $LOGFILE >>$mail_msg_file
1164 1166                  cat $build_noise_file >>$LOGFILE
1165 1167                  cat $build_noise_file >>$mail_msg_file
1166 1168                  echo | tee -a $LOGFILE >>$mail_msg_file
1167 1169          fi
1168 1170          rm -f $build_noise_file
1169 1171  
1170 1172          case "$build_ok" in
1171 1173                  y)
1172 1174                          state=Completed
1173 1175                          ;;
1174 1176                  i)
1175 1177                          state=Interrupted
1176 1178                          ;;
1177 1179                  *)
1178 1180                          state=Failed
1179 1181                          ;;
1180 1182          esac
1181 1183  
1182 1184          if [[ $state != "Interrupted" && $build_extras_ok != "y" ]]; then
1183 1185                  state=Failed
1184 1186          fi
1185 1187  
1186 1188          NIGHTLY_STATUS=$state
1187 1189          export NIGHTLY_STATUS
1188 1190  
1189 1191          run_hook POST_NIGHTLY $state
1190 1192          run_hook SYS_POST_NIGHTLY $state
1191 1193  
1192 1194          #
1193 1195          # mailx(1) sets From: based on the -r flag
1194 1196          # if it is given.
1195 1197          #
1196 1198          mailx_r=
1197 1199          if [[ -n "${MAILFROM}" ]]; then
1198 1200                  mailx_r="-r ${MAILFROM}"
1199 1201          fi
1200 1202  
1201 1203          cat $build_time_file $build_environ_file $mail_msg_file \
1202 1204              > ${LLOG}/mail_msg
1203 1205          if [ "$m_FLAG" = "y" ]; then
1204 1206                  cat ${LLOG}/mail_msg | /usr/bin/mailx ${mailx_r} -s \
1205 1207          "Nightly ${MACH} Build of `basename ${CODEMGR_WS}` ${state}." \
1206 1208                          ${MAILTO}
1207 1209          fi
1208 1210  
1209 1211          if [ "$u_FLAG" = "y" -a "$build_ok" = "y" ]; then
1210 1212                  staffer cp ${LLOG}/mail_msg $PARENT_WS/usr/src/mail_msg-${MACH}
1211 1213                  staffer cp $LOGFILE $PARENT_WS/usr/src/nightly-${MACH}.log
1212 1214          fi
1213 1215  
1214 1216          mv $LOGFILE $LLOG
1215 1217  }
1216 1218  
1217 1219  #
1218 1220  #       Remove the locks and temporary files on any exit
1219 1221  #
1220 1222  function cleanup {
1221 1223          logshuffle
1222 1224  
1223 1225          [ -z "$lockfile" ] || staffer rm -f $lockfile
1224 1226          [ -z "$atloglockfile" ] || rm -f $atloglockfile
1225 1227          [ -z "$ulockfile" ] || staffer rm -f $ulockfile
1226 1228          [ -z "$Ulockfile" ] || rm -f $Ulockfile
1227 1229  
1228 1230          set -- $newdirlist
1229 1231          while [ $# -gt 0 ]; do
1230 1232                  ISUSER=$1 staffer rmdir $2
1231 1233                  shift; shift
1232 1234          done
1233 1235          rm -rf $TMPDIR
1234 1236  }
1235 1237  
1236 1238  function cleanup_signal {
1237 1239          build_ok=i
1238 1240          # this will trigger cleanup(), above.
1239 1241          exit 1
1240 1242  }
1241 1243  
1242 1244  trap cleanup 0
1243 1245  trap cleanup_signal 1 2 3 15
1244 1246  
1245 1247  #
1246 1248  # Generic lock file processing -- make sure that the lock file doesn't
1247 1249  # exist.  If it does, it should name the build host and PID.  If it
1248 1250  # doesn't, then make sure we can create it.  Clean up locks that are
1249 1251  # known to be stale (assumes host name is unique among build systems
1250 1252  # for the workspace).
1251 1253  #
1252 1254  function create_lock {
1253 1255          lockf=$1
1254 1256          lockvar=$2
1255 1257  
1256 1258          ldir=`dirname $lockf`
1257 1259          [ -d $ldir ] || newdir $ldir || exit 1
1258 1260          eval $lockvar=$lockf
1259 1261  
1260 1262          while ! staffer ln -s $hostname.$STAFFER.$$ $lockf 2> /dev/null; do
1261 1263                  basews=`basename $CODEMGR_WS`
1262 1264                  ls -l $lockf | nawk '{print $NF}' | IFS=. read host user pid
1263 1265                  if [ "$host" != "$hostname" ]; then
1264 1266                          echo "$MACH build of $basews apparently" \
1265 1267                              "already started by $user on $host as $pid."
1266 1268                          exit 1
1267 1269                  elif kill -s 0 $pid 2>/dev/null; then
1268 1270                          echo "$MACH build of $basews already started" \
1269 1271                              "by $user as $pid."
1270 1272                          exit 1
1271 1273                  else
1272 1274                          # stale lock; clear it out and try again
1273 1275                          rm -f $lockf
1274 1276                  fi
1275 1277          done
1276 1278  }
1277 1279  
1278 1280  #
1279 1281  # Return the list of interesting proto areas, depending on the current
1280 1282  # options.
1281 1283  #
1282 1284  function allprotos {
1283 1285          typeset roots="$ROOT"
1284 1286  
1285 1287          if [[ "$F_FLAG" = n && "$MULTI_PROTO" = yes ]]; then
1286 1288                  roots="$roots $ROOT-nd"
1287 1289          fi
1288 1290  
1289 1291          echo $roots
1290 1292  }
1291 1293  
1292 1294  # Ensure no other instance of this script is running on this host.
1293 1295  # LOCKNAME can be set in <env_file>, and is by default, but is not
1294 1296  # required due to the use of $ATLOG below.
1295 1297  if [ -n "$LOCKNAME" ]; then
1296 1298          create_lock /tmp/$LOCKNAME "lockfile"
1297 1299  fi
1298 1300  #
1299 1301  # Create from one, two, or three other locks:
1300 1302  #       $ATLOG/nightly.lock
1301 1303  #               - protects against multiple builds in same workspace
1302 1304  #       $PARENT_WS/usr/src/nightly.$MACH.lock
1303 1305  #               - protects against multiple 'u' copy-backs
1304 1306  #       $NIGHTLY_PARENT_ROOT/nightly.lock
1305 1307  #               - protects against multiple 'U' copy-backs
1306 1308  #
1307 1309  # Overriding ISUSER to 1 causes the lock to be created as root if the
1308 1310  # script is run as root.  The default is to create it as $STAFFER.
1309 1311  ISUSER=1 create_lock $ATLOG/nightly.lock "atloglockfile"
1310 1312  if [ "$u_FLAG" = "y" ]; then
1311 1313          create_lock $PARENT_WS/usr/src/nightly.$MACH.lock "ulockfile"
1312 1314  fi
1313 1315  if [ "$U_FLAG" = "y" ]; then
1314 1316          # NIGHTLY_PARENT_ROOT is written as root if script invoked as root.
1315 1317          ISUSER=1 create_lock $NIGHTLY_PARENT_ROOT/nightly.lock "Ulockfile"
1316 1318  fi
1317 1319  
1318 1320  # Locks have been taken, so we're doing a build and we're committed to
1319 1321  # the directories we may have created so far.
1320 1322  newdirlist=
1321 1323  
1322 1324  #
1323 1325  # Create mail_msg_file
1324 1326  #
1325 1327  mail_msg_file="${TMPDIR}/mail_msg"
1326 1328  touch $mail_msg_file
1327 1329  build_time_file="${TMPDIR}/build_time"
1328 1330  build_environ_file="${TMPDIR}/build_environ"
1329 1331  touch $build_environ_file
1330 1332  #
1331 1333  #       Move old LOGFILE aside
1332 1334  #       ATLOG directory already made by 'create_lock' above
1333 1335  #
1334 1336  if [ -f $LOGFILE ]; then
1335 1337          mv -f $LOGFILE ${LOGFILE}-
1336 1338  fi
1337 1339  #
1338 1340  #       Build OsNet source
1339 1341  #
1340 1342  START_DATE=`date`
1341 1343  SECONDS=0
1342 1344  echo "\n==== Nightly $maketype build started:   $START_DATE ====" \
1343 1345      | tee -a $LOGFILE > $build_time_file
1344 1346  
1345 1347  echo "\nBuild project:  $build_project\nBuild taskid:   $build_taskid" | \
1346 1348      tee -a $mail_msg_file >> $LOGFILE
1347 1349  
1348 1350  # make sure we log only to the nightly build file
1349 1351  build_noise_file="${TMPDIR}/build_noise"
1350 1352  exec </dev/null >$build_noise_file 2>&1
1351 1353  
1352 1354  run_hook SYS_PRE_NIGHTLY
1353 1355  run_hook PRE_NIGHTLY
1354 1356  
1355 1357  echo "\n==== list of environment variables ====\n" >> $LOGFILE
1356 1358  env >> $LOGFILE
1357 1359  
1358 1360  echo "\n==== Nightly argument issues ====\n" | tee -a $mail_msg_file >> $LOGFILE
1359 1361  
1360 1362  if [ "$N_FLAG" = "y" ]; then
1361 1363          if [ "$p_FLAG" = "y" ]; then
1362 1364                  cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1363 1365  WARNING: the p option (create packages) is set, but so is the N option (do
1364 1366           not run protocmp); this is dangerous; you should unset the N option
1365 1367  EOF
1366 1368          else
1367 1369                  cat <<EOF | tee -a $mail_msg_file >> $LOGFILE
1368 1370  Warning: the N option (do not run protocmp) is set; it probably shouldn't be
1369 1371  EOF
1370 1372          fi
1371 1373          echo "" | tee -a $mail_msg_file >> $LOGFILE
1372 1374  fi
1373 1375  
1374 1376  if [ "$D_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
1375 1377          #
1376 1378          # In the past we just complained but went ahead with the lint
1377 1379          # pass, even though the proto area was built non-DEBUG.  It's
1378 1380          # unlikely that non-DEBUG headers will make a difference, but
1379 1381          # rather than assuming it's a safe combination, force the user
1380 1382          # to specify a DEBUG build.
1381 1383          #
1382 1384          echo "WARNING: DEBUG build not requested; disabling lint.\n" \
1383 1385              | tee -a $mail_msg_file >> $LOGFILE
1384 1386          l_FLAG=n
1385 1387  fi
1386 1388  
1387 1389  if [ "$f_FLAG" = "y" ]; then
1388 1390          if [ "$i_FLAG" = "y" ]; then
1389 1391                  echo "WARNING: the -f flag cannot be used during incremental" \
1390 1392                      "builds; ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1391 1393                  f_FLAG=n
1392 1394          fi
1393 1395          if [ "${l_FLAG}${p_FLAG}" != "yy" ]; then
1394 1396                  echo "WARNING: the -f flag requires -l, and -p;" \
1395 1397                      "ignoring -f\n" | tee -a $mail_msg_file >> $LOGFILE
1396 1398                  f_FLAG=n
1397 1399          fi
1398 1400  fi
1399 1401  
1400 1402  if [ "$w_FLAG" = "y" -a ! -d $ROOT ]; then
1401 1403          echo "WARNING: -w specified, but $ROOT does not exist;" \
1402 1404              "ignoring -w\n" | tee -a $mail_msg_file >> $LOGFILE
1403 1405          w_FLAG=n
1404 1406  fi
1405 1407  
1406 1408  if [ "$t_FLAG" = "n" ]; then
1407 1409          #
1408 1410          # We're not doing a tools build, so make sure elfsign(1) is
1409 1411          # new enough to safely sign non-crypto binaries.  We test
1410 1412          # debugging output from elfsign to detect the old version.
1411 1413          #
1412 1414          newelfsigntest=`SUNW_CRYPTO_DEBUG=stderr /usr/bin/elfsign verify \
1413 1415              -e /usr/lib/security/pkcs11_softtoken.so.1 2>&1 \
1414 1416              | egrep algorithmOID`
1415 1417          if [ -z "$newelfsigntest" ]; then
1416 1418                  echo "WARNING: /usr/bin/elfsign out of date;" \
1417 1419                      "will only sign crypto modules\n" | \
1418 1420                      tee -a $mail_msg_file >> $LOGFILE
1419 1421                  export ELFSIGN_OBJECT=true
1420 1422          elif [ "$VERIFY_ELFSIGN" = "y" ]; then
1421 1423                  echo "WARNING: VERIFY_ELFSIGN=y requires" \
1422 1424                      "the -t flag; ignoring VERIFY_ELFSIGN\n" | \
1423 1425                      tee -a $mail_msg_file >> $LOGFILE
1424 1426          fi
1425 1427  fi
1426 1428  
1427 1429  case $MULTI_PROTO in
1428 1430  yes|no) ;;
1429 1431  *)
1430 1432          echo "WARNING: MULTI_PROTO is \"$MULTI_PROTO\"; " \
1431 1433              "should be \"yes\" or \"no\"." | tee -a $mail_msg_file >> $LOGFILE
1432 1434          echo "Setting MULTI_PROTO to \"no\".\n" | \
1433 1435              tee -a $mail_msg_file >> $LOGFILE
1434 1436          export MULTI_PROTO=no
1435 1437          ;;
1436 1438  esac
1437 1439  
1438 1440  echo "\n==== Build version ====\n" | tee -a $mail_msg_file >> $LOGFILE
1439 1441  echo $VERSION | tee -a $mail_msg_file >> $LOGFILE
1440 1442  
1441 1443  # Save the current proto area if we're comparing against the last build
1442 1444  if [ "$w_FLAG" = "y" -a -d "$ROOT" ]; then
1443 1445      if [ -d "$ROOT.prev" ]; then
1444 1446          rm -rf $ROOT.prev
1445 1447      fi
1446 1448      mv $ROOT $ROOT.prev
1447 1449  fi
1448 1450  
1449 1451  # Same for non-DEBUG proto area
1450 1452  if [ "$w_FLAG" = "y" -a "$MULTI_PROTO" = yes -a -d "$ROOT-nd" ]; then
1451 1453          if [ -d "$ROOT-nd.prev" ]; then
1452 1454                  rm -rf $ROOT-nd.prev
1453 1455          fi
1454 1456          mv $ROOT-nd $ROOT-nd.prev
1455 1457  fi
1456 1458  
1457 1459  #
1458 1460  # Echo the SCM type of the parent workspace, this can't just be which_scm
1459 1461  # as that does not know how to identify various network repositories.
1460 1462  #
1461 1463  function parent_wstype {
1462 1464          typeset scm_type junk
1463 1465  
1464 1466          CODEMGR_WS="$BRINGOVER_WS" "$WHICH_SCM" 2>/dev/null \
1465 1467              | read scm_type junk
1466 1468          if [[ -z "$scm_type" || "$scm_type" == unknown ]]; then
1467 1469                  # Probe BRINGOVER_WS to determine its type
1468 1470                  if [[ $BRINGOVER_WS == ssh://* ]]; then
1469 1471                          scm_type="mercurial"
1470 1472                  elif [[ $BRINGOVER_WS == http://* ]] && \
1471 1473                      wget -q -O- --save-headers "$BRINGOVER_WS/?cmd=heads" | \
1472 1474                      egrep -s "application/mercurial" 2> /dev/null; then
1473 1475                          scm_type="mercurial"
1474 1476                  else
1475 1477                          scm_type="none"
1476 1478                  fi
1477 1479          fi    
1478 1480  
1479 1481          # fold both unsupported and unrecognized results into "none"
1480 1482          case "$scm_type" in
1481 1483          mercurial)
1482 1484                  ;;
1483 1485          *)      scm_type=none
1484 1486                  ;;
1485 1487          esac
1486 1488  
1487 1489          echo $scm_type
1488 1490  }
1489 1491  
1490 1492  # Echo the SCM types of $CODEMGR_WS and $BRINGOVER_WS
1491 1493  function child_wstype {
1492 1494          typeset scm_type junk
1493 1495  
1494 1496          # Probe CODEMGR_WS to determine its type
1495 1497          if [[ -d $CODEMGR_WS ]]; then
1496 1498                  $WHICH_SCM | read scm_type junk || exit 1
1497 1499          fi
1498 1500  
1499 1501          case "$scm_type" in
1500 1502          none|git|mercurial)
1501 1503                  ;;
1502 1504          *)      scm_type=none
1503 1505                  ;;
1504 1506          esac
1505 1507  
1506 1508          echo $scm_type
1507 1509  }
1508 1510  
1509 1511  SCM_TYPE=$(child_wstype)
1510 1512  
1511 1513  #
1512 1514  #       Decide whether to clobber
1513 1515  #
1514 1516  if [ "$i_FLAG" = "n" -a -d "$SRC" ]; then
1515 1517          echo "\n==== Make clobber at `date` ====\n" >> $LOGFILE
1516 1518  
1517 1519          cd $SRC
1518 1520          # remove old clobber file
1519 1521          rm -f $SRC/clobber.out
1520 1522          rm -f $SRC/clobber-${MACH}.out
1521 1523  
1522 1524          # Remove all .make.state* files, just in case we are restarting
1523 1525          # the build after having interrupted a previous 'make clobber'.
1524 1526          find . \( -name SCCS -o -name .hg -o -name .svn -o -name .git \
1525 1527                  -o -name 'interfaces.*' \) -prune \
1526 1528                  -o -name '.make.*' -print | xargs rm -f
1527 1529  
1528 1530          $MAKE -ek clobber 2>&1 | tee -a $SRC/clobber-${MACH}.out >> $LOGFILE
1529 1531          echo "\n==== Make clobber ERRORS ====\n" >> $mail_msg_file
1530 1532          grep "$MAKE:" $SRC/clobber-${MACH}.out |
1531 1533                  egrep -v "Ignoring unknown host" | \
1532 1534                  tee $TMPDIR/clobber_errs >> $mail_msg_file
1533 1535  
1534 1536          if [[ -s $TMPDIR/clobber_errs ]]; then
1535 1537                  build_extras_ok=n
1536 1538          fi
1537 1539  
1538 1540          if [[ "$t_FLAG" = "y" ]]; then
1539 1541                  echo "\n==== Make tools clobber at `date` ====\n" >> $LOGFILE
1540 1542                  cd ${TOOLS}
1541 1543                  rm -f ${TOOLS}/clobber-${MACH}.out
1542 1544                  $MAKE TOOLS_PROTO=$TOOLS_PROTO -ek clobber 2>&1 | \
1543 1545                          tee -a ${TOOLS}/clobber-${MACH}.out >> $LOGFILE
1544 1546                  echo "\n==== Make tools clobber ERRORS ====\n" \
1545 1547                          >> $mail_msg_file
1546 1548                  grep "$MAKE:" ${TOOLS}/clobber-${MACH}.out \
1547 1549                          >> $mail_msg_file
1548 1550                  if (( $? == 0 )); then
1549 1551                          build_extras_ok=n
1550 1552                  fi
1551 1553                  rm -rf ${TOOLS_PROTO}
1552 1554                  mkdir -p ${TOOLS_PROTO}
1553 1555          fi
1554 1556  
1555 1557          typeset roots=$(allprotos)
1556 1558          echo "\n\nClearing $roots" >> "$LOGFILE"
1557 1559          rm -rf $roots
1558 1560  
1559 1561          # Get back to a clean workspace as much as possible to catch
1560 1562          # problems that only occur on fresh workspaces.
1561 1563          # Remove all .make.state* files, libraries, and .o's that may
1562 1564          # have been omitted from clobber.  A couple of libraries are
1563 1565          # under source code control, so leave them alone.
1564 1566          # We should probably blow away temporary directories too.
1565 1567          cd $SRC
1566 1568          find $relsrcdirs \( -name SCCS -o -name .hg -o -name .svn \
1567 1569              -o -name .git -o -name 'interfaces.*' \) -prune -o \
1568 1570              \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
1569 1571                 -name '*.o' \) -print | \
1570 1572              grep -v 'tools/ctf/dwarf/.*/libdwarf' | xargs rm -f
1571 1573  else
1572 1574          echo "\n==== No clobber at `date` ====\n" >> $LOGFILE
1573 1575  fi
1574 1576  
1575 1577  type bringover_mercurial > /dev/null 2>&1 || function bringover_mercurial {
1576 1578          typeset -x PATH=$PATH
1577 1579  
1578 1580          # If the repository doesn't exist yet, then we want to populate it.
1579 1581          if [[ ! -d $CODEMGR_WS/.hg ]]; then
1580 1582                  staffer hg init $CODEMGR_WS
1581 1583                  staffer echo "[paths]" > $CODEMGR_WS/.hg/hgrc
1582 1584                  staffer echo "default=$BRINGOVER_WS" >> $CODEMGR_WS/.hg/hgrc
1583 1585                  touch $TMPDIR/new_repository
1584 1586          fi
1585 1587  
1586 1588          typeset -x HGMERGE="/bin/false"
1587 1589  
1588 1590          #
1589 1591          # If the user has changes, regardless of whether those changes are
1590 1592          # committed, and regardless of whether those changes conflict, then
1591 1593          # we'll attempt to merge them either implicitly (uncommitted) or
1592 1594          # explicitly (committed).
1593 1595          #
1594 1596          # These are the messages we'll use to help clarify mercurial output
1595 1597          # in those cases.
1596 1598          #
1597 1599          typeset mergefailmsg="\
1598 1600  ***\n\
1599 1601  *** nightly was unable to automatically merge your changes.  You should\n\
1600 1602  *** redo the full merge manually, following the steps outlined by mercurial\n\
1601 1603  *** above, then restart nightly.\n\
1602 1604  ***\n"
1603 1605          typeset mergepassmsg="\
1604 1606  ***\n\
1605 1607  *** nightly successfully merged your changes.  This means that your working\n\
1606 1608  *** directory has been updated, but those changes are not yet committed.\n\
1607 1609  *** After nightly completes, you should validate the results of the merge,\n\
1608 1610  *** then use hg commit manually.\n\
1609 1611  ***\n"
1610 1612  
1611 1613          #
1612 1614          # For each repository in turn:
1613 1615          #
1614 1616          # 1. Do the pull.  If this fails, dump the output and bail out.
1615 1617          #
1616 1618          # 2. If the pull resulted in an extra head, do an explicit merge.
1617 1619          #    If this fails, dump the output and bail out.
1618 1620          #
1619 1621          # Because we can't rely on Mercurial to exit with a failure code
1620 1622          # when a merge fails (Mercurial issue #186), we must grep the
1621 1623          # output of pull/merge to check for attempted and/or failed merges.
1622 1624          #
1623 1625          # 3. If a merge failed, set the message and fail the bringover.
1624 1626          #
1625 1627          # 4. Otherwise, if a merge succeeded, set the message
1626 1628          #
1627 1629          # 5. Dump the output, and any message from step 3 or 4.
1628 1630          #
1629 1631  
1630 1632          typeset HG_SOURCE=$BRINGOVER_WS
1631 1633          if [ ! -f $TMPDIR/new_repository ]; then
1632 1634                  HG_SOURCE=$TMPDIR/open_bundle.hg
1633 1635                  staffer hg --cwd $CODEMGR_WS incoming --bundle $HG_SOURCE \
1634 1636                      -v $BRINGOVER_WS > $TMPDIR/incoming_open.out
1635 1637  
1636 1638                  #
1637 1639                  # If there are no incoming changesets, then incoming will
1638 1640                  # fail, and there will be no bundle file.  Reset the source,
1639 1641                  # to allow the remaining logic to complete with no false
1640 1642                  # negatives.  (Unlike incoming, pull will return success
1641 1643                  # for the no-change case.)
1642 1644                  #
1643 1645                  if (( $? != 0 )); then
1644 1646                          HG_SOURCE=$BRINGOVER_WS
1645 1647                  fi
1646 1648          fi
1647 1649  
1648 1650          staffer hg --cwd $CODEMGR_WS pull -u $HG_SOURCE \
1649 1651              > $TMPDIR/pull_open.out 2>&1
1650 1652          if (( $? != 0 )); then
1651 1653                  printf "%s: pull failed as follows:\n\n" "$CODEMGR_WS"
1652 1654                  cat $TMPDIR/pull_open.out
1653 1655                  if grep "^merging.*failed" $TMPDIR/pull_open.out > /dev/null 2>&1; then
1654 1656                          printf "$mergefailmsg"
1655 1657                  fi
1656 1658                  touch $TMPDIR/bringover_failed
1657 1659                  return
1658 1660          fi
1659 1661  
1660 1662          if grep "not updating" $TMPDIR/pull_open.out > /dev/null 2>&1; then
1661 1663                  staffer hg --cwd $CODEMGR_WS merge \
1662 1664                      >> $TMPDIR/pull_open.out 2>&1
1663 1665                  if (( $? != 0 )); then
1664 1666                          printf "%s: merge failed as follows:\n\n" \
1665 1667                              "$CODEMGR_WS"
1666 1668                          cat $TMPDIR/pull_open.out
1667 1669                          if grep "^merging.*failed" $TMPDIR/pull_open.out \
1668 1670                              > /dev/null 2>&1; then
1669 1671                                  printf "$mergefailmsg"
1670 1672                          fi
1671 1673                          touch $TMPDIR/bringover_failed
1672 1674                          return
1673 1675                  fi
1674 1676          fi
1675 1677  
1676 1678          printf "updated %s with the following results:\n" "$CODEMGR_WS"
1677 1679          cat $TMPDIR/pull_open.out
1678 1680          if grep "^merging" $TMPDIR/pull_open.out >/dev/null 2>&1; then
1679 1681                  printf "$mergepassmsg"
1680 1682          fi
1681 1683          printf "\n"
1682 1684  
1683 1685          #
1684 1686          # Per-changeset output is neither useful nor manageable for a
1685 1687          # newly-created repository.
1686 1688          #
1687 1689          if [ -f $TMPDIR/new_repository ]; then
1688 1690                  return
1689 1691          fi
1690 1692  
1691 1693          printf "\nadded the following changesets to open repository:\n"
1692 1694          cat $TMPDIR/incoming_open.out
1693 1695  }
1694 1696  
1695 1697  type bringover_none > /dev/null 2>&1 || function bringover_none {
1696 1698          echo "Couldn't figure out what kind of SCM to use for $BRINGOVER_WS."
1697 1699          touch $TMPDIR/bringover_failed
1698 1700  }
1699 1701  
1700 1702  #
1701 1703  #       Decide whether to bringover to the codemgr workspace
1702 1704  #
1703 1705  if [ "$n_FLAG" = "n" ]; then
1704 1706          PARENT_SCM_TYPE=$(parent_wstype)
1705 1707  
1706 1708          if [[ $SCM_TYPE != none && $SCM_TYPE != $PARENT_SCM_TYPE ]]; then
1707 1709                  echo "cannot bringover from $PARENT_SCM_TYPE to $SCM_TYPE, " \
1708 1710                      "quitting at `date`." | tee -a $mail_msg_file >> $LOGFILE
1709 1711                  exit 1
1710 1712          fi
1711 1713  
1712 1714          run_hook PRE_BRINGOVER
1713 1715  
1714 1716          echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE
1715 1717          echo "\n==== BRINGOVER LOG ====\n" >> $mail_msg_file
1716 1718  
1717 1719          eval "bringover_${PARENT_SCM_TYPE}" 2>&1 |
1718 1720                  tee -a $mail_msg_file >> $LOGFILE
1719 1721  
1720 1722          if [ -f $TMPDIR/bringover_failed ]; then
1721 1723                  rm -f $TMPDIR/bringover_failed
1722 1724                  build_ok=n
1723 1725                  echo "trouble with bringover, quitting at `date`." |
1724 1726                          tee -a $mail_msg_file >> $LOGFILE
1725 1727                  exit 1
1726 1728          fi
1727 1729  
1728 1730          #
1729 1731          # It's possible that we used the bringover above to create
1730 1732          # $CODEMGR_WS.  If so, then SCM_TYPE was previously "none,"
1731 1733          # but should now be the same as $BRINGOVER_WS.
1732 1734          #
1733 1735          [[ $SCM_TYPE = none ]] && SCM_TYPE=$PARENT_SCM_TYPE
1734 1736  
1735 1737          run_hook POST_BRINGOVER
1736 1738  
1737 1739          check_closed_bins
1738 1740  
1739 1741  else
1740 1742          echo "\n==== No bringover to $CODEMGR_WS ====\n" >> $LOGFILE
1741 1743  fi
1742 1744  
1743 1745  # Safeguards
1744 1746  [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
1745 1747  [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
1746 1748  [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
1747 1749  
1748 1750  echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE
1749 1751  
1750 1752  # System
1751 1753  whence uname | tee -a $build_environ_file >> $LOGFILE
1752 1754  uname -a 2>&1 | tee -a $build_environ_file >> $LOGFILE
1753 1755  echo | tee -a $build_environ_file >> $LOGFILE
1754 1756  
1755 1757  # make
1756 1758  whence $MAKE | tee -a $build_environ_file >> $LOGFILE
1757 1759  $MAKE -v | tee -a $build_environ_file >> $LOGFILE
1758 1760  echo "number of concurrent jobs = $DMAKE_MAX_JOBS" |
1759 1761      tee -a $build_environ_file >> $LOGFILE
1760 1762  
1761 1763  #
1762 1764  # Report the compiler versions.
1763 1765  #
1764 1766  
1765 1767  if [[ ! -f $SRC/Makefile ]]; then
1766 1768          build_ok=n
1767 1769          echo "\nUnable to find \"Makefile\" in $SRC." | \
1768 1770              tee -a $build_environ_file >> $LOGFILE
1769 1771          exit 1
1770 1772  fi
1771 1773  
1772 1774  ( cd $SRC
1773 1775    for target in cc-version cc64-version java-version; do
1774 1776          echo
1775 1777          #
1776 1778          # Put statefile somewhere we know we can write to rather than trip
1777 1779          # over a read-only $srcroot.
1778 1780          #
1779 1781          rm -f $TMPDIR/make-state
1780 1782          export SRC
1781 1783          if $MAKE -K $TMPDIR/make-state -e $target 2>/dev/null; then
1782 1784                  continue
1783 1785          fi
1784 1786          touch $TMPDIR/nocompiler
1785 1787    done
1786 1788    echo
1787 1789  ) | tee -a $build_environ_file >> $LOGFILE
1788 1790  
1789 1791  if [ -f $TMPDIR/nocompiler ]; then
1790 1792          rm -f $TMPDIR/nocompiler
1791 1793          build_ok=n
1792 1794          echo "Aborting due to missing compiler." |
1793 1795                  tee -a $build_environ_file >> $LOGFILE
1794 1796          exit 1
1795 1797  fi
1796 1798  
1797 1799  # as
1798 1800  whence as | tee -a $build_environ_file >> $LOGFILE
1799 1801  as -V 2>&1 | head -1 | tee -a $build_environ_file >> $LOGFILE
1800 1802  echo | tee -a $build_environ_file >> $LOGFILE
1801 1803  
1802 1804  # Check that we're running a capable link-editor
1803 1805  whence ld | tee -a $build_environ_file >> $LOGFILE
1804 1806  LDVER=`ld -V 2>&1`
1805 1807  echo $LDVER | tee -a $build_environ_file >> $LOGFILE
1806 1808  LDVER=`echo $LDVER | sed -e "s/.*-1\.\([0-9]*\).*/\1/"`
1807 1809  if [ `expr $LDVER \< 422` -eq 1 ]; then
1808 1810          echo "The link-editor needs to be at version 422 or higher to build" | \
1809 1811              tee -a $build_environ_file >> $LOGFILE
1810 1812          echo "the latest stuff.  Hope your build works." | \
1811 1813              tee -a $build_environ_file >> $LOGFILE
1812 1814  fi
1813 1815  
1814 1816  #
1815 1817  # Build and use the workspace's tools if requested
1816 1818  #
1817 1819  if [[ "$t_FLAG" = "y" ]]; then
1818 1820          set_non_debug_build_flags
1819 1821  
1820 1822          build_tools ${TOOLS_PROTO}
1821 1823          if (( $? != 0 )); then
1822 1824                  build_ok=n
1823 1825          else
1824 1826                  use_tools $TOOLS_PROTO
1825 1827          fi
1826 1828  fi
1827 1829  
1828 1830  # timestamp the start of the normal build; the findunref tool uses it.
1829 1831  touch $SRC/.build.tstamp
1830 1832  
1831 1833  normal_build
1832 1834  
1833 1835  ORIG_SRC=$SRC
1834 1836  BINARCHIVE=${CODEMGR_WS}/bin-${MACH}.cpio.Z
1835 1837  
1836 1838  
1837 1839  #
1838 1840  # There are several checks that need to look at the proto area, but
1839 1841  # they only need to look at one, and they don't care whether it's
1840 1842  # DEBUG or non-DEBUG.
1841 1843  #
1842 1844  if [[ "$MULTI_PROTO" = yes && "$D_FLAG" = n ]]; then
1843 1845          checkroot=$ROOT-nd
1844 1846  else
1845 1847          checkroot=$ROOT
1846 1848  fi
1847 1849  
1848 1850  if [ "$build_ok" = "y" ]; then
1849 1851          echo "\n==== Creating protolist system file at `date` ====" \
1850 1852                  >> $LOGFILE
1851 1853          protolist $checkroot > $ATLOG/proto_list_${MACH}
1852 1854          echo "==== protolist system file created at `date` ====\n" \
1853 1855                  >> $LOGFILE
1854 1856  
1855 1857          if [ "$N_FLAG" != "y" ]; then
1856 1858  
1857 1859                  E1=
1858 1860                  f1=
1859 1861                  for f in $f1; do
1860 1862                          if [ -f "$f" ]; then
1861 1863                                  E1="$E1 -e $f"
1862 1864                          fi
1863 1865                  done
1864 1866  
1865 1867                  E2=
1866 1868                  f2=
1867 1869                  if [ -d "$SRC/pkg" ]; then
1868 1870                          f2="$f2 exceptions/packaging"
1869 1871                  fi
1870 1872  
1871 1873                  for f in $f2; do
1872 1874                          if [ -f "$f" ]; then
1873 1875                                  E2="$E2 -e $f"
1874 1876                          fi
1875 1877                  done
1876 1878          fi
1877 1879  
1878 1880          if [ "$N_FLAG" != "y" -a -d $SRC/pkg ]; then
1879 1881                  echo "\n==== Validating manifests against proto area ====\n" \
1880 1882                      >> $mail_msg_file
1881 1883                  ( cd $SRC/pkg ; $MAKE -e protocmp ROOT="$checkroot" ) | \
1882 1884                      tee $TMPDIR/protocmp_noise >> $mail_msg_file
1883 1885                  if [[ -s $TMPDIR/protocmp_noise ]]; then
1884 1886                          build_extras_ok=n
1885 1887                  fi
1886 1888          fi
1887 1889  
1888 1890          if [ "$N_FLAG" != "y" -a -f "$REF_PROTO_LIST" ]; then
1889 1891                  echo "\n==== Impact on proto area ====\n" >> $mail_msg_file
1890 1892                  if [ -n "$E2" ]; then
1891 1893                          ELIST=$E2
1892 1894                  else
1893 1895                          ELIST=$E1
1894 1896                  fi
1895 1897                  $PROTOCMPTERSE \
1896 1898                          "Files in yesterday's proto area, but not today's:" \
1897 1899                          "Files in today's proto area, but not yesterday's:" \
1898 1900                          "Files that changed between yesterday and today:" \
1899 1901                          ${ELIST} \
1900 1902                          -d $REF_PROTO_LIST \
1901 1903                          $ATLOG/proto_list_${MACH} \
1902 1904                          >> $mail_msg_file
1903 1905          fi
1904 1906  fi
1905 1907  
1906 1908  if [[ "$u_FLAG" == "y" && "$build_ok" == "y" && \
1907 1909      "$build_extras_ok" == "y" ]]; then
1908 1910          staffer cp $ATLOG/proto_list_${MACH} \
1909 1911                  $PARENT_WS/usr/src/proto_list_${MACH}
1910 1912  fi
1911 1913  
1912 1914  # Update parent proto area if necessary. This is done now
1913 1915  # so that the proto area has either DEBUG or non-DEBUG kernels.
1914 1916  # Note that this clears out the lock file, so we can dispense with
1915 1917  # the variable now.
1916 1918  if [ "$U_FLAG" = "y" -a "$build_ok" = "y" ]; then
1917 1919          echo "\n==== Copying proto area to $NIGHTLY_PARENT_ROOT ====\n" | \
1918 1920              tee -a $LOGFILE >> $mail_msg_file
1919 1921          rm -rf $NIGHTLY_PARENT_ROOT/*
1920 1922          unset Ulockfile
1921 1923          mkdir -p $NIGHTLY_PARENT_ROOT
1922 1924          if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1923 1925                  ( cd $ROOT; tar cf - . |
1924 1926                      ( cd $NIGHTLY_PARENT_ROOT;  umask 0; tar xpf - ) ) 2>&1 |
1925 1927                      tee -a $mail_msg_file >> $LOGFILE
1926 1928          fi
1927 1929          if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
1928 1930                  rm -rf $NIGHTLY_PARENT_ROOT-nd/*
1929 1931                  mkdir -p $NIGHTLY_PARENT_ROOT-nd
1930 1932                  cd $ROOT-nd
1931 1933                  ( tar cf - . |
1932 1934                      ( cd $NIGHTLY_PARENT_ROOT-nd; umask 0; tar xpf - ) ) 2>&1 |
1933 1935                      tee -a $mail_msg_file >> $LOGFILE
1934 1936          fi
1935 1937          if [ -n "${NIGHTLY_PARENT_TOOLS_ROOT}" ]; then
1936 1938                  echo "\n==== Copying tools proto area to $NIGHTLY_PARENT_TOOLS_ROOT ====\n" | \
1937 1939                      tee -a $LOGFILE >> $mail_msg_file
1938 1940                  rm -rf $NIGHTLY_PARENT_TOOLS_ROOT/*
1939 1941                  mkdir -p $NIGHTLY_PARENT_TOOLS_ROOT
1940 1942                  if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
1941 1943                          ( cd $TOOLS_PROTO; tar cf - . |
1942 1944                              ( cd $NIGHTLY_PARENT_TOOLS_ROOT; 
1943 1945                              umask 0; tar xpf - ) ) 2>&1 |
1944 1946                              tee -a $mail_msg_file >> $LOGFILE
1945 1947                  fi
1946 1948          fi
1947 1949  fi
1948 1950  
1949 1951  #
1950 1952  # ELF verification: ABI (-A) and runtime (-r) checks
1951 1953  #
1952 1954  if [[ ($build_ok = y) && (($A_FLAG = y) || ($r_FLAG = y)) ]]; then
1953 1955          # Directory ELF-data.$MACH holds the files produced by these tests.
1954 1956          elf_ddir=$SRC/ELF-data.$MACH
1955 1957  
1956 1958          # If there is a previous ELF-data backup directory, remove it. Then,
1957 1959          # rotate current ELF-data directory into its place and create a new
1958 1960          # empty directory
1959 1961          rm -rf $elf_ddir.ref
1960 1962          if [[ -d $elf_ddir ]]; then
1961 1963                  mv $elf_ddir $elf_ddir.ref
1962 1964          fi
1963 1965          mkdir -p $elf_ddir
1964 1966  
1965 1967          # Call find_elf to produce a list of the ELF objects in the proto area.
1966 1968          # This list is passed to check_rtime and interface_check, preventing
1967 1969          # them from separately calling find_elf to do the same work twice.
1968 1970          find_elf -fr $checkroot > $elf_ddir/object_list
1969 1971  
1970 1972          if [[ $A_FLAG = y ]]; then
1971 1973                  echo "\n==== Check versioning and ABI information ====\n"  | \
1972 1974                      tee -a $LOGFILE >> $mail_msg_file
1973 1975  
1974 1976                  # Produce interface description for the proto. Report errors.
1975 1977                  interface_check -o -w $elf_ddir -f object_list \
1976 1978                          -i interface -E interface.err
1977 1979                  if [[ -s $elf_ddir/interface.err ]]; then
1978 1980                          tee -a $LOGFILE < $elf_ddir/interface.err \
1979 1981                              >> $mail_msg_file
1980 1982                          build_extras_ok=n
1981 1983                  fi
1982 1984  
1983 1985                  # If ELF_DATA_BASELINE_DIR is defined, compare the new interface
1984 1986                  # description file to that from the baseline gate. Issue a
1985 1987                  # warning if the baseline is not present, and keep going.
1986 1988                  if [[ "$ELF_DATA_BASELINE_DIR" != '' ]]; then
1987 1989                          base_ifile="$ELF_DATA_BASELINE_DIR/interface"
1988 1990  
1989 1991                          echo "\n==== Compare versioning and ABI information" \
1990 1992                              "to baseline ====\n"  | \
1991 1993                              tee -a $LOGFILE >> $mail_msg_file
1992 1994                          echo "Baseline:  $base_ifile\n" >> $LOGFILE
1993 1995  
1994 1996                          if [[ -f $base_ifile ]]; then
1995 1997                                  interface_cmp -d -o $base_ifile \
1996 1998                                      $elf_ddir/interface > $elf_ddir/interface.cmp
1997 1999                                  if [[ -s $elf_ddir/interface.cmp ]]; then
1998 2000                                          echo | tee -a $LOGFILE >> $mail_msg_file
1999 2001                                          tee -a $LOGFILE < \
2000 2002                                              $elf_ddir/interface.cmp \
2001 2003                                              >> $mail_msg_file
2002 2004                                          build_extras_ok=n
2003 2005                                  fi
2004 2006                          else
2005 2007                                  echo "baseline not available. comparison" \
2006 2008                                      "skipped" | \
2007 2009                                      tee -a $LOGFILE >> $mail_msg_file
2008 2010                          fi
2009 2011  
2010 2012                  fi
2011 2013          fi
2012 2014  
2013 2015          if [[ $r_FLAG = y ]]; then
2014 2016                  echo "\n==== Check ELF runtime attributes ====\n" | \
2015 2017                      tee -a $LOGFILE >> $mail_msg_file
2016 2018  
2017 2019                  # If we're doing a DEBUG build the proto area will be left
2018 2020                  # with debuggable objects, thus don't assert -s.
2019 2021                  if [[ $D_FLAG = y ]]; then
2020 2022                          rtime_sflag=""
2021 2023                  else
2022 2024                          rtime_sflag="-s"
2023 2025                  fi
2024 2026                  check_rtime -i -m -v $rtime_sflag -o -w $elf_ddir \
2025 2027                          -D object_list  -f object_list -E runtime.err \
2026 2028                          -I runtime.attr.raw
2027 2029                  if (( $? != 0 )); then
2028 2030                          build_extras_ok=n
2029 2031                  fi
2030 2032  
2031 2033                  # check_rtime -I output needs to be sorted in order to 
2032 2034                  # compare it to that from previous builds.
2033 2035                  sort $elf_ddir/runtime.attr.raw > $elf_ddir/runtime.attr
2034 2036                  rm $elf_ddir/runtime.attr.raw
2035 2037  
2036 2038                  # Report errors
2037 2039                  if [[ -s $elf_ddir/runtime.err ]]; then
2038 2040                          tee -a $LOGFILE < $elf_ddir/runtime.err \
2039 2041                                  >> $mail_msg_file
2040 2042                          build_extras_ok=n
2041 2043                  fi
2042 2044  
2043 2045                  # If there is an ELF-data directory from a previous build,
2044 2046                  # then diff the attr files. These files contain information
2045 2047                  # about dependencies, versioning, and runpaths. There is some
2046 2048                  # overlap with the ABI checking done above, but this also
2047 2049                  # flushes out non-ABI interface differences along with the
2048 2050                  # other information.
2049 2051                  echo "\n==== Diff ELF runtime attributes" \
2050 2052                      "(since last build) ====\n" | \
2051 2053                      tee -a $LOGFILE >> $mail_msg_file >> $mail_msg_file
2052 2054  
2053 2055                  if [[ -f $elf_ddir.ref/runtime.attr ]]; then
2054 2056                          diff $elf_ddir.ref/runtime.attr \
2055 2057                                  $elf_ddir/runtime.attr \
2056 2058                                  >> $mail_msg_file
2057 2059                  fi
2058 2060          fi
2059 2061  
2060 2062          # If -u set, copy contents of ELF-data.$MACH to the parent workspace.
2061 2063          if [[ "$u_FLAG" = "y" ]]; then
2062 2064                  p_elf_ddir=$PARENT_WS/usr/src/ELF-data.$MACH
2063 2065  
2064 2066                  # If parent lacks the ELF-data.$MACH directory, create it
2065 2067                  if [[ ! -d $p_elf_ddir ]]; then
2066 2068                          staffer mkdir -p $p_elf_ddir
2067 2069                  fi
2068 2070  
2069 2071                  # These files are used asynchronously by other builds for ABI
2070 2072                  # verification, as above for the -A option. As such, we require
2071 2073                  # the file replacement to be atomic. Copy the data to a temp
2072 2074                  # file in the same filesystem and then rename into place. 
2073 2075                  (
2074 2076                          cd $elf_ddir
2075 2077                          for elf_dfile in *; do
2076 2078                                  staffer cp $elf_dfile \
2077 2079                                      ${p_elf_ddir}/${elf_dfile}.new
2078 2080                                  staffer mv -f ${p_elf_ddir}/${elf_dfile}.new \
2079 2081                                      ${p_elf_ddir}/${elf_dfile}
2080 2082                          done
2081 2083                  )
2082 2084          fi
2083 2085  fi
2084 2086  
2085 2087  # DEBUG lint of kernel begins
2086 2088  
2087 2089  if [ "$i_CMD_LINE_FLAG" = "n" -a "$l_FLAG" = "y" ]; then
2088 2090          if [ "$LINTDIRS" = "" ]; then
2089 2091                  # LINTDIRS="$SRC/uts y $SRC/stand y $SRC/psm y"
2090 2092                  LINTDIRS="$SRC y"
2091 2093          fi
2092 2094          set $LINTDIRS
2093 2095          while [ $# -gt 0 ]; do
2094 2096                  dolint $1 $2; shift; shift
2095 2097          done
2096 2098  else
2097 2099          echo "\n==== No '$MAKE lint' ====\n" >> $LOGFILE
2098 2100  fi
2099 2101  
2100 2102  # "make check" begins
2101 2103  
2102 2104  if [ "$i_CMD_LINE_FLAG" = "n" -a "$C_FLAG" = "y" ]; then
2103 2105          # remove old check.out
2104 2106          rm -f $SRC/check.out
2105 2107  
2106 2108          rm -f $SRC/check-${MACH}.out
2107 2109          cd $SRC
2108 2110          $MAKE -ek check ROOT="$checkroot" 2>&1 | tee -a $SRC/check-${MACH}.out \
2109 2111              >> $LOGFILE
2110 2112          echo "\n==== cstyle/hdrchk errors ====\n" >> $mail_msg_file
2111 2113  
2112 2114          grep ":" $SRC/check-${MACH}.out |
2113 2115                  egrep -v "Ignoring unknown host" | \
2114 2116                  sort | uniq | tee $TMPDIR/check_errors >> $mail_msg_file
2115 2117  
2116 2118          if [[ -s $TMPDIR/check_errors ]]; then
2117 2119                  build_extras_ok=n
2118 2120          fi
2119 2121  else
2120 2122          echo "\n==== No '$MAKE check' ====\n" >> $LOGFILE
2121 2123  fi
2122 2124  
2123 2125  echo "\n==== Find core files ====\n" | \
2124 2126      tee -a $LOGFILE >> $mail_msg_file
2125 2127  
2126 2128  find $abssrcdirs -name core -a -type f -exec file {} \; | \
2127 2129          tee -a $LOGFILE >> $mail_msg_file
2128 2130  
2129 2131  if [ "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2130 2132          echo "\n==== Diff unreferenced files (since last build) ====\n" \
2131 2133              | tee -a $LOGFILE >>$mail_msg_file
2132 2134          rm -f $SRC/unref-${MACH}.ref
2133 2135          if [ -f $SRC/unref-${MACH}.out ]; then
2134 2136                  mv $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2135 2137          fi
2136 2138  
2137 2139          findunref -S $SCM_TYPE -t $SRC/.build.tstamp -s usr $CODEMGR_WS \
2138 2140              ${TOOLS}/findunref/exception_list 2>> $mail_msg_file | \
2139 2141              sort > $SRC/unref-${MACH}.out
2140 2142  
2141 2143          if [ ! -f $SRC/unref-${MACH}.ref ]; then
2142 2144                  cp $SRC/unref-${MACH}.out $SRC/unref-${MACH}.ref
2143 2145          fi
2144 2146  
2145 2147          diff $SRC/unref-${MACH}.ref $SRC/unref-${MACH}.out >>$mail_msg_file
2146 2148  fi
2147 2149  
2148 2150  # Verify that the usual lists of files, such as exception lists,
2149 2151  # contain only valid references to files.  If the build has failed,
2150 2152  # then don't check the proto area.
2151 2153  CHECK_PATHS=${CHECK_PATHS:-y}
2152 2154  if [ "$CHECK_PATHS" = y -a "$N_FLAG" != y ]; then
2153 2155          echo "\n==== Check lists of files ====\n" | tee -a $LOGFILE \
2154 2156                  >>$mail_msg_file
2155 2157          arg=-b
2156 2158          [ "$build_ok" = y ] && arg=
2157 2159          checkpaths $arg $checkroot > $SRC/checkpaths.out 2>&1
2158 2160          if [[ -s $SRC/checkpaths.out ]]; then
2159 2161                  tee -a $LOGFILE < $SRC/checkpaths.out >> $mail_msg_file
2160 2162                  build_extras_ok=n
2161 2163          fi
2162 2164  fi
2163 2165  
2164 2166  if [ "$M_FLAG" != "y" -a "$build_ok" = y ]; then
2165 2167          echo "\n==== Impact on file permissions ====\n" \
2166 2168                  >> $mail_msg_file
2167 2169  
2168 2170          abspkg=
2169 2171          for d in $abssrcdirs; do
2170 2172                  if [ -d "$d/pkg" ]; then
2171 2173                          abspkg="$abspkg $d"
2172 2174                  fi
2173 2175          done
2174 2176  
2175 2177          if [ -n "$abspkg" ]; then
2176 2178                  for d in "$abspkg"; do
2177 2179                          ( cd $d/pkg ; $MAKE -e pmodes ) >> $mail_msg_file
2178 2180                  done
2179 2181          fi
2180 2182  fi
2181 2183  
2182 2184  if [ "$w_FLAG" = "y" -a "$build_ok" = "y" ]; then
2183 2185          if [[ "$MULTI_PROTO" = no || "$D_FLAG" = y ]]; then
2184 2186                  do_wsdiff DEBUG $ROOT.prev $ROOT
2185 2187          fi
2186 2188  
2187 2189          if [[ "$MULTI_PROTO" = yes && "$F_FLAG" = n ]]; then
2188 2190                  do_wsdiff non-DEBUG $ROOT-nd.prev $ROOT-nd
2189 2191          fi
2190 2192  fi
2191 2193  
2192 2194  END_DATE=`date`
2193 2195  echo "==== Nightly $maketype build completed: $END_DATE ====" | \
2194 2196      tee -a $LOGFILE >> $build_time_file
2195 2197  
2196 2198  typeset -i10 hours
2197 2199  typeset -Z2 minutes
2198 2200  typeset -Z2 seconds
2199 2201  
2200 2202  elapsed_time=$SECONDS
2201 2203  ((hours = elapsed_time / 3600 ))
2202 2204  ((minutes = elapsed_time / 60  % 60))
2203 2205  ((seconds = elapsed_time % 60))
2204 2206  
2205 2207  echo "\n==== Total build time ====" | \
2206 2208      tee -a $LOGFILE >> $build_time_file
2207 2209  echo "\nreal    ${hours}:${minutes}:${seconds}" | \
2208 2210      tee -a $LOGFILE >> $build_time_file
2209 2211  
2210 2212  if [ "$u_FLAG" = "y" -a "$f_FLAG" = "y" -a "$build_ok" = "y" ]; then
2211 2213          staffer cp ${SRC}/unref-${MACH}.out $PARENT_WS/usr/src/
2212 2214  
2213 2215          #
2214 2216          # Produce a master list of unreferenced files -- ideally, we'd
2215 2217          # generate the master just once after all of the nightlies
2216 2218          # have finished, but there's no simple way to know when that
2217 2219          # will be.  Instead, we assume that we're the last nightly to
2218 2220          # finish and merge all of the unref-${MACH}.out files in
2219 2221          # $PARENT_WS/usr/src/.  If we are in fact the final ${MACH} to
2220 2222          # finish, then this file will be the authoritative master
2221 2223          # list.  Otherwise, another ${MACH}'s nightly will eventually
2222 2224          # overwrite ours with its own master, but in the meantime our
2223 2225          # temporary "master" will be no worse than any older master
2224 2226          # which was already on the parent.
2225 2227          #
2226 2228  
2227 2229          set -- $PARENT_WS/usr/src/unref-*.out
2228 2230          cp "$1" ${TMPDIR}/unref.merge
2229 2231          shift
2230 2232  
2231 2233          for unreffile; do
2232 2234                  comm -12 ${TMPDIR}/unref.merge "$unreffile" > ${TMPDIR}/unref.$$
2233 2235                  mv ${TMPDIR}/unref.$$ ${TMPDIR}/unref.merge
2234 2236          done
2235 2237  
2236 2238          staffer cp ${TMPDIR}/unref.merge $PARENT_WS/usr/src/unrefmaster.out
2237 2239  fi
2238 2240  
2239 2241  #
2240 2242  # All done save for the sweeping up.
2241 2243  # (whichever exit we hit here will trigger the "cleanup" trap which
2242 2244  # optionally sends mail on completion).
2243 2245  #
2244 2246  if [[ "$build_ok" == "y" ]]; then
2245 2247          if [[ "$W_FLAG" == "y" || "$build_extras_ok" == "y" ]]; then
2246 2248                  exit 0
2247 2249          fi
2248 2250  fi
2249 2251  
2250 2252  exit 1
  
    | 
      ↓ open down ↓ | 
    1501 lines elided | 
    
      ↑ open up ↑ | 
  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX