Tuning in to a CWS

From Apache OpenOffice Wiki
Jump to: navigation, search
Book-old.png    This article is outdated.    
Documentation caution.png This is a procedure for legacy CVS and won't work with SVN! With SVN the entire module hierarchy corresponds to some branch or CWS. SVN provides the switch subcommand to tune into a CWS.

Method and script to tune in to an already existing CWS based on a specific milestone that's already built.

If you just want to build a CWS and don't need the milestone build for other purposes or CWSs based on it, there is a much simpler method that checks out the milestone and updates modules with the CWS branch, see Getting It: Checking out a CWS through CVS

Introduction

This method here is especially useful when working on multiple CWSs based on the same milestone, saving disk space and build time. It also serves when working on just one CWS, to be able to compare differences between the unmodified master's environment and installation and the modifications done in the CWS. It comes also handy if you already have a milestone build and want to tune in to a CWS based on that milestone.

The method needs a full master build of the milestone, but for the CWS build only copies of the modules added to the CWS are needed, modules not added to the CWS are created as symbolic links to the master build, effectively saving 4GB of disk space and hours of build time for each subsequent CWS based on the same milestone master. The method takes advantage of a build tool feature that skips .lnk directory entries (see solenv/bin/build.pl for reference). It is heavily inspired by a feature of the cwscreate tool that does almost the same in Sun Microsystem's Hamburg labs where a series of recent milestone builds is kept to branch off and resync to, but due to fixed directory structures not being available in personal plain OOo checkout builds is not available there (see solenv/bin/cwscreate.pl for reference). cwscreate also does this only during creation of a CWS, not offering the "tune in to existing CWS" method introduced here.

Prerequisites

To make things work some prerequisites have to be met:

  • The CWS does not introduce binary incompatible changes that would affect modules that are not added to the CWS. To be exact, it would work if at the end you manually removed the symbolic links of affected modules and copied the modules from the master to the CWS build tree, omitting the output directories respectively removing them from the copy. This is error prone though. The script checks if the CWS in EIS has modules marked as being incompatible and ceases to continue if that is the case.
  • The milestone master build tree must reside in and had been configured for a directory hierarchy that ends in /$WORK_STAMP/something because in the CWS environment's LinuxX86Env.Set* /$WORK_STAMP/ will be replaced with /$CWS_WORK_STAMP/$WORK_STAMP/ for CWS relevant directories like solver and such, using a dumb sed expression. The actual value of something doesn't matter, however, it is recommended to use something that corresponds to the milestone, e.g. src.m239, to keep things distinct. For example: the milestone build tree resides in $HOME/ooo/src/SRC680/src.m239, with /SRC680/ being the important part. The script does check this.
  • OOo must had been built up to at least module postprocess and delivered, install sets are not necessary, they can be created from within the CWS. However, they're good to have to compare the milestone with changes done in the CWS later. The script does check this.
    Be aware though that when later using the dmake openoffice_en-US PKGFORMAT=installed command in instsetoo_native/util to create an install set, either the build command must had been run once previously in instsetoo_native or a dmake command been issued in instsetoo_native/packimages, otherwise the images*.zip files will be missing. So easiest is to run build --all in instsetoo_native before tuning in to the CWS.
  • The corresponding LinuxX86Env.Set.sh is sourced. The script does check (parts of) this.
  • The CWS_WORK_STAMP environment variable is set to the name of the CWS. The script does check this.
  • $HOME/.cwsrc with good values, see cws config file. The script does not check this but cwsquery will fail and the script does check that.
  • CVS tunnel must be up if the script's $myCvsId variable is not empty. The script does not check this.

Basically fulfilling the prerequisites means (untested, there may be typos and quirks lurking)

mkdir -p $HOME/ooo/src/SRC680/src.m239
cd $HOME/ooo/src/SRC680/src.m239
cvs -d :pserver:anoncvs@anoncvs.services.openoffice.org:/cvs co -P -r SRC680_m239 OpenOffice2
cd config_office
./configure
cd ..
./bootstrap
source LinuxX86Env.Set.sh
cd $SRC_ROOT/instsetoo_native
build --all
export CWS_WORK_STAMP=cwsname

