#!/bin/sh -
#	$Id: script,v 1.1.1.1.2.2 2000/02/08 00:44:19 noriko Exp $
#
# Build the distribution archives.
#
# A set of commands intended to be cut and pasted into a csh window.

# Development tree, release home.
setenv D /a/db

# Update the release number.
cd $D/dist
vi RELEASE
cvs commit RELEASE
setenv VERSION \
`sh -c '. RELEASE; echo $DB_VERSION_MAJOR.$DB_VERSION_MINOR.$DB_VERSION_PATCH'`
echo "Version: $VERSION"

# Run a full configuration.
cd $D/dist && sh s_all

# Build the documentation.
cd $D/docs_src && make clean
cd $D/docs_src && make
cd $D/docs_src && make && make check

# Make sure the development tree is up-to-date and there are no random
# files that shouldn't be there.
cd $D && cvs -q update

# Copy a development tree into a release tree.
setenv R /a/db-$VERSION
rm -rf $R && mkdir -p $R
cd $D && tar cf - \
`cvs -q status | sed -n -e "/Repository/s;.*/CVSROOT/db/;;" -e "s/,v//p"` | \
(cd $R && tar xpf -)

# Fix symbolic links and permissions.
cd $R/dist && sh s_perm
cd $R/dist && sh s_symlink

# Build the documents.
cd $R/docs_src && make

# Build a version.
cd $R && rm -rf build_run && mkdir build_run
cd $R/build_run && ~bostic/bin/dbconf && make >& mklog
make ex_{access,btrec,env,lock,mpool,thread,tpcb} >>& mklog
make {getcwd,getopt,memcmp,memcpy,memmove,raise}.lo >>& mklog
make {snprintf,strerror,vsnprintf}.lo >>& mklog
vi mklog

# Smoke test.
./ex_access

# Check the install
make prefix=`pwd`/BDB install

# Run distribution check scripts
$R/dist/build/chk.def
$R/dist/build/chk.offt

# Clean up the tree.
cd $R && rm -rf build_run docs_src
cd $R && rm -rf test_thread test_server test/upgrade/databases
cd $R && mkdir test/upgrade/databases

# ACQUIRE ROOT PRIVILEGES
cd $R && find . -type d | xargs chmod 775
cd $R && find . -type f | xargs chmod 444
cd $R/dist && sh s_perm
chown -R bin.wsrc $R
# DISCARD ROOT PRIVILEGES

# Compare this release with the last one.
cd $R/.. && gzcat LAST_RELEASE | tar xf -
cd $R/../LAST_RELEASE && find . | sort > /tmp/__OLD
cd $R && find . | sort > /tmp/__NEW
# File changes.
diff -c /tmp/__OLD /tmp/__NEW

# Create the release.
setenv T "$R/../db-$VERSION.tar.gz"
cd $R/.. && tar cf - db-$VERSION | gzip --best > $T
chmod 444 $T

setenv T "$R/../db-$VERSION.zip"
cd $R/.. && zip -r - db-$VERSION > $T
chmod 444 $T
