buildpatch   [plain text]


# $Id: buildpatch,v 12.36 2007/11/15 15:18:33 bostic Exp $
#
# Build the distribution package.
#
# A set of commands intended to be cut-and-pasted into a csh window.
#
# Search for XXX to find places where work is required before running
# the commands, or to find values you need to update in the commands.

# Set the major, minor & patch values
# XXX
setenv MAJOR	4
setenv MINOR	XXX
setenv PATCH	XXX

# Set root directory where we do the work, can be anywhere.
# XXX
setenv D	~/berkeleydb
setenv R	$D/db-${MAJOR}.${MINOR}.${PATCH}

# Remove any previous release tree.
rm -rf $R

# Set the major, minor and patch numbers of the snapshot we're starting with,
# and the locations of the full release archive and the patch to upgrade.
# XXX
setenv ORIG	4.6.19
setenv ARCHIVE	"~ftp/hidden/db-$ORIG.tar.gz"
setenv ARPATCH	"$D/$ORIG.patch"

# Extract from the starting release archive and rename as the release tree.
rm -rf $R.tmp && mkdir $R.tmp && cd $R.tmp &&\
    gzcat $ARCHIVE | tar xf - &&\
    mv -i db-$ORIG $R && cd $R && rm -rf $R.tmp

# Set permissions to allow file modification.
cd $R && find . -type f | xargs chmod 664

# Apply the patch set that moves from the old release to the new one.
cd $R && patch -p0 < $ARPATCH &&\
    find . -name '*.orig' -o -name '*.rej' | xargs rm -f

# Update all of the version numbers in the documentation.
#
# We get most of the version numbers, but don't re-build the Getting Started
# Guide PDF, so its version numbers will be left unchanged.
#
# !!!
# This is obviously unsafe, although the changes of the old version number
# appearing in some piece of documentation and NOT needing to be changed
# are pretty minimal.  That said, each patched release should be compared
# against the original release, and each change vetted to ensure no incorrect
# changes have been made.
cd $R/docs/
find . -name '*.html' > __a
foreach i (`cat __a`)
    cat $i | sed\
    -e "s/>$ORIG</>$MAJOR.$MINOR.$PATCH</g"\
    -e "s/Version $ORIG/Version $MAJOR.$MINOR.$PATCH/g"\
    -e "s/version $ORIG/version $MAJOR.$MINOR.$PATCH/g"\
    -e "s/Version: $ORIG/Version: $MAJOR.$MINOR.$PATCH/g"\
    > __b
    cmp $i __b > /dev/null || cp __b $i
end
rm -rf __a __b

# Update the change log.
#
# XXX
# The Ref Guide change log page should have been updated in the CVS source tree
# to reflect changes between the archival snapshot we started with and the new
# release.  Copy the change log page into place in the docs_src and docs trees,
# from a current CVS tree.
# XXX
setenv CURRENT path-to-current-tree
cd $R && cp \
    $CURRENT/docs_src/ref/changelog/${MAJOR}.${MINOR}.html\
    docs_src/ref/changelog/${MAJOR}.${MINOR}.html
cp docs_src/ref/changelog/${MAJOR}.${MINOR}.html\
    docs/ref/changelog/${MAJOR}.${MINOR}.html

# Update the change log patch number.
cd $R/docs_src/ref/changelog && vi toc.so

# Update the release date (the version has already been updated, but the
# date is wrong).
cd $R && vi docs/index.html

# Update the release number.
cd $R/dist &&\
    (echo "/^DB_VERSION_MAJOR/s/=.*/=$MAJOR/" &&\
     echo "/^DB_VERSION_MINOR/s/=.*/=$MINOR/" &&\
     echo "/^DB_VERSION_PATCH/s/=.*/=$PATCH/" &&\
     echo w &&\
     echo q) | ed RELEASE > /dev/null
setenv VERSION `sh -c '. RELEASE; echo $DB_VERSION'`
echo "Berkeley DB release $VERSION."