Fire up CVS tunnel if appropriate.

The Script

The tune_in_to_cws bash script:

#!/bin/bash
# Start working on a CWS, e.g. based on SRC680_m239 milestone, linking all
# non-cws module directories. For details see
# http://wiki.services.openoffice.org/wiki/Tuning_in_to_a_CWS
 
# To make things work, the milestone build tree MUST had been configured for a
# directory hierarchy that ends in /$WORK_STAMP/something, e.g. /SRC680/src
 
# ADAPT THESE VARIABLES TO YOUR NEEDS:
# myCvsId: Obviously the CVS id you have commit right with. Used to update the
# CVS/Root files copied from CWS modules with your tunnel. If this is set
# empty, CVS/Root files are left untouched. It is a good idea to checkout the
# milestone using anoncvs to not accidentally commit anything, hence this
# procedure.
myCvsId=""
# myCvsTunnel: The line that is written to CVS/Root files if myCvsId is not
# empty. The tunnel must be up and running if myCvsId is not empty!
myCvsTunnel=":pserver:$myCvsId@localhost:/cvs"
# myBaseDir: The CWS build tree is created as
# $myBaseDir/$CWS_WORK_STAMP/$WORK_STAMP/src$UPDMINOREXT
myBaseDir="$HOME/ooo/src"
# UPDMINOREXT: You may set this to anything you like. However, it is a good
# idea to make it correspond to the milestone your CWS is based on, since that
# leaves the old tree accessible after a resync and an upgrade to a newer
# milestone when working on a fresh tree. Not set if preset in the current
# environment, but ovrerridden if myAdaptExtToCurrent is not empty, see there.
test "$UPDMINOREXT" || UPDMINOREXT=".m239"
# myAdaptExtToCurrent: If not empty, UPDMINOREXT will be overridden with
# ".$(cwsquery current)"
myAdaptExtToCurrent="Yes"
 
# myCopySolenvAndImages: The solenv and *_images modules are needed without
# .lnk extension. For safety, to not get in the way of the master when building
# the CWS or vice versa, or when doing an incompatible build later, they are
# copied to the CWS. When myCopySolenvAndImages is set empty they are linked
# instead of copied. If they are part of the CWS they are handled differently
# anyway and will be copied, no matter how myCopySolenvAndImages is setup.
myCopySolenvAndImages="Yes"
 
# myOmitOutputDirs: Whether output directories are to be omitted from the CWS
# copy and you have to rebuild the CWS modules. You may set this to empty if
# and only if you are absolutely sure that the CWS does not have intermodule
# dependencies.
myOmitOutputDirs="Yes"
 
# Run this script and if everything went fine:
#
# cd $myBaseDir/$CWS_WORK_STAMP/$WORK_STAMP/src$UPDMINOREXT
# # !!! ATTENTION !!! You MUST source the newly created environment!
# source LinuxX86Env.Set.sh
# cd $SRC_ROOT/postprocess
# build --all
# cd $SRC_ROOT/instsetoo_native/util
# dmake openoffice_en-US PKGFORMAT=installed
#
# You then have a working installation in
# $myBaseDir/$CWS_WORK_STAMP/$WORK_STAMP/inst$UPDMINOREXT
 
myEnvNotSet='not set, source LinuxX86Env.Set.sh environment!'
myDidntWork='did not work, bailing out!'
test "$SRC_ROOT" || { echo "\$SRC_ROOT $myEnvNotSet"; exit 1; }
test "$WORK_STAMP" || { echo "\$WORK_STAMP $myEnvNotSet"; exit 1; }
echo "$SRC_ROOT" | grep "/$WORK_STAMP/"
if [ $? -ne 0 ]; then
    echo "/\$WORK_STAMP/ (/$WORK_STAMP/) not in \$SRC_ROOT ($SRC_ROOT)."
    exit 1
