Print this page
XXX Remove nawk(1)

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/boot/scripts/create_ramdisk.ksh
          +++ new/usr/src/cmd/boot/scripts/create_ramdisk.ksh
↓ open down ↓ 151 lines elided ↑ open up ↑
 152  152          lofiadm -d "$rdfile64" 2>/dev/null
 153  153          [ -n "$rddir" ] && rm -fr "$rddir" 2> /dev/null
 154  154          [ -n "$new_rddir" ] && rm -fr "$new_rddir" 2>/dev/null
 155  155  }
 156  156  
 157  157  function getsize
 158  158  {
 159  159          # Estimate image size and add 10% overhead for ufs stuff.
 160  160          # Note, we can't use du here in case we're on a filesystem, e.g. zfs,
 161  161          # in which the disk usage is less than the sum of the file sizes.
 162      -        # The nawk code 
      162 +        # The awk code 
 163  163          #
 164  164          #       {t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}
 165  165          #
 166  166          # below rounds up the size of a file/directory, in bytes, to the
 167  167          # next multiple of 1024.  This mimics the behavior of ufs especially
 168  168          # with directories.  This results in a total size that's slightly
 169  169          # bigger than if du was called on a ufs directory.
 170  170          size32=$(cat "$list32" | xargs -I {} ls -lLd "{}" 2> /dev/null |
 171      -                nawk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}
      171 +                /usr/xpg4/bin/awk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}
 172  172                  END {print int(t * 1.10 / 1024)}')
 173  173          (( size32 += dirsize32 ))
 174  174          size64=$(cat "$list64" | xargs -I {} ls -lLd "{}" 2> /dev/null |
 175      -                nawk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}
      175 +                /usr/xpg4/bin/awk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}
 176  176                  END {print int(t * 1.10 / 1024)}')
 177  177          (( size64 += dirsize64 ))
 178  178          (( total_size = size32 + size64 ))
 179  179  
 180  180          if [ $compress = yes ] ; then
 181      -                total_size=`echo $total_size | nawk '{print int($1 / 2)}'`
      181 +                total_size=`echo $total_size | /usr/xpg4/bin/awk '{print int($1 / 2)}'`
 182  182          fi
 183  183  }
 184  184  
 185  185  #
 186  186  # Copies all desired files to a target directory.  One argument should be
 187  187  # passed: the file containing the list of files to copy.  This function also
 188  188  # depends on several variables that must be set before calling:
 189  189  #
 190  190  # $ALT_ROOT - the target directory
 191  191  # $compress - whether or not the files in the archives should be compressed
↓ open down ↓ 196 lines elided ↑ open up ↑
 388  388          echo "updating $archive"
 389  389  
 390  390          if [ "$format" = "ufs" ]; then
 391  391                  create_ufs "$which" "$archive" "$lofidev"
 392  392          else
 393  393                  create_isofs "$which" "$archive"
 394  394          fi
 395  395  
 396  396          # sanity check the archive before moving it into place
 397  397          #
 398      -        ARCHIVE_SIZE=`ls -l "${archive}-new" 2> /dev/null | nawk '{ print $5 }'`
      398 +        ARCHIVE_SIZE=`ls -l "${archive}-new" 2> /dev/null | /usr/xpg4/bin/awk '{ print $5 }'`
 399  399          if [ $compress = yes ] || [ $ISA = sparc ] ; then
 400  400                  #
 401  401                  # 'file' will report "English text" for uncompressed
 402  402                  # boot_archives.  Checking for that doesn't seem stable,
 403  403                  # so we just check that the file exists.
 404  404                  #
 405  405                  ls "${archive}-new" >/dev/null 2>&1
 406  406          else
 407  407                  #
 408  408                  # the file type check also establishes that the
↓ open down ↓ 61 lines elided ↑ open up ↑
 470  470  # is written to stdout, which is redirected at the end of the loop.  The
 471  471  # 64-bit list is appended with each write.
 472  472  #
 473  473  cd "/$ALT_ROOT"
 474  474  find $filelist -print 2>/dev/null | while read path
 475  475  do
 476  476          if [ $SPLIT = no ]; then
 477  477                  print "$path"
 478  478          elif [ -d "$path" ]; then
 479  479                  if [ $format = ufs ]; then
 480      -                        size=`ls -lLd "$path" | nawk '
      480 +                        size=`ls -lLd "$path" | /usr/xpg4/bin/awk '
 481  481                              {print ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}'`
 482  482                          if [ `basename "$path"` != "amd64" ]; then
 483  483                                  (( dirsize32 += size ))
 484  484                          fi
 485  485                          (( dirsize64 += size ))
 486  486                  fi
 487  487          else
 488  488                  case `LC_MESSAGES=C /usr/bin/file -m /dev/null "$path" 2>/dev/null` in
 489  489                  *ELF\ 64-bit*)
 490  490                          print "$path" >> "$list64"
↓ open down ↓ 99 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX