186 lines
		
	
	
	
		
			6.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			186 lines
		
	
	
	
		
			6.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/bin/sh
 | |
| # Copyright (c) 2001-2017 Wolfram Schneider <wosch@FreeBSD.org>
 | |
| # Copyright (c) 2001 Dima Dorfman <dd@FreeBSD.org>
 | |
| #
 | |
| # Update the FreeBSD web site from the SVN repository.
 | |
| #
 | |
| #
 | |
| # NOTE: Changes to this file is NOT automatically used for the web
 | |
| # site build on www.FreeBSD.org.  If an update to the main build
 | |
| # script is required, please contact webmaster@FreeBSD.org or a member
 | |
| # of the wwwadm team.
 | |
| #
 | |
| #
 | |
| # Major variables:
 | |
| #
 | |
| #	PATH		- The search path as interpreted by the shell.
 | |
| #	SVNROOT		- Path to the FreeBSD SVN repository.
 | |
| #	BUILDDIR	- Where the checked out copies of the files are stored.
 | |
| #	DESTDIR		- Where the rendered copies should wind up.
 | |
| #	PUBDIR		- Where the rendered files are published.
 | |
| #	LOGFILE		- Name of the log file to use (in $BUILDDIR).
 | |
| #	BUILDARGS	- Arguments to pass to make(1) when {build,install}ing.
 | |
| #	INSTARGS	- Arguments to pass to make(1) when installing.
 | |
| #	WEBMAILTO	- Address to send mail to if the build fails.
 | |
| #
 | |
| #	subtrees	- List of directores in $BUILDDIR which are from SVN.
 | |
| #
 | |
| # Variables which are in uppercase are derived from the environment
 | |
| # unless they don't exist, in which case a value suitable for
 | |
| # www.FreeBSD.org is used.  Variables in lowercase can't be safely
 | |
| # changed without editing other parts of the script; thus, their value
 | |
| # in the environment is ignored.
 | |
| #
 | |
| # Exit codes:
 | |
| #
 | |
| #	0	- success
 | |
| #	1	- unknown failure
 | |
| #	2	- failure in SVN operations
 | |
| #	3	- failure in make operations
 | |
| #
 | |
| # $FreeBSD$
 | |
| #
 | |
| 
 | |
| #
 | |
| # Default configuration.
 | |
| #
 | |
| DEFAULT_PATH=/bin:/usr/bin:/usr/local/bin;
 | |
| DEFAULT_SVNROOT=svn://svn.FreeBSD.org
 | |
| DEFAULT_BUILDDIR=/usr/local/www/build;
 | |
| #DEFAULT_LOGDIR=/usr/local/www/build/log;
 | |
| DEFAULT_LOGDIR=/usr/local/www/logs/build;
 | |
| DEFAULT_DESTDIR=/usr/local/www;
 | |
| DEFAULT_LOGFILE=webbuild.log
 | |
| DEFAULT_BUILDARGS='';
 | |
| DEFAULT_INSTARGS='';
 | |
| DEFAULT_WEBMAILTO=freebsd-doc;
 | |
| #DEFAULT_WEBMAILTO=simon;
 | |
| #DEFAULT_WEBMAILTO=hrs;
 | |
| 
 | |
| #
 | |
| # Variable setup.
 | |
| #
 | |
| PATH=${PATH:-${DEFAULT_PATH}}; export PATH;
 | |
| SVNROOT=${SVNROOT:-${DEFAULT_SVNROOT}}; export SVNROOT;
 | |
| BUILDDIR=${BUILDDIR:-${DEFAULT_BUILDDIR}};
 | |
| LOGDIR=${LOGDIR:-${DEFAULT_LOGDIR}};
 | |
| DESTDIR=${DESTDIR:-${DEFAULT_DESTDIR}}; export DESTDIR
 | |
| LOGFILE=${LOGFILE:-${LOGDIR}/${DEFAULT_LOGFILE}};
 | |
| BUILDARGS=${BUILDARGS:-${DEFAULT_BUILDARGS}};
 | |
| INSTARGS="${BUILDARGS} ${INSTARGS:-${DEFAULT_INSTARGS}}";
 | |
| WEBMAILTO=${WEBMAILTO:-${DEFAULT_WEBMAILTO}};
 | |
| 
 | |
| # too fragile, see PR: 222488	 
 | |
| export NO_OBJ=YES
 | |
| 
 | |
| # Notes on the names of the release notes directories:
 | |
| #
 | |
| # - They weren't named the same way they will be on the web site
 | |
| # (CURRENT, 11-STABLE) becuase that wouldn't make it obvious that they
 | |
| # were release notes.
 | |
| #
 | |
| # - They weren't named after their path names in the repository
 | |
| # (src/release/doc) because that doesn't play well with branches.
 | |
| #
 | |
| # - The '/doc' part is necessary because of the way doc.subdir.mk finds
 | |
| # ${LANGCODE}.  It strips off the last component of ${.CURDIR} one by
 | |
| # one and compares the last component to 'doc'.  When it finds it, it
 | |
| # assumes that the directory right below that is the language code.
 | |
| # This works fine if all the languages are in a directory called
 | |
| # 'doc', and not at all if they aren't.
 | |
| subtrees='head src/share/man/man4
 | |
| relnotes11/doc relnotes11/man4
 | |
| relnotes10/doc relnotes10/man4
 | |
| ports';
 | |
| 
 | |
| #
 | |
| # Update the checked out copies.  Check out new copies every Sunday or
 | |
| # if they don't exist.
 | |
| #
 | |
| 
 | |
| # Only create $BUILDDIR if the directory right above it exists.
 | |
| cd `dirname $BUILDDIR` || exit 1;
 | |