fi
test "$INPATH" || { echo "\$INPATH $myEnvNotSet"; exit 1; }
test "$OUTPATH" || { echo "\$OUTPATH $myEnvNotSet"; exit 1; }
if [ ! -f "$SRC_ROOT/postprocess/$INPATH/bin/uiconfig.zip" ]; then
    echo "$SRC_ROOT/postprocess/$INPATH/bin/uiconfig.zip doesn't exist, milestone master probably not built."
    exit 1
fi
test "$CWS_WORK_STAMP" || { echo '$CWS_WORK_STAMP not set, export CWS_WORK_STAMP=cwsname'; exit 1; }
myModules="$(cwsquery modules)"
if [ $? -ne 0 ]; then
    echo 'cwsquery modules unsuccessful, ~/.cwsrc bad or EIS not reachable.'
    exit 1
fi
echo "Modules: $myModules"
myIncompatible="$(cwsquery incompatible)"
if [ $? -ne 0 ]; then
    echo 'cwsquery incompatible unsuccessful.'
    exit 1
fi
if [ "$myIncompatible" != "" ]; then
    echo "Incompatible module(s) $myIncompatible"
    echo "This probably won't work with linked master modules."
    exit 1
fi
 
if [ "$myAdaptExtToCurrent" != "" ]; then
    UPDMINOREXT=".$(cwsquery current)"
    if [ $? -ne 0 ]; then
        echo 'cwsquery current unsuccessful.'
        exit 1
    else
        echo "UPDMINOREXT: $UPDMINOREXT"
    fi
fi
 