# Build auto-generated files.
cd $R/dist && sh s_all

# Remove source directories we don't distribute.
cd $R && rm -rf build_brew_x build_s60_x
cd $R && rm -rf java/src/com/sleepycat/xa
cd $R && rm -rf rpc_server/java
cd $R && rm -rf test/TODO test/upgrade test_erlang test_perf test_purify
cd $R && rm -rf test_rep test_server test_vxworks
cd $R && find . -name '.cvsignore' | xargs rm -f

# Create symbolic links and cscope output, fix permissions.
cd $R/dist && sh s_perm
cd $R/dist && sh s_cscope
cd $R/dist && sh s_symlink

# Build a version and smoke test.
setenv DBCONF	"~db/bin/dbconf thread"
cd $R && rm -rf build_run && mkdir build_run
cd $R/build_run && $DBCONF && make >& mklog
cd $R/build_run && make ex_access && ./ex_access

# Check the install
cd $R/build_run && make prefix=`pwd`/BDB install

# Build a small-footprint version and smoke test.
cd $R && rm -rf build_run && mkdir build_run
cd $R/build_run && ../dist/configure --enable-smallbuild && make >& mklog
cd $R/build_run && make ex_access && ./ex_access

# Remove the build directory
cd $R && rm -rf build_run

# ACQUIRE ROOT PRIVILEGES
cd $R && find . -type d | xargs chmod 775
cd $R && find . -type f | xargs chmod 444
cd $R && chmod 664 build_windows/*.dsp
cd $R/dist && sh s_perm
chown -R 100 $R
chgrp -R 100 $R
# DISCARD ROOT PRIVILEGES

# Check for file names differing only in case.
cd $R && find . | sort -f | uniq -ic | sed '/1 /d'

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

# Check the path length.
gzcat $T | tar tf - |\
awk '{ if (length() > 99) print "Path length: " length() " bytes: " $0;}'

# Create the non-crypto tree.
setenv RNC "$R/../db-$VERSION.NC"
rm -rf $RNC $R/../__TMP && mkdir $R/../__TMP
cd $R/../__TMP && gzcat $T | pax -r && mv -i db-$VERSION $RNC
cd $R && rm -rf $R/../__TMP
cd $RNC/dist && sh s_crypto

# ACQUIRE ROOT PRIVILEGES
cd $RNC && find . -type d | xargs chmod 775
cd $RNC && find . -type f | xargs chmod 444
cd $RNC && chmod 664 build_windows/*.dsp
cd $RNC/dist && sh s_perm
chown -R 100 $RNC
chgrp -R 100 $RNC
# DISCARD ROOT PRIVILEGES

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

# Check the path length.
gzcat $T | tar tf - |\
awk '{ if (length() > 99) print "Path length: " length() " bytes: " $0;}'

# Remove tags files.  They're large and we don't want to store symbolic links
# in the zip archive for portability reasons.
#
# Modify the text files to have Windows end-of-line characters.
# ACQUIRE ROOT PRIVILEGES
cd $R && rm -f `find . -name 'tags'`
cd $RNC && rm -f `find . -name 'tags'`

set t=__tmp
cd $R && awk '{print $0 "\r"}' < LICENSE > $t && cp $t LICENSE && rm -f $t
cd $R && awk '{print $0 "\r"}' < README > $t && cp $t README && rm -f $t
cd $RNC && awk '{print $0 "\r"}' < LICENSE > $t && cp $t LICENSE && rm -f $t
cd $RNC && awk '{print $0 "\r"}' < README > $t && cp $t README && rm -f $t
# DISCARD ROOT PRIVILEGES

# Create the crypto zip archive release.
setenv T "$R/../db-$VERSION.zip"
cd $R/.. && zip -q -r - db-$VERSION > $T
chmod 444 $T

# Create the non-crypto zip archive release.
setenv T "$R/../db-$VERSION.NC.zip"
cd $RNC/.. && zip -q -r - db-$VERSION.NC > $T
chmod 444 $T