| if [ ! -d $BUILDDIR ]; then
 | |
| 	mkdir $BUILDDIR;
 | |
| fi
 | |
| umask 002
 | |
| cd $BUILDDIR || exit 1;
 | |
| 
 | |
| # We use newsyslog now...
 | |
| mkdir -p $LOGDIR
 | |
| 
 | |
| buildstart=`date +%s`
 | |
| echo Build started `date` >> ${LOGFILE}
 | |
| 
 | |
| # XXX If one of the directories in $subtrees doesn't exist, *all* of
 | |
| # them will be wiped and checked out again.  This should only happen
 | |
| # if something went terribly wrong, or if there's a new entry in
 | |
| # $subtrees, so I (dd) don't plan on fixing it; there's no sense in
 | |
| # optimizing something that should only happen twice a year (if that).
 | |
| #cond="X`date '+%u'` = X7 `echo $subtrees | sed -E 's/([^ ]*)/-o ! -d \1/g'`";
 | |
| cond="-e $BUILDDIR/fullbuild-clean.flag `echo $subtrees | sed -E 's/([^ ]*)/-o ! -d \1/g'`";
 | |
| if [ $cond ]; then
 | |
| 	# Remove the old copies.
 | |
| 	rm -Rf $subtrees 2>/dev/null;
 | |
| 	chflags -R noschg $subtrees 2>/dev/null;
 | |
| 	rm -Rf $subtrees 2>/dev/null;
 | |
| 
 | |
| 	# Check out the new copies.  This creates all the $subtrees.
 | |
| 	svn co $SVNROOT/doc/head head >> $LOGFILE 2>&1 || exit 2;
 | |
| 
 | |
| 	test -d relnotes || mkdir relnotes;
 | |
| 	mkdir -p src/share/man/man4
 | |
| 	svn co $SVNROOT/base/head/share/man/man4 src/share/man/man4 >> $LOGFILE 2>&1 || exit 2;
 | |
| 	svn co $SVNROOT/base/stable/11/release/doc relnotes11/doc >> $LOGFILE 2>&1 || exit 2;
 | |
| 	svn co $SVNROOT/base/stable/11/share/man/man4 relnotes11/man4 >> $LOGFILE 2>&1 || exit 2;
 | |
| 	svn co $SVNROOT/base/stable/10/release/doc relnotes10/doc >> $LOGFILE 2>&1 || exit 2;
 | |
| 	svn co $SVNROOT/base/stable/10/share/man/man4 relnotes10/man4 >> $LOGFILE 2>&1 || exit 2;
 | |
| 	svn co --depth immediates $SVNROOT/ports/head ports >> $LOGFILE 2>&1 || exit 2
 | |
| 	svn up --set-depth infinity ports/Mk >> $LOGFILE 2>&1 || exit 2
 | |
| 	rm -f $BUILDDIR/fullbuild-clean.flag
 | |
| else
 | |
| 	for dir in ${subtrees}; do
 | |
| 		svn cleanup $dir >> $LOGFILE 2>&1 || exit 2;
 | |
| 		svn update --accept theirs-full $dir >> $LOGFILE 2>&1 || exit 2;
 | |
| 	done
 | |
| fi
 | |
| 
 | |
| if [ ! -e "${PINDEX_OVERRIDE}" ]; then
 | |
| 	[ -e ${PORTSDIR}/INDEX-${INDEXNUM} ] && rm -f ${PORTSDIR}/INDEX-${INDEXNUM}
 | |
| 	make -C ${PORTSDIR} fetchindex >> $LOGFILE 2>&1 || exit 2
 | |
| fi
 | |
| 
 | |
| #
 | |
| # Build the web site.
 | |
| #
 | |
| cd $BUILDDIR/head || exit 1;
 | |
| 
 | |
| # get latest revision
 | |
| LATESTREVISION=$LOGDIR/LATESTREVISION
 | |
| make -C en_US.ISO8859-1/articles/pam/ SRCS="$(pwd)" -V LATESTREVISION | \
 | |
|   sed -E 's/--stringparam[ ]+/!/g' | tr '!' '\n' > $LATESTREVISION
 | |
| 
 | |
| time make ${BUILDARGS} p-all >> $LOGFILE 2>&1 ||
 | |
| 	(cat $LATESTREVISION >> $LOGFILE
 | |
| 	 tail -50 $LOGFILE | mail -s "FreeBSD web build failed on `hostname`" $WEBMAILTO;
 | |
| 	 exit 3) || exit 3;
 | |
| 
 | |
| cd $BUILDDIR/head/en_US.ISO8859-1/htdocs || exit 1;
 | |
| 
 | |
| ( time make ${INSTARGS} -j8 all && time make ${INSTARGS} install ) >> $LOGFILE 2>&1 ||
 | |
| 	(cat $LATESTREVISION >> $LOGFILE
 | |
| 	 tail -50 $LOGFILE |
 | |
| 	 mail -s "FreeBSD web build failed on `hostname`" $WEBMAILTO;
 | |
| 	 exit 3) || exit 3;
 | |
| 
 | |
| if [ "X${PUBDIR}" != "X" ]; then
 | |
| 	/usr/local/bin/rsync ${RSYNC_FLAGS} ${DESTDIR}/ ${PUBDIR} \
 | |
| 		>> ${LOGFILE} 2>&1
 | |
| fi
 | |
| 
 | |
| cat $LATESTREVISION >> ${LOGFILE}
 | |
| buildstop=`date +%s`
 | |
| buildd=$(($buildstop - $buildstart))
 | |
| echo "Build ended `date` (${buildd}s)" >> ${LOGFILE}
 | |
| 
 | |
| exit 0;
 |