myCwsBase="$myBaseDir/$CWS_WORK_STAMP/$WORK_STAMP"
myCwsDir="$myCwsBase/src$UPDMINOREXT"
mkdir -p $myCwsDir
cd $myCwsDir || { echo "Are you sure you have permissions in $myCwsDir where you want to create the CWS tree?"; exit 1; }
for dir in $SRC_ROOT/*; do
    # On subsequent runs do not create module.lnk/module links effectively
    # being $SRC_ROOT/module/module
    myLnk="$(basename "$dir").lnk"
    if [ ! -e "$myLnk" ]; then
        ln -s "$dir" "$myLnk"
    fi
done
rm {LinuxX86Env.Set*,makefile.mk,solver,solenv,*_images,postprocess,instsetoo_native}.lnk
if [ "$myCopySolenvAndImages" != "" ]; then
    cp -auv $SRC_ROOT/{solenv,*_images} "$myCwsDir"
else
    ln -s $SRC_ROOT/{solenv,*_images} "$myCwsDir"
fi
cp -auv $SRC_ROOT/{makefile.mk,solver,postprocess,instsetoo_native} "$myCwsDir"
cp -av $SRC_ROOT/LinuxX86Env.Set* "$myCwsDir"
 
echo "Adapting" LinuxX86Env.Set* "and replacing /$WORK_STAMP/ with /$CWS_WORK_STAMP/$WORK_STAMP/"
for file in LinuxX86Env.Set*; do
    sed --in-place -e "s/\/$WORK_STAMP\//\/$CWS_WORK_STAMP\/$WORK_STAMP\//g" "$file"
done
echo "setenv CWS_WORK_STAMP \"$CWS_WORK_STAMP\"" >>LinuxX86Env.Set
echo "export CWS_WORK_STAMP=\"$CWS_WORK_STAMP\"" >>LinuxX86Env.Set.sh
echo "setenv LOCALINSTALLDIR \"$myCwsBase/inst$UPDMINOREXT\"" >>LinuxX86Env.Set
echo "export LOCALINSTALLDIR=\"$myCwsBase/inst$UPDMINOREXT\"" >>LinuxX86Env.Set.sh
 
# Copy CWS modules from milestone.
for dir in $myModules; do
    rm "$dir.lnk"
    # May be linked solenv or *_images
    if [ -h "$dir" ]; then
        rm "$dir"
    fi
    if [ "$myOmitOutputDirs" == "" ]; then
        cp -av "$SRC_ROOT/$dir" "$myCwsDir"
        test $? -eq 0 || { echo "cp -av $SRC_ROOT/$dir $myCwsDir  $myDidntWork"; exit 1; }
    else
        echo "Omitting output directories $SRC_ROOT/$dir/{$OUTPATH,$INPATH} (myOmitOutputDirs not empty)"
        mkdir -p "$myCwsDir/$dir"
        for sub in "$SRC_ROOT/$dir"/*; do
            if [ "$sub" != "$SRC_ROOT/$dir/$OUTPATH" -a "$sub" != "$SRC_ROOT/$dir/$INPATH" ]; then
                cp -av "$sub" "$myCwsDir/$dir"
                test $? -eq 0 || { echo "cp -av $sub $myCwsDir/$dir  $myDidntWork"; exit 1; }
            fi
        done
    fi
done
 
# From here on everything uses the CWS environment!
source LinuxX86Env.Set.sh
 
for dir in $myModules; do
    echo "Undelivering module $dir from solver."
    pushd "$dir"
    # The deliver command actually is an alias and would not work here. Emulate.
    perl $SOLARENV/bin/$DELIVER -delete
    popd
done
if [ "$myCvsId" != "" ]; then
    # In case milestone was checked out using anoncvs:
    echo "Changing CVS/Root files of CWS modules to $myCvsTunnel"
    for dir in $myModules; do
        echo "Module $dir"
        for file in $(find "$dir" -name Root | grep '/CVS/Root'); do
            echo "$myCvsTunnel" >"$file"
            test $? -eq 0 || { echo "echo $myCvsTunnel >$file  $myDidntWork"; exit 1; }
        done
    done
fi
myAllExit=0
# Update modules with CWS branch, all lower case tag.
myBranch="$(echo cws_${WORK_STAMP}_${CWS_WORK_STAMP}|tr A-Z a-z)"
for dir in $myModules; do
    echo "CVS updating module $dir with $myBranch"
    pushd "$dir"
    cvs update -dP -r $myBranch
    myExit=$?
    if [ $myExit -ne 0 ]; then
        echo "Warning, $dir cvs update returned with exit code $myExit"
        myAllExit=$myExit
    fi
    popd
done
if [ $myAllExit -ne 0 ]; then
    echo "Warning, at least one cvs update returned with exit code $myAllExit"
fi
echo ''
echo '# And now:'
echo "cd $myCwsDir"
echo 'source LinuxX86Env.Set.sh'
echo '# !!! ATTENTION !!! You MUST source the newly created environment for the CWS!'

Epilogue

Run the tune_in_to_cws script and if everything went fine:

cd $myBaseDir/$CWS_WORK_STAMP/$WORK_STAMP/src$UPDMINOREXT
# !!! ATTENTION !!! You MUST source the newly created environment, or else
# you will spoil the milestone solver when delivering files from the CWS!
source LinuxX86Env.Set.sh
cd $SRC_ROOT/postprocess
build --all
cd $SRC_ROOT/instsetoo_native/util
dmake openoffice_en-US PKGFORMAT=installed

You then have a working installation in $myBaseDir/$CWS_WORK_STAMP/$WORK_STAMP/inst$UPDMINOREXT as this script adds LOCALINSTALLDIR $myBaseDir/$CWS_WORK_STAMP/$WORK_STAMP/inst$UPDMINOREXT to LinuxX86Env.Set* to create CWS installs within the CWS hierarchy, see also http://blogs.sun.com/GullFOSS/entry/the_fastest_way_to_get

After having tuned in the CWS, do not modify files on the master under solenv/ or the *_images/ modules that are linked from the CWS to the master if not part of the CWS, as building from within the CWS would build and deliver those to the CWS' solver. Modify the script to copy those directories if this somehow is likely to confuse your working habits.

Personal tools