Andreas Klemm on Sat, 29 Dec 2001 22:02:13 +0100 (CET)(envelope-from owner-apsfilter-cvs@apsfilter.org)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

cvs commit: www Makefile www/scripts make-release


andreas     2001/12/29 22:02:09 CET

  Modified files:
    .                    Makefile 
  Log:
  - update apsfilter stable release to 7.1.1
  - make-release script: added "else" clause:
    if no patches available then
  	patchfile="no patches available"
  	patchpath=""
    This fixes "bytes" bug, now we always get 0 bytes !
  
  #! /bin/sh
  
  # $ApsCVS: www/scripts/make-release,v 1.98 2001/12/29 14:19:08 andreas Exp $
  
  #
  # copyright 1999-2000 Andreas Klemm <andreas@apsfilter.org>
  #
  
  umask 002
  
  #
  # make-release
  #	- create apsfilter -STABLE releases and patches
  #	- create -CURRENT snapshots
  #	- create apsfilter download page (WML source)
  #
  # uses several make environment variables,
  # which can be overwritten in /etc/make.conf:
  #
  #	APSWWWDEST	- webserver root
  #	APSARCHIVE	- not yet implemented
  #	APSWWWOWN	- file owner (default: andreas)
  #	APSWWWGRP	- file group (default: apsfilter)
  #	APSWWWMODE	- file mode  (default: 664)
  #	CVS		- path to cvs wrapper script
  #	APSCVS		- root of local apsfilter CVS repository
  #	STABLE_RELEASE	- apsfilter-stable release (default: 7.0.1)
  #	STABLE_BRANCH	- apsfilter-stable branch (default: RELENG_7)
  #	CURRENT_RELEASE	- apsfilter-current release (default: current)
  #	CURRENT_BRANCH	- apsfilter-current branch (default: HEAD)
  
  # coding conventions:
  #
  #	GLOBAL		- global variable in uppercase
  #	local		- local  variable in lowercase
  #
  
  ############################################################
  # Begin of configuration section
  
  # For debugging purposes
  
  #DEBUG=yes		# report in what function we are
  #NOEXEC=echo		# don't execute commands
  #set -x			# enable debugging in shell
  
  # End of configuration section
  ############################################################
  
  #
  # environment variables (from make environment)
  # - defaults are for for www.apsfilter.org
  # - predefined in mk/bsd.wml.mk
  # - overwriteable for tests in /etc/make.conf
  #
  
  # path to web server root
  APSWWWDEST=${APSWWWDEST:=/var/www/www.apsfilter.org/htdocs}
  
  # default download dir on www.apsfilter.org if not set
  APSDOWNLOAD=${APSDOWNLOAD:=${APSWWWDEST}/download}
  
  # XXX not yet implemented
  # archive directory where every apsfilter release and official release diffs
  # will be archived (except -current SNAPSHOTS)
  #APSARCHIVE=${APSARCHIVE:=/var/home/andreas/apsarchive}
  
  # permissons
  APSWWWOWN=${APSWWWOWN:=andreas}
  APSWWWGRP=${APSWWWGRP:=apsfilter}
  APSWWWMODE=${APSWWWMODE:=664}
  
  ##
  ## EOF (environment variables from make environment)
  ##
  
  # default apsfilter stable version and branch if not set
  STABLE_RELEASE=${STABLE_RELEASE:=7.0.1}
  STABLE_BRANCH=${STABLE_BRANCH:=RELENG_7}
  
  # default apsfilter developement version and branch if not set
  CURRENT_RELEASE=${CURRENT_RELEASE:=current}
  CURRENT_BRANCH=${CURRENT_BRANCH:=HEAD}
  
  # path to cvs wrapper script, which is SUID apscvs:apscvs
  CVS=${CVS:=/var/apscvs/bin/cvs}
  
  # default CVROOT on www.apsfilter.org if not set
  APSCVS=${APSCVS:=/var/apscvs/APSCVS}
  
  # apsfilter download startpage name
  # this is in wml language
  INDEXWML=download.wml
  
  # release specific files will be copied to $APSDOWNLOAD as $file-$REL
  INFOFILES="ANNOUNCE ChangeLog INSTALL KNOWN_BUGS README"
  
  # compression methods
  COMPRESS_METHOD="gzip bzip2"
  
  # install command
  INSTALL_FILE="install -C -p -o $APSWWWOWN -g $APSWWWGRP -m $APSWWWMODE"
  
  # date string used to create unique filenames for diffs
  #DATE="`date +%d.%m.%Y-%H:%M:%S`"
  #DATE="`date +%d.%m.%Y-%H:%M`"
  DATE="`date +%d.%m.%Y`"
  
  # save WRKDIR
  WRKDIR="`pwd`"
  
  # cleanup if we get termination signal
  trap 'echo "+++ cleaning up..."; $NOEXEC rm -rf "$TMPDIR"' EXIT
  trap 'exit 255' SIGINT SIGTRAP SIGBUS SIGUSR1 SIGUSR2 SIGTERM
  
  check_destdirs()
  {
  	# no special working directory
  
  	if [ -n "$DEBUG" ]; then
  		echo "debug: in check_destdirs"
  	fi
  
  	if [ ! -d $APSWWWDEST ]; then
  		echo "$APSWWWDEST is missing"
  		exit 1
  	fi
  	if [ ! -d $APSDOWNLOAD ]; then
  		echo "$APSDOWNLOAD is missing"
  		exit 1
  	fi
  
  	return
  }
  
  create_tmp_dir()
  {
  	# no special working directory
  
  	if [ -n "$DEBUG" ]; then
  		echo "debug: in create_tmp_dir"
  	fi
  
  	TMPDIR=`mktemp -d 2>/dev/null /tmp/make-release.XXXXXX`
  	if [ $? -ne 0 ]; then exit 255; fi
  
  	return
  }
  
  get_tmp_diff_name()
  {
  	# no special working directory
  
  	if [ -n "$DEBUG" ]; then
  		echo "debug: in get_tmp_diff_name"
  	fi
  
  	TMPDIFF=`mktemp 2>/dev/null /tmp/make-release.diff.XXXXXX`
  	if [ $? -ne 0 ]; then exit 255; fi
  
  	return
  }
  
  rm_old_current_snaps()
  {
  	# no special working directory
  
  	if [ -n "$DEBUG" ]; then
  		echo "debug: in rm_old_current_snaps"
  	fi
  
  	$NOEXEC rm -f $APSDOWNLOAD/*apsfilter-current*
  
  	return
  }
  
  install_file()
  {
  	# no special working directory
  	# changes to $APSDOWNLOAD to create md5 file entries without paths
  
  	if [ -n "$DEBUG" ]; then
  		echo "debug: in install_file"
  	fi
  
  	local basename chksum file status
  	file=$1			# complete path !
  	status=$2		# "missing", "changed"
  	chksum=$3		# "md5" or "no_md5"
  
  	basename=`basename $file`
  
  	# install file in apsdownload dir
  	echo ">>> installing $status $basename"
  	$NOEXEC $INSTALL_FILE $file $APSDOWNLOAD
  
  	if [ "$chksum" = "md5" ]; then
  		# change working directory
  		# create md5 file without path in name
  		$NOEXEC cd $APSDOWNLOAD || exit 1
  		$NOEXEC md5 $basename > $basename.md5
  	fi
  
  	unset basename chksum file status
  	return
  }
  
  check_file()
  {
  	# no special working directory
  
  	if [ -n "$DEBUG" ]; then
  		echo "debug: in check_file"
  	fi
  
  	local basename branch chksum file
  	file=$1			# complete path !
  	branch=$2		# branch (HEAD, ..)
  	chksum=$3		# "md5" or "no_md5"
  
  	basename=`basename $file`
  
  	if [ ! -f $APSDOWNLOAD/$basename ]; then
  
  		# case 1: file not present -> install
  		install_file $file missing $chksum
  
  	else
  
  		# case 2: archive present, check for differences
  		cmp -s $file $APSDOWNLOAD/$basename
  
  		# exit status = 1 -> files differ
  		if [ $? -eq 1 ]; then
  
  			if [ "$branch" = "HEAD" ]; then
  				# now we have to clean all old snaps
  				rm_old_current_snaps
  			fi
  
  			install_file $file changed $chksum
  		else
  			echo "    keep unchanged $basename"
  		fi
  
  	fi
  
  	unset basename branch chksum file
  	return
  }
  
  create_rel_diff()
  {
  	# special working directories
  	# 1. create TMPDIR and cd $TMPDIR, checkout -STABLE or HEAD branch
  	# 2. remove TMPDIR
  	# 3. create new TMPDIR and cd $TMPDIR, checkout -STABLE, create diffs
  
  	if [ -n "$DEBUG" ]; then
  		echo "debug: in create_rel_diff"
  	fi
  
  	local archname branch compress i patchfile patchpath
  	local reltag relunder suff version
  
  	version=$1			# i.e.: 5.4.2, current
  	branch=$2			# i.e.: RELENG_5, HEAD
  
  	create_tmp_dir			# get TMPDIR
  	$NOEXEC cd $TMPDIR || exit 1
  
  	if [ "$branch" = "HEAD" ]; then
  		reltag=HEAD
  		archname=apsfilter-${version}-${DATE}
  	else
  		relunder=`echo $version | tr '.' '_'`
  		reltag=RELENG_${relunder}_RELEASE
  		archname=apsfilter-$version
  	fi
  
  	echo "+++ rolling apsfilter release $archname"
  
  	echo "--- export apsfilter ..."
  	$NOEXEC $CVS -Q -d $APSCVS export -r $reltag apsfilter
  
  	# create the tar archive with correct timestamp (ChangeLog is reference)
  	echo "--- create tar archive ... "
  	$NOEXEC tar cf $archname.tar apsfilter
  	$NOEXEC touch -r apsfilter/ChangeLog $archname.tar
  
  	# install missing or update changed tar archives
  	for i in $COMPRESS_METHOD
  	do
  		case $i in
  			gzip)	compress="gzip -9"
  				suff=gz
  				;;
  			bzip2)	compress=bzip2
  				suff=bz2
  				;;
  		esac
  
  		# make sure to have correct working directory after check_file()
  		$NOEXEC cd $TMPDIR || exit 1
  
  		# create compressed tar archive
  		$NOEXEC $compress < $archname.tar > $archname.tar.$suff
  		# create timestamp from ChangeLog file
  		$NOEXEC touch -r apsfilter/ChangeLog $archname.tar.$suff
  
  		# check if installation is needed and create md5 file
  		check_file $TMPDIR/$archname.tar.$suff $branch md5
  	done
  
  	# update files to last -STABLE (not for HEAD)
  	if [ "$reltag" != "HEAD" ]; then
  
  		$NOEXEC rm -rf $TMPDIR/apsfilter
  
  		# make sure to have correct working directory after check_file()
  		$NOEXEC cd $TMPDIR || exit 1
  
  		echo "--- checkout apsfilter branch $branch ..."
  		$NOEXEC $CVS -Q -d $APSCVS checkout -r $branch -P apsfilter
  	fi
  
  	# install INFOFILES
  	echo "--- check/install $branch infofiles ..."
  	for file in $INFOFILES
  	do
  		if [ ! -f $DOWNLOAD_DIR/${file}-${version} ]; then
  
  			# we have to copy the file to $TMPDIR otherwise
  			# check_file won't work properly !
  			# check if installation is needed, do NOT create md5
  			$NOEXEC cp -p $TMPDIR/apsfilter/$file \
  					$TMPDIR/$file-$version
  			check_file $TMPDIR/$file-$version $branch no_md5
  		fi
  	done
  
  	# cleanup temporary export directory
  	$NOEXEC rm -rf $TMPDIR
  
  	create_tmp_dir			# get TMPDIR
  	$NOEXEC cd $TMPDIR || exit 1
  
  	get_tmp_diff_name		# get TMPDIFF
  
  	# create diffs only for branches != HEAD, -current is snapshot release
  	if [ "$branch" != "HEAD" ]; then
  		# checkout
  		$NOEXEC $CVS -Q -d $APSCVS checkout -r $branch -P apsfilter
  
  		# enter directory
  		$NOEXEC cd $TMPDIR/apsfilter || exit 1
  
  		echo "--- creating diff $version $branch"
  		$NOEXEC $CVS -d $APSCVS rdiff -u --new-file \
  			-r $reltag -r $branch \
  			> $TMPDIFF 2> /dev/null
  
  		# if $TMPDIFF contains data, we have a patch
  		if [ -s "$TMPDIFF" ]; then
  
  			patchfile=apsfilter-diff-${version}-${DATE}.gz
  			patchpath=$TMPDIR/$patchfile
  
  			# adjust timestamp before compressing
  			$NOEXEC touch -r ChangeLog $TMPDIFF
  			$NOEXEC gzip -9 $TMPDIFF || exit 1
  			# adjust timestamp after compressing
  			$NOEXEC touch -r ChangeLog $TMPDIFF.gz
  
  			# move the tmp patch file to tmp directory
  			$NOEXEC mv $TMPDIFF.gz $patchpath || exit 1
  
  			# check if installation is needed, create md5 file
  			check_file $patchpath $branch md5
  		else
  			patchfile="no patches available"
  			patchpath=""
  		fi
  	fi
  
  	# cleanup temporary apsfilter branch directory
  	$NOEXEC rm -rf $TMPDIR
  
  	# update webpage
  	if [ "$branch" != "HEAD" ]; then
  		$NOEXEC cat >> $WRKDIR/$INDEXWML <<- !EOM
  		<linkgroup name="Apsfilter Production (STABLE) Release">
  		<aps-download-entry
  			gz_name="$archname.tar.gz"
  			gz_md5_name="$archname.tar.gz.md5"
  			bz2_name="$archname.tar.bz2"
  			bz2_md5_name="$archname.tar.bz2.md5"
  			patch_name="$patchfile"
  			ANNOUNCE_name="ANNOUNCE-$version"
  			ChangeLog_name="ChangeLog-$version"
  			INSTALL_name="INSTALL-$version"
  			KNOWN_BUGS_name="KNOWN_BUGS-$version"
  			README_name="README-$version"
  		>
  		<STABLE_comment>
  		<p><a href="http://www.apsfilter.org/docs/apsfilter-handbook-stable.html">Handbook (stable release)</a>
  		<p><a href="http://www.apsfilter.org/cgi-bin/cvsweb.cgi/src/apsfilter/?cvsroot=apsfilter&only_with_tag=${STABLE_BRANCH}">CVS Repository ${STABLE_BRANCH} branch</a>
  		</aps-download-entry>
  		</linkgroup>
  		!EOM
  	else
  		$NOEXEC cat >> $WRKDIR/$INDEXWML <<- !EOM
  		<linkgroup name="Apsfilter Developement (SNAPSHOT) Release">
  		<aps-download-entry
  			gz_name="$archname.tar.gz"
  			gz_md5_name="$archname.tar.gz.md5"
  			bz2_name="$archname.tar.bz2"
  			bz2_md5_name="$archname.tar.bz2.md5"
  			patch_name="none"
  			ANNOUNCE_name="ANNOUNCE-$version"
  			ChangeLog_name="ChangeLog-$version"
  			INSTALL_name="INSTALL-$version"
  			KNOWN_BUGS_name="KNOWN_BUGS-$version"
  			README_name="README-$version"
  		>
  		<HEAD_comment>
  		<p><a href="http://www.apsfilter.org/docs/apsfilter-handbook-current.html">Handbook (developement release)</a>
  		<p><a href="http://www.apsfilter.org/cgi-bin/cvsweb.cgi/src/apsfilter/?cvsroot=apsfilter&only_with_tag=${CURRENT_BRANCH}">CVS Repository ${CURRENT_BRANCH} branch</a>
  		</aps-download-entry>
  		</linkgroup>
  		!EOM
  	fi
  
  	unset archname branch compress i patchfile patchpath
  	unset reltag relunder suff version
  	return
  }
  
  create_webpage_head()
  {
  	if [ -n "$DEBUG" ]; then
  		echo "debug: in create_webpage_head"
  	fi
  
  	$NOEXEC cat > $WRKDIR/$INDEXWML <<- "!EOM"
  		#
  		# download.wml - automatically created by make-release
  		#
  		# Please note: never cvs import this file,
  		# it changes too much and never gets removed by a "make clean".
  		# So please don't do it ;-)
  		#
  		#use wml::tmpl::lbpage file=$(ROOT)/download.html
  		<page_title name="Apsfilter Software Center">
  		<h2>Apsfilter Software Center</h2>
  	!EOM
  }
  
  ############################################################
  #
  # MAIN
  #
  
  # create destination directories
  check_destdirs
  
  # create WML source for startpage
  create_webpage_head
  
  # create apsfilter-STABLE
  create_rel_diff	$STABLE_RELEASE $STABLE_BRANCH
  
  # create apsfilter-current SNAP
  create_rel_diff	$CURRENT_RELEASE $CURRENT_BRANCH
  
  # create trailer, link to cvsweb
  $NOEXEC cat >> $WRKDIR/$INDEXWML <<- !EOM
  	<p>Additional informations:
  	<a
  	  href="http://www.apsfilter.org/cgi-bin/cvsweb.cgi">
  	  Apsfilter CVS repository browser
  	</a>.
  	!EOM
  exit 0
  
  Revision  Changes    Path
  1.58      +2 -2      www/Makefile


  Modified files:
    scripts              make-release 
  Log:
  - update apsfilter stable release to 7.1.1
  - make-release script: added "else" clause:
    if no patches available then
  	patchfile="no patches available"
  	patchpath=""
    This fixes "bytes" bug, now we always get 0 bytes !
  
  Revision  Changes    Path
  1.99      +4 -1      www/scripts/make-release