Print this page
8564 developer/build/onbld shouldn't require ghostscript
Reviewed by: Alexander Pyhalov <apyhalov@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/scripts/webrev.sh
          +++ new/usr/src/tools/scripts/webrev.sh
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19  #
  20   20  # CDDL HEADER END
  21   21  #
  22   22  
  23   23  #
  24   24  # Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  25   25  # Copyright 2008, 2010, Richard Lowe
  26   26  # Copyright 2012 Marcel Telka <marcel@telka.sk>
  27   27  # Copyright 2014 Bart Coddens <bart.coddens@gmail.com>
  28   28  # Copyright 2017 Nexenta Systems, Inc.
  29      -# Copyright 2016 Joyent, Inc.
       29 +# Copyright 2019 Joyent, Inc.
  30   30  # Copyright 2016 RackTop Systems.
  31   31  #
  32   32  
  33   33  #
  34   34  # This script takes a file list and a workspace and builds a set of html files
  35   35  # suitable for doing a code review of source changes via a web page.
  36   36  # Documentation is available via the manual page, webrev.1, or just
  37   37  # type 'webrev -h'.
  38   38  #
  39   39  # Acknowledgements to contributors to webrev are listed in the webrev(1)
↓ open down ↓ 1233 lines elided ↑ open up ↑
1273 1273                and has the feature enabled.
1274 1274              </body>
1275 1275            </noframes>
1276 1276            </frameset>
1277 1277          </html>
1278 1278          EOF
1279 1279  }
1280 1280  
1281 1281  
1282 1282  #
1283      -# fix_postscript
1284      -#
1285      -# Merge codereview output files to a single conforming postscript file, by:
1286      -#       - removing all extraneous headers/trailers
1287      -#       - making the page numbers right
1288      -#       - removing pages devoid of contents which confuse some
1289      -#         postscript readers.
1290      -#
1291      -# From Casper.
1292      -#
1293      -function fix_postscript
1294      -{
1295      -        infile=$1
1296      -
1297      -        cat > /tmp/$$.crmerge.pl << \EOF
1298      -
1299      -        print scalar(<>);               # %!PS-Adobe---
1300      -        print "%%Orientation: Landscape\n";
1301      -
1302      -        $pno = 0;
1303      -        $doprint = 1;
1304      -
1305      -        $page = "";
1306      -
1307      -        while (<>) {
1308      -                next if (/^%%Pages:\s*\d+/);
1309      -
1310      -                if (/^%%Page:/) {
1311      -                        if ($pno == 0 || $page =~ /\)S/) {
1312      -                                # Header or single page containing text
1313      -                                print "%%Page: ? $pno\n" if ($pno > 0);
1314      -                                print $page;
1315      -                                $pno++;
1316      -                        } else {
1317      -                                # Empty page, skip it.
1318      -                        }
1319      -                        $page = "";
1320      -                        $doprint = 1;
1321      -                        next;
1322      -                }
1323      -
1324      -                # Skip from %%Trailer of one document to Endprolog
1325      -                # %%Page of the next
1326      -                $doprint = 0 if (/^%%Trailer/);
1327      -                $page .= $_ if ($doprint);
1328      -        }
1329      -
1330      -        if ($page =~ /\)S/) {
1331      -                print "%%Page: ? $pno\n";
1332      -                print $page;
1333      -        } else {
1334      -                $pno--;
1335      -        }
1336      -        print "%%Trailer\n%%Pages: $pno\n";
1337      -EOF
1338      -
1339      -        $PERL /tmp/$$.crmerge.pl < $infile
1340      -}
1341      -
1342      -
1343      -#
1344 1283  # input_cmd | insert_anchors | output_cmd
1345 1284  #
1346 1285  # Flag blocks of difference with sequentially numbered invisible
1347 1286  # anchors.  These are used to drive the frames version of the
1348 1287  # sdiffs output.
1349 1288  #
1350 1289  # NOTE: Anchor zero flags the top of the file irrespective of changes,
1351 1290  # an additional anchor is also appended to flag the bottom.
1352 1291  #
1353 1292  # The script detects changed lines as any line that has a "<span
↓ open down ↓ 996 lines elided ↑ open up ↑
2350 2289  trap "rm -f /tmp/$$.* ; exit" 0 1 2 3 15
2351 2290  
2352 2291  set +o noclobber
2353 2292  
2354 2293  PATH=$(/bin/dirname "$(whence $0)"):$PATH
2355 2294  
2356 2295  [[ -z $WDIFF ]] && WDIFF=`look_for_prog wdiff`
2357 2296  [[ -z $WX ]] && WX=`look_for_prog wx`
2358 2297  [[ -z $GIT ]] && GIT=`look_for_prog git`
2359 2298  [[ -z $WHICH_SCM ]] && WHICH_SCM=`look_for_prog which_scm`
2360      -[[ -z $CODEREVIEW ]] && CODEREVIEW=`look_for_prog codereview`
2361      -[[ -z $PS2PDF ]] && PS2PDF=`look_for_prog ps2pdf`
2362 2299  [[ -z $PERL ]] && PERL=`look_for_prog perl`
2363 2300  [[ -z $RSYNC ]] && RSYNC=`look_for_prog rsync`
2364 2301  [[ -z $SCCS ]] && SCCS=`look_for_prog sccs`
2365 2302  [[ -z $AWK ]] && AWK=`look_for_prog nawk`
2366 2303  [[ -z $AWK ]] && AWK=`look_for_prog gawk`
2367 2304  [[ -z $AWK ]] && AWK=`look_for_prog awk`
2368 2305  [[ -z $SCP ]] && SCP=`look_for_prog scp`
2369 2306  [[ -z $SED ]] && SED=`look_for_prog sed`
2370 2307  [[ -z $SFTP ]] && SFTP=`look_for_prog sftp`
2371 2308  [[ -z $SORT ]] && SORT=`look_for_prog sort`
↓ open down ↓ 10 lines elided ↑ open up ↑
2382 2319  if [[ ! -x $PERL ]]; then
2383 2320          print -u2 "Error: No perl interpreter found.  Exiting."
2384 2321          exit 1
2385 2322  fi
2386 2323  
2387 2324  if [[ ! -x $WHICH_SCM ]]; then
2388 2325          print -u2 "Error: Could not find which_scm.  Exiting."
2389 2326          exit 1
2390 2327  fi
2391 2328  
2392      -#
2393      -# These aren't fatal, but we want to note them to the user.
2394      -# We don't warn on the absence of 'wx' until later when we've
2395      -# determined that we actually need to try to invoke it.
2396      -#
2397      -[[ ! -x $CODEREVIEW ]] && print -u2 "WARNING: codereview(1) not found."
2398      -[[ ! -x $PS2PDF ]] && print -u2 "WARNING: ps2pdf(1) not found."
2399 2329  [[ ! -x $WDIFF ]] && print -u2 "WARNING: wdiff not found."
2400 2330  
2401 2331  # Declare global total counters.
2402 2332  integer TOTL TINS TDEL TMOD TUNC
2403 2333  
2404 2334  # default remote host for upload/delete
2405 2335  typeset -r DEFAULT_REMOTE_HOST="cr.opensolaris.org"
2406 2336  # prefixes for upload targets
2407 2337  typeset -r rsync_prefix="rsync://"
2408 2338  typeset -r ssh_prefix="ssh://"
↓ open down ↓ 647 lines elided ↑ open up ↑
3056 2986  
3057 2987  [[ -n $INCLUDE_FILE ]] && print "      Including: $INCLUDE_FILE"
3058 2988  print "      Output to: $WDIR"
3059 2989  
3060 2990  #
3061 2991  # Save the file list in the webrev dir
3062 2992  #
3063 2993  [[ ! $FLIST -ef $WDIR/file.list ]] && cp $FLIST $WDIR/file.list
3064 2994  
3065 2995  rm -f $WDIR/$WNAME.patch
3066      -rm -f $WDIR/$WNAME.ps
3067      -rm -f $WDIR/$WNAME.pdf
3068 2996  
3069 2997  touch $WDIR/$WNAME.patch
3070 2998  
3071 2999  print "   Output Files:"
3072 3000  
3073 3001  #
3074 3002  # Clean up the file list: Remove comments, blank lines and env variables.
3075 3003  #
3076 3004  $SED -e "s/#.*$//" -e "/=/d" -e "/^[   ]*$/d" $FLIST > /tmp/$$.flist.clean
3077 3005  FLIST=/tmp/$$.flist.clean
↓ open down ↓ 219 lines elided ↑ open up ↑
3297 3225                          fi
3298 3226                          sdiff_to_html $ofile.man.txt $nfile.man.txt $F.man $DIR \
3299 3227                              "$COMM" > $WDIR/$DIR/$F.man.sdiff.html
3300 3228                          print " man-sdiffs\c"
3301 3229                          print " man-frames\c"
3302 3230                  fi
3303 3231                  rm -f $ofile.man.txt $nfile.man.txt
3304 3232                  rm -f $WDIR/$DIR/$F.man.cdiff $WDIR/$DIR/$F.man.udiff
3305 3233          fi
3306 3234  
3307      -        #
3308      -        # Now we generate the postscript for this file.  We generate diffs
3309      -        # only in the event that there is delta, or the file is new (it seems
3310      -        # tree-killing to print out the contents of deleted files).
3311      -        #
3312      -        if [[ -f $nfile ]]; then
3313      -                ocr=$ofile
3314      -                [[ ! -f $ofile ]] && ocr=/dev/null
3315      -
3316      -                if [[ -z $mv_but_nodiff ]]; then
3317      -                        textcomm=`getcomments text $P $PP`
3318      -                        if [[ -x $CODEREVIEW ]]; then
3319      -                                $CODEREVIEW -y "$textcomm" \
3320      -                                    -e $ocr $nfile \
3321      -                                    > /tmp/$$.psfile 2>/dev/null &&
3322      -                                    cat /tmp/$$.psfile >> $WDIR/$WNAME.ps
3323      -                                if [[ $? -eq 0 ]]; then
3324      -                                        print " ps\c"
3325      -                                else
3326      -                                        print " ps[fail]\c"
3327      -                                fi
3328      -                        fi
3329      -                fi
3330      -        fi
3331      -
3332 3235          if [[ -f $ofile ]]; then
3333 3236                  source_to_html Old $PP < $ofile > $WDIR/$DIR/$F-.html
3334 3237                  print " old\c"
3335 3238          fi
3336 3239  
3337 3240          if [[ -f $nfile ]]; then
3338 3241                  source_to_html New $P < $nfile > $WDIR/$DIR/$F.html
3339 3242                  print " new\c"
3340 3243          fi
3341 3244  
3342 3245          cd $OWD
3343 3246  
3344 3247          print
3345 3248  done
3346 3249  
3347 3250  frame_nav_js > $WDIR/ancnav.js
3348 3251  frame_navigation > $WDIR/ancnav.html
3349 3252  
3350      -if [[ ! -f $WDIR/$WNAME.ps ]]; then
3351      -        print " Generating PDF: Skipped: no output available"
3352      -elif [[ -x $CODEREVIEW && -x $PS2PDF ]]; then
3353      -        print " Generating PDF: \c"
3354      -        fix_postscript $WDIR/$WNAME.ps | $PS2PDF - > $WDIR/$WNAME.pdf
3355      -        print "Done."
3356      -else
3357      -        print " Generating PDF: Skipped: missing 'ps2pdf' or 'codereview'"
3358      -fi
3359      -
3360 3253  # If we're in OpenSolaris mode and there's a closed dir under $WDIR,
3361 3254  # delete it - prevent accidental publishing of closed source
3362 3255  
3363 3256  if [[ -n "$Oflag" ]]; then
3364 3257          $FIND $WDIR -type d -name closed -exec /bin/rm -rf {} \;
3365 3258  fi
3366 3259  
3367 3260  # Now build the index.html file that contains
3368 3261  # links to the source files and their diffs.
3369 3262  
↓ open down ↓ 60 lines elided ↑ open up ↑
3430 3323  print "</td></tr>"
3431 3324  print "<tr><th>Summary of changes:</th><td>"
3432 3325  printCI $TOTL $TINS $TDEL $TMOD $TUNC
3433 3326  print "</td></tr>"
3434 3327  
3435 3328  if [[ -f $WDIR/$WNAME.patch ]]; then
3436 3329          wpatch_url="$(print $WNAME.patch | url_encode)"
3437 3330          print "<tr><th>Patch of changes:</th><td>"
3438 3331          print "<a href=\"$wpatch_url\">$WNAME.patch</a></td></tr>"
3439 3332  fi
3440      -if [[ -f $WDIR/$WNAME.pdf ]]; then
3441      -        wpdf_url="$(print $WNAME.pdf | url_encode)"
3442      -        print "<tr><th>Printable review:</th><td>"
3443      -        print "<a href=\"$wpdf_url\">$WNAME.pdf</a></td></tr>"
3444      -fi
3445 3333  
3446 3334  if [[ -n "$iflag" ]]; then
3447 3335          print "<tr><th>Author comments:</th><td><div>"
3448 3336          cat /tmp/$$.include
3449 3337          print "</div></td></tr>"
3450 3338  fi
3451 3339  print "</table>"
3452 3340  print "</div>"
3453 3341  
3454 3342  #
↓ open down ↓ 238 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX