Index: cmtpacman/HEAD/HEAD/ChangeLog
===================================================================
--- cmtpacman/HEAD/HEAD/ChangeLog	(revision 53)
+++ cmtpacman/HEAD/HEAD/ChangeLog	(revision 53)
@@ -0,0 +1,14 @@
+2004-11-12  Christian Arnault  <arnault@lal.in2p3.fr>
+
+	* scripts/create_kit.sh: Improve the detection of python_modules
+	scripts jobOptions XML runtime files WRT tempfiles
+
+2004-10-26 Christian Arnault <arnault@lal.in2p3.fr> 2
+
+	* Install the CMT project files into the project kits
+	* Install the production of the source kits
+
+2004-09-13 Christian Arnault <arnault@lal.in2p3.fr> 1
+
+	* First import
+
Index: cmtpacman/HEAD/HEAD/cmt/requirements
===================================================================
--- cmtpacman/HEAD/HEAD/cmt/requirements	(revision 53)
+++ cmtpacman/HEAD/HEAD/cmt/requirements	(revision 53)
@@ -0,0 +1,5 @@
+package cmtpacman
+
+author Christian Arnault <arnault@lal.in2p3.fr>
+
+
Index: cmtpacman/HEAD/HEAD/cmt/version.cmt
===================================================================
--- cmtpacman/HEAD/HEAD/cmt/version.cmt	(revision 53)
+++ cmtpacman/HEAD/HEAD/cmt/version.cmt	(revision 53)
@@ -0,0 +1,2 @@
+v1
+
Index: cmtpacman/HEAD/HEAD/contrib/userdist.sh
===================================================================
--- cmtpacman/HEAD/HEAD/contrib/userdist.sh	(revision 53)
+++ cmtpacman/HEAD/HEAD/contrib/userdist.sh	(revision 53)
@@ -0,0 +1,162 @@
+#! /bin/bash
+
+function help ()
+{
+  echo "Usage: `basename $0` [OPTION]... [PACKAGE]..."
+  echo -e "Create a distribution kit of the PACKAGEs (all by default) reachable from the \"main\" package (TestRelease by default) in a user's devarea (defaults to either the environment variable, macro devarea in \${HOME}/cmthome/requirements, first entry in CMTPATH, or \${HOME}/MyTest).\n"
+  echo "  -a <dev_area> : select development area <dev_area>"
+  echo "  -m <main_pkg> : select \"main\" package <main_pkg> in development area"
+  echo "  -r <release>  : select Atlas release <release>"
+  echo "  -d <kit_dir>  : create kit in directory <kit_dir>"
+  echo "  -O            : package optimized build (debug otherwise)"
+  echo "  -S            : skip CMT setup"
+  echo -e "  -h            : display this help and exit\n"
+  echo "Report bugs to <Grigori.Rybkine@rhul.ac.uk>."
+}
+
+#
+# Process the options and arguments
+#
+release=${ATLAS_RELEASE}
+mode=
+packages=
+devarea=${devarea}
+mainpkg=TestRelease
+skip=
+
+while getopts ":a:m:r:d:OSh" opt; do
+  case $opt in
+    a ) devarea=${OPTARG} ;;
+    m ) mainpkg=${OPTARG} ;;
+    r ) release=${OPTARG} ;;
+    d ) PACMAN_CACHE=${OPTARG} ;;
+    O ) mode=opt ;;
+    S ) skip=true ;;
+    h ) help ; exit 0 ;;
+    \?|: ) help ; exit 1 ;;
+  esac
+done
+
+shift $(($OPTIND - 1))
+
+for pkg ; do
+  package=`echo ${pkg} | sed -e 's#^[^/]#/&#' -e 's#[^/]$#&/#'`
+  packages="${packages} ${package}"
+done
+
+shift $#
+
+#
+# Locate the Deployment package
+#
+curdir=$PWD
+cd `dirname $0`
+dep=$PWD
+
+#
+# Connect to the release
+#
+if [ -z ${skip} ] ; then
+
+cd ${HOME}/cmthome || exit
+if [ "${release}" ] && [ "${mode}" ] ; then
+  source setup.sh -tag=${release},${mode}
+  if [ -z "${devarea}" ] ; then
+    devarea=`cmt show macro_value devarea -tag=${release},${mode}`
+  fi
+elif [ "${release}" ] && [ -z "${mode}" ] ; then
+  source setup.sh -tag=${release}
+#  mode=`cmt system | sed 's/.*\-//g'`
+  [ "${devarea}" ] || devarea=`cmt show macro_value devarea -tag=${release}`
+elif [ -z "${release}" ] && [ "${mode}" ] ; then
+  source setup.sh -tag=${mode}
+  release=`cmt show macro_value ATLAS_RELEASE -tag=${mode}`
+  [ "${devarea}" ] || devarea=`cmt show macro_value devarea -tag=${mode}`
+else
+  source setup.sh
+  release=`cmt show macro_value ATLAS_RELEASE`
+#  mode=`cmt system | sed 's/.*\-//g'`
+  [ "${devarea}" ] || devarea=`cmt show macro_value devarea`
+fi
+
+else
+  which cmt > /dev/null 2>&1 || { echo "CMT not setup" ; exit 1; }
+fi
+
+[ "${release}" ] || { echo "Select Atlas release, please" ; exit 1; }
+
+cmt_path_purge=`echo $CMTPATH | sed s/^:*//`
+cmt_path_0=`echo ${cmt_path_purge} | cut -d: -f1`
+
+if [ "${devarea}" ] ; then
+  if echo ${devarea} | grep -vq ^/ ; then
+    devarea=${curdir}/${devarea}
+  fi
+  devarea=`echo ${devarea} | sed 's#/*$##'`
+  [ "${devarea}" != "${cmt_path_0}" ] && export CMTPATH=${devarea}:${CMTPATH}
+else
+# devarea specified through neither the option, environment nor macro
+  devarea=${cmt_path_0}
+  if [ -z "${devarea}" ] ; then
+    devarea=${HOME}/MyTest ; export CMTPATH=${devarea}:${CMTPATH}
+  fi
+  echo "Using ${devarea} as devarea" 
+fi
+
+if [ "${mode}" ]; then
+  mode_opt="-platform ${mode}"
+else
+  mode_opt=
+fi
+
+if [ "${PACMAN_CACHE}" ]; then 
+  if echo ${PACMAN_CACHE} | grep -vq ^/ ; then
+    PACMAN_CACHE=${curdir}/${PACMAN_CACHE}
+  fi
+else
+  PACMAN_CACHE=/tmp/${LOGNAME}/${release}
+  echo "Creating kit in ${PACMAN_CACHE}" 
+fi
+
+export PACMAN_CACHE
+mkdir -p ${PACMAN_CACHE}
+
+#
+# Select the top location from which the construction kit will be broadcast
+#
+cd ${devarea}/${mainpkg}/${mainpkg}*/cmt || exit
+
+#
+# Set up the release context
+#
+source setup.sh -no_cleanup
+
+#
+# Connect to the patch directory
+#
+patches=/afs/cern.ch/user/a/alibrari/Kit/patches
+patches_opt="-patches ${patches}"
+
+#
+# May need to construct the cycles file
+#
+if [ -r ${patches}/cycles_${release}.txt ] ; then
+  cycles_opt="-cycles ${patches}/cycles_${release}.txt"
+else
+  cmt -quiet show cycles >| ${PACMAN_CACHE}/cycles_${release}.txt
+  cycles_opt="-cycles ${PACMAN_CACHE}/cycles_${release}.txt"
+fi
+
+#
+# Run the construction kit
+#
+if [ -z "${packages}" ] ; then
+  ${dep}/create_project_kits.sh ${mode_opt}
+  cmt broadcast -local ${dep}/create_kit.sh ${patches_opt} ${cycles_opt} ${mode_opt} ${PACMAN_CACHE}
+else
+  cmt broadcast -local -select="${packages}" ${dep}/create_kit.sh ${patches_opt} ${cycles_opt} ${mode_opt} ${PACMAN_CACHE}
+  #cmt -quiet broadcast -local -select="${packages}" ${dep}/create_kit.sh ${patches_opt} ${cycles_opt} ${mode_opt} ${PACMAN_CACHE}
+fi
+
+cd $curdir
+
Index: cmtpacman/HEAD/HEAD/scripts/CMT.pacman
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/CMT.pacman	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/CMT.pacman	(revision 53)
@@ -0,0 +1,33 @@
+#
+#   CMT installation and setup.
+#
+#   Hi Simon:  Here's a suggestion.  I actually made this a long time ago and modified it to get
+#   your download.  I don't know if the setup is correct any more, but it might be a good starting
+#   point.
+#
+#      Saul
+#
+description  = 'CMT ${cmtversion} (v1)'
+url          = 'http://www.cmtsite.org'
+
+download     = {'unix':'CMT${cmtversion}.tar.gz'}
+source       = 'http://www.cmtsite.org/${cmtversion}/'
+
+inpath       = ['gcc','make']
+
+localdoc     = 'doc/CMT.htm'
+#
+#   This turns off using the root directory extracted from tar. - I 'm getting those tar 
+#   messages again from your tarball.  This messes up getting the root installation, so I'm 
+#   turning that off with the following:
+#
+##usePackageRoot = 0
+#
+#   ...so I cd from the installation area by hand before each shell command.
+#
+install      = { '*': ['cd $PACMAN_INSTALLATION/CMT/${cmtversion}/mgr; ./INSTALL'] }
+#
+#  since usePackageRoot=0, I have to clean up by hand
+#
+uninstall    = ['rm -r -f CMT CMT${cmtversion}.tar']
+
Index: cmtpacman/HEAD/HEAD/scripts/CMTCONFIG.pacman
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/CMTCONFIG.pacman	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/CMTCONFIG.pacman	(revision 53)
@@ -0,0 +1,17 @@
+#
+#   CMT basic settings for opt context 
+#
+description  = 'CMT configuration for ${cmtversion} ${CMTCONFIG} (v1)'
+
+url          = 'http://www.cmtsite.org'
+
+depends = [ 'CMT-${cmtversion}' ]
+
+enviros      = [['CMTCONFIG','|${CMTCONFIG}|'],
+                ['CMTSITE','|STANDALONE|'],
+                ['SITEROOT','|$PACMAN_INSTALLATION|'],
+                ['CMTCVSOFFSET','|offline|'],
+                ['CVSROOT','|:kserver:atlas-sw.cern.ch:/atlascvs|']]
+
+setup         = ["source ${PACMAN_INSTALLATION}/CMT/${cmtversion}/mgr/setup.SHELL"]
+
Index: cmtpacman/HEAD/HEAD/scripts/cmt.py
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/cmt.py	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/cmt.py	(revision 53)
@@ -0,0 +1,121 @@
+
+# -*- coding: iso-8859-1 -*-
+
+import os
+import sys
+import string
+import popen2
+import stat
+import re
+from os import path
+
+class CMT:
+
+    def removedirs (self, top):
+        # Delete everything reachable from the directory named in 'top'.
+        # CAUTION:  This is dangerous!  For example, if top == '/', it
+        # could delete all your disk files.
+        if os.path.exists (top):
+            for root, dirs, files in os.walk (top, topdown=False):
+                for name in files:
+                    name = root + '/' + name
+                    os.chmod (name, stat.S_IWRITE)
+                    os.remove (name)
+                for name in dirs:
+                    name = root + '/' + name
+                    os.chmod (name, stat.S_IWRITE)
+                    os.rmdir (name)
+            os.chmod (top, stat.S_IWRITE)
+            os.rmdir (top)
+
+
+    #----------------------------------------------------
+    #
+    # ExÃ©cution d'une commande du shell
+    #
+    def execute (self, cmd):
+        #print '> ' + cmd
+        r, w, e = popen2.popen3(cmd)
+        lines = []
+        for line in r.readlines():
+            line = string.rstrip (line)
+            lines.append (line)
+        #for line in e.readlines():
+        #    line = string.rstrip (line)
+        #    lines.append (line)
+        r.close()
+        w.close()
+        e.close()
+        return lines
+        #end execute
+
+    #----------------------------------------------------
+    def show_lines (lines):
+        for line in lines:
+            print line
+        # end show_lines
+
+    #----------------------------------------------------
+    cmtexe = os.environ ['CMTROOT'] + '/' + os.environ ['CMTBIN'] + '/cmt.exe'
+    macros = dict ()
+    sets = dict ()
+    uses = []
+    pwd = ''
+    
+    def __init__ (self):
+
+        self.pwd = self.do (self.cmtexe + ' show pwd')
+        if self.pwd == '':
+            self.pwd = os.getcwd ()
+        
+        temp_file_name1 = os.path.join (self.pwd, 'CMT' + str(os.getpid ()) + '1.txt')
+        temp_file_name2 = os.path.join (self.pwd, 'CMT' + str(os.getpid ()) + '2.txt')
+        temp_file = file (temp_file_name1, 'w+')
+
+        lines = self.execute (self.cmtexe + ' -quiet build tag_makefile')
+        for line in lines:
+            temp_file.write (line + '\n')
+        temp_file.close ()
+        
+        self.do ('filter ' + temp_file_name1 + ' ' + temp_file_name2)
+        
+        temp_file = file (temp_file_name2)
+        
+        for line in temp_file.readlines ():
+            name = re.sub ('=.*', '', line)
+            value = re.sub ('^' + name + '=', '', line)
+            self.macros [name] = value
+
+        temp_file.close ()
+
+        os.remove (temp_file_name1)
+        os.remove (temp_file_name2)
+
+        #lines = execute (self.cmtexe + ' show sets')
+        #for line in lines:
+        #    name = re.sub ('=.*', '', line)
+        #    value = re.sub ('^' + name + '=', '', line)
+        #    sets [name] = value
+
+        lines = self.execute (self.cmtexe + ' show uses')
+        for line in lines:
+            if line[0] == '#':
+                continue
+            self.uses.append (line)
+
+    def macro_value (self, name):
+        if not self.macros.has_key (name):
+            lines = self.execute (self.cmtexe + ' show macro_value ' + name)
+            self.macros[name] = ''
+            for line in lines:
+                self.macros[name] = line
+                break
+        return self.macros[name]
+
+    def do (self, cmd):
+        lines = self.execute (self.cmtexe + ' -quiet ' + cmd)
+        if len(lines) > 0:
+            return lines[0]
+        else:
+            return ''
+
Index: cmtpacman/HEAD/HEAD/scripts/create_all_kits.sh
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/create_all_kits.sh	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/create_all_kits.sh	(revision 53)
@@ -0,0 +1,230 @@
+
+function all_packages ()
+{
+  top=$1
+  shift
+
+  if test -d ${base}/${release}/${top}/cmt; then
+    cd ${base}/${release}/${top}/cmt
+  else
+    cd ${base}/${release}/${top}/*/cmt
+    if test ! $? = 0; then
+      echo "run_create_kit.sh> Cannot move to the top package as [${base}/${release}/${top}/*/cmt]"
+      exit
+    fi
+  fi
+
+  select_opt=
+  if test ! "${selected}" = ""; then
+    select_opt="-select='${selected}'"
+  fi
+
+  echo "all_packages> cmt broadcast -global -select=${selected} - ${dep}/create_kit.sh -release ${release} ${patch_opt} ${cycles_opt} ${platform_opt} ${pacman_cache} ${override_opt} ${source_opt}"
+
+  cmt broadcast -global -select="${selected}" - \
+    ${dep}/create_kit.sh \
+      -release ${release} \
+      ${patch_opt} \
+      ${cycles_opt} \
+      ${platform_opt} \
+      ${pacman_cache} \
+      ${override_opt} \
+      ${source_opt} 2>&1 | cat
+}
+
+function CMT ()
+{
+  #
+  # CMT itself 
+  #
+
+  cmtversion=`cmt -quiet version`
+
+  echo "create_all_kits.sh> Constructing the pacman kit for CMT ${cmtversion} [${platform}] into ${pacman_cache}"
+
+  cat ${dep}/CMTCONFIG.pacman | \
+    sed -e 's#${cmtversion}#'"${cmtversion}"'#g' \
+        -e 's#${CMTCONFIG}#'"${CMTCONFIG}"'#g' >| ${pacman_cache}/cache/CMTCONFIG-${cmtversion}-${platform}.pacman
+
+  cat ${dep}/CMT.pacman | \
+    sed -e 's#${cmtversion}#'"${cmtversion}"'#g' >| ${pacman_cache}/cache/CMT-${cmtversion}.pacman
+}
+
+function help ()
+{
+  echo "create_all_kits.sh"
+  echo ""
+  echo "  External parameters:"
+  echo '    ${CMTPATH}       : as for the normal release usage'
+  echo '    ${PACMAN_CACHE}  : where to create the kit'
+  echo ""
+  echo "  Arguments:"
+  echo "    --help           : get this help"
+  echo "    -base <base>     : the base directory of the release [no default]"
+  echo "    -release <rel>   : the release id [no default]"
+  echo "    -top <top>       : the top package [no default]"
+  echo "    -p <package>     : select this package instead of all [can be multiple]"
+  echo "    -cmtversion <v>  : the CMT version"
+  echo "    -patches <dir>   : location of patches for requirements files"
+  echo "    -cycles <file>   : text file containing the output of cmt show cycles"
+  echo "    -platform <plat> : suffix characterizing the platform"
+  echo "    -override        : override existings kits [default is to keep them]"
+  echo "    -step <step>     : one of (projects|all|CMT)"
+  echo "    -source          : create source kits"
+  echo "    [<addon> ...]    : list of missing packages to manually add to this release"
+  echo ""
+}
+
+
+#-----------------------------------------
+# main
+#-----------------------------------------
+
+##set -x
+
+echo "create_all_kits> args=[$*]"
+
+# generic definitions
+dep=`dirname $0`
+dep=`(cd ${dep}; pwd)`
+
+export SITEROOT=/afs/cern.ch
+
+top=
+cmtversion=`cmt version`
+patch_dir=
+patch_opt=
+cycles_file=
+cycles_opt=
+platform=
+platform_suffix=
+platform_opt=
+override_opt=
+selected=
+source_opt=
+
+while test ! $# = 0; do
+  arg=$1
+  ##echo "arg=[${arg}]"
+  if test "${arg}" = "-step"; then
+    shift
+    step=$1
+  elif test "${arg}" = "-base"; then
+    shift
+    base=$1
+  elif test "${arg}" = "-top"; then
+    shift
+    top=$1
+  elif test "${arg}" = "-release"; then
+    shift
+    release=$1
+  elif test "${arg}" = "-p"; then
+    shift
+    package=$1
+    package=`echo ${package} | sed -e 's#^[^/]#/&#' -e 's#[^/]$#&/#'`
+    selected="${selected} ${package}"
+  elif test "${arg}" = "-cmtversion"; then
+    shift
+    cmtversion=$1
+  elif test "${arg}" = "-patches"; then
+    shift
+    patch_dir=$1
+    patch_opt="-patches ${patch_dir}"
+  elif test "${arg}" = "-cycles"; then
+    shift
+    cycles_file=$1
+    cycles_opt="-cycles ${cycles_file}"
+  elif test "${arg}" = "-platform"; then
+    shift
+    platform=$1
+    platform_suffix="-${platform}";
+    platform_opt="-platform ${platform}";
+  elif test "${arg}" = "-override"; then
+    shift
+    override_opt="-override"
+  elif test "${arg}" = "-source"; then
+    shift
+    source_opt="-source"
+    platform="src"
+    platform_suffix="-${platform}";
+    platform_opt="-platform ${platform}";
+  elif test "${arg}" = "--help"; then
+    help
+    exit
+  fi
+  shift
+done
+
+#
+# Checking effective arguments
+#
+
+if test "${CMTPATH}" = ""; then
+  echo "CMTPATH must be defined first."
+  help
+  exit
+fi
+
+if test "${PACMAN_CACHE}" = ""; then
+  echo "PACMAN_CACHE must be defined first."
+  help
+  exit
+fi
+
+if test "${base}" = ""; then
+  echo "Please specify the base directory of the release using the -base option."
+  help
+  exit
+fi
+
+if test "${release}" = ""; then
+  echo "Please specify the release id using the -release option."
+  help
+  exit
+fi
+
+if test "${top}" = ""; then
+  echo "Please specify the top package using the -top option."
+  help
+  exit
+fi
+
+pacman_cache=${PACMAN_CACHE}
+
+kits_dir=${pacman_cache}/kits
+cache_dir=${pacman_cache}/cache
+
+if test ! -d ${kits_dir}; then
+  mkdir -p ${kits_dir}
+fi
+
+if test ! -d ${cache_dir}; then
+  mkdir -p ${cache_dir}
+fi
+
+#echo step=${step}
+#echo "selected=[${selected}]"
+#echo "patch_opt=[${patch_opt}]"
+#echo "cycles_opt=[${cycles_opt}]"
+#echo "platform_opt=[${platform_opt}]"
+#echo "pacman_cache=[${pacman_cache}]"
+#echo "override_opt=[${override_opt}]"
+#echo "source_opt=[${source_opt}]"
+
+if test ! "${source_opt}" = ""; then
+  ${dep}/create_project_kits.sh ${platform_opt}
+  all_packages ${top}
+elif test "${step}" = ""; then
+  CMT
+  ${dep}/create_project_kits.sh ${platform_opt}
+  all_packages ${top}
+else
+  if test "${step}" = "projects"; then
+    ${dep}/create_project_kits.sh ${platform_opt}
+  elif test "${step}" = "all"; then
+    all_packages ${top}
+  elif test "${step}" = "CMT"; then
+    CMT
+  fi
+fi
+
Index: cmtpacman/HEAD/HEAD/scripts/create_kit.py
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/create_kit.py	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/create_kit.py	(revision 53)
@@ -0,0 +1,291 @@
+
+# -*- coding: iso-8859-1 -*-
+
+import os
+import sys
+import string
+import popen2
+import stat
+import re
+import time
+from os import path
+import getopt
+import tempfile
+import signal
+import cmt
+
+tempprefix = ''
+tempfile1 = ''
+tempfile2 = ''
+tempcopydir = ''
+tempcmtusercontext = ''
+patch_requirements = ''
+
+release = ''
+cyclefile = ''
+patch_dir = ''
+minimal = False
+pacman_only = False
+platform = ''
+platform_suffix = ''
+override = False
+do_source_kit = False
+url = ''
+
+pacman_base = ''
+cache_dir = ''
+kits_dir = ''
+
+patch_requirements = ''
+
+here = ''
+
+cmt = cmt.CMT ()
+
+def get_project (cmtpath):
+    if cmtpath != '':
+        rr = os.path.basename (cmtpath)
+        pr = os.path.dirname (cmtpath)
+        pr = os.path.basename (pr)
+        return os.path.join (pr, rr)
+
+def cleanup ():
+    print 'Cleanup'
+    cmt.removedirs (tempprefix)
+
+def build_pacman (url, package, version, cmtpath, project_id, is_internal):
+    #print url, package, version, cmtpath, project_id, is_internal
+
+    source = '../kits'
+
+    # External packages (those with export_paths) are split into two kits:
+    # o The internal part, which follows the naming convention for internal packages
+    # o The external part, which only refers to the package version (no mention of
+    #   the project)
+
+    # Naming cnvention:
+    #  external packages : <package>-<version>-<platform>
+    #  internal packages : <projectid>/<package>-<platform>
+
+    if not is_internal:
+        # first build the pacman file for the external stuff
+
+        if native_version == None:
+            #vv=`echo ${version} | sed -e 's#'^${package}-'##'`
+            vv = ''
+        else:
+            vv = native_version
+            download_filename="${package}-${vv}${platform_suffix}"
+        download_filename = package + '-' + vv + platform_suffix
+
+        pacman_filename = download_filename + '.pacman'
+
+        print 'build_pacman> Create pacman file for external stuff ' + pacman_filename
+
+        pacman_file_version = get_pacman_file_version (os.path.join (cache_dir, pacman_filename))
+
+        #if test -f ${cache_dir}/${pacman_filename};  then
+        # mv ${cache_dir}/${pacman_filename} ${cache_dir}/${pacman_filename}.bak
+        # if test ! $? = 0; then
+        #   print 'create_kit> failed to rename ' + cache_dir + '/' + pacman_filename + ' to ' + cache_dir + '/' + pacman_filename' + '.bak'
+        # exit 1
+
+    # write pacman file
+
+
+
+    # end build_pacman
+
+def usage ():
+    print "Make a distribution kit for a CMT package"
+    print "Usage: create_kit.sh [ <option> ... ] <pacman-cache>"
+    print " where option can be:"
+    print "  -r|--release <release-id>  : specify the release id"
+    print "  -c|--cycles <cycles-file>  : specify the cycles file"
+    print "  -P|--patches <patch-dir>   : specify a directory for patches "
+    print "  -m|--minimal               : only store CMT files into the tar ball"
+    print "  -O|--pacman_only           : do not generate the tar ball"
+    print "  -p|--platform <platform>   : specify a platform suffix"
+    print "  -o|--override              : override the existing tar balls"
+    print "  -s|--source                : generate the source kit"
+    print "Typical/example usage:"
+    print "  cmt broadcast create_kit.sh -release 6.3.0 -cycles ${DEP}/cycles.txt /tmp "
+    # end usage
+
+#----------------------------------------------------
+# Main
+#----------------------------------------------------
+def main ():
+
+    print time.strftime ('%c')
+
+    pwd = os.getcwd ()
+
+    try:
+        opts, args = getopt.getopt (sys.argv[1:] , 'r:c:P:mOp:osu:', ['release=', 'cycles=', 'patches=', 'minimal', 'pacman_only', 'platform=', 'override', 'source', 'url='])
+
+    except getopt.GetoptError:
+        # print help information and exit:
+        usage()
+        sys.exit(2)
+
+    for o,a in opts:
+        if o in ('-r', '--release'):
+            release = a
+        if o in ('-c', '--cycles'):
+            cyclefile = a
+        if o in ('-P', '--patches'):
+            patch_dir = a
+        if o in ('-m', '--minimal'):
+            minimal = True
+        if o in ('-O', '--pacman_only'):
+            pacman_only = True
+        if o in ('-p', '--platform'):
+            platform = a
+        if o in ('-o', '--override'):
+            override = True
+        if o in ('-s', '--source'):
+            do_source_kit = True
+        if o in ('-u', '--url'):
+            url = a
+
+    for a in args:
+        pacman_base = os.path.normpath (a)
+        cache_dir = os.path.join (pacman_base, os.path.normpath ('cache'))
+        kits_dir = os.path.join (pacman_base, os.path.normpath ('kits'))
+
+    #---------------
+    # Prepare the target pacman cache 
+    #
+
+    if not os.path.isdir (cache_dir):
+        print 'Creating ' + cache_dir
+        os.makedirs (cache_dir)
+
+    if not os.path.isdir (kits_dir):
+        print 'Creating ' + kits_dir
+        os.makedirs (kits_dir)
+
+    here = os.path.dirname (sys.argv[0])
+    if here == '':
+        here = os.getcwd ()
+
+    print 'here=' + here
+
+    #---------------
+    # Prepare temporary file management
+    #
+
+    #signal.signal (0, cleanup)
+    #signal.signal (1, cleanup)
+    #signal.signal (2, cleanup)
+    #signal.signal (15, cleanup)
+
+    tempprefix = 'CMT' + str(os.getpid ())
+    print 'tempprefix=' + tempprefix
+
+    tempfile1 = os.path.join (tempprefix, 't')
+    tempfile2 = os.path.join (tempprefix, 'u')
+    tempcopydir = os.path.join (tempprefix, 'c')
+    tempcmtusercontext = os.path.join (tempprefix, 'd')
+
+    cleanup ()
+
+    os.makedirs (tempprefix)
+
+    #---------------
+    # Prepare the CMT and package context
+    #
+
+    h = cmt.do ('show pwd')
+    root = os.path.dirname (h)
+
+    cmtversion = cmt.do ('version')
+
+    version = cmt.macro_value ('version')
+    if version == 'v*':
+        version = 'v1'
+
+    print 'cmtversion=' + cmtversion
+    print 'version' + version
+
+    package = cmt.macro_value ('package')
+    if package != '':
+        package = os.path.normpath (package)
+        
+    cmtpath = cmt.macro_value (package + '_cmtpath')
+    if cmtpath != '':
+        cmtpath = os.path.normpath (cmtpath)
+
+    offset = cmt.macro_value (package + '_offset')
+    if offset != '':
+        offset = os.path.normpath (offset)
+
+    print 'package=' + package
+    print 'cmtpath=' + cmtpath
+    print 'offset=' + offset
+
+    project = cmt.macro_value (package + '_project')
+    print 'package_project=' + project
+
+    release = cmt.macro_value (package + '_project_release')
+    print 'package_project_release=' + release
+    
+    print 'CMTPATH=' + cmt.macro_value ('CMTPATH')
+
+    if cmtpath == '':
+        cmtpath = os.path.normpath (cmt.macro_value (package + '_root'))
+        cmtpath = os.path.dirname (cmtpath)
+        cmtpath = os.path.dirname (cmtpath)
+
+    print '# Working on ' + package + ' ' + version + ' ' + offset + ' in ' + cmtpath + ' project ' + project + ' ' + release
+
+    cleanup ()
+    sys.exit (0)
+
+    #---------------
+    # Prepare the patch structure
+    #
+
+    if options.patch_dir != None:
+        if os.path.isdir (os.path.join (options.patch_dir, project_id)):
+            print 'create_kit> ' + options.patch_dir + '/' + project_id
+            os.makedirs (tempcmtusercontext)
+            os.putenv ('CMTUSERCONTEXT', tempcmtusercontext)
+            patch_requirements = os.path.join (tempcmtusercontext, os.path.normpath ('requirements'))
+            f = open (patch_requirements, 'w+')
+            
+    #---------------
+    # Prepare the detection of external packages
+    #
+
+    native_version = cmt.macro_value (package + '_native_version')
+    export_paths = cmt.macro_value (package + '_export_paths')
+
+    is_internal = export_paths == None
+
+    if options.do_source_kit:
+        is_internal = True
+            
+    #---------------
+    # Prepare the temporary copies
+    #
+
+    os.makedirs (tempcopydir)
+    copycmd = 'ln -s'
+
+    #---------------
+    # Generate the pacman file
+    #
+
+    build_pacman (options.url, package, version, cmtpath, project_id, is_internal)
+
+    #---------------
+    # 
+    #
+
+    cleanup ()
+
+if __name__ == '__main__':
+    main()
+
Index: cmtpacman/HEAD/HEAD/scripts/create_kit.sh
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/create_kit.sh	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/create_kit.sh	(revision 53)
@@ -0,0 +1,1453 @@
+
+if test ! "${KITDEBUG}" = ""; then
+  set -x
+fi
+
+#--------------------------------------------
+#
+#  create_kit.sh [options]
+#
+#    options are:
+#
+#      -rpm               optional (default to norpm)
+#      -cycles <file>     optional cycles file (output of cmt show cycles)
+#      -release <release> optional current release id
+#      -platform <platf>  optional suffix for all kits
+#      output-directory   optional (default to current directory)
+#
+#  Acquire contents of a package and create a tar ball from it 
+#
+#     - shared libraries obtained from 
+#           ../$CMTCONFIG/*.so
+#     - applications obtained from either
+#           $(use_applications)
+#         and
+#           ../$CMTCONFIG/*.exe
+#     - runtime files obtained from either
+#           $(use_runtime)
+#         and
+#           ../share/*
+#     - header files obtained from 
+#         ../<package>/*
+#     - the CMT files (requirements + make fragments) of the package
+#         ../cmt/requirements
+#         ../cmt/fragments
+#     
+#  By default only a compressed (gzip) tar ball is constructed. With the
+#  -rpm option, a RPM is also constructed.
+#
+#--------------------------------------------
+
+#--------------------------------------------
+macro_value ()
+{
+  name=$1
+  shift
+
+  grep "^${name}=" ${tempmacros} | sed -e "s#^${name}=##"
+}
+
+#--------------------------------------------
+standalone_macro_value ()
+{
+  name=$1
+  shift
+
+  grep "^${name}=" ${tempmacrosstandalone} | sed -e "s#^${name}=##"
+}
+
+#--------------------------------------------
+libraries ()
+{
+  grep "^library" ${tempconstituents}
+}
+
+#--------------------------------------------
+applications ()
+{
+  grep "^application" ${tempconstituents}
+}
+
+#--------------------------------------------
+purge_variables ()
+{
+  for e in `printenv | sed -e 's#=.*##' | egrep 'ROOT'`; do 
+    p=`echo $e | sed -e 's#ROOT##'`
+
+    is_cmt=0
+
+    if test "${p}" = "CMT"; then
+      is_cmt=1
+    fi
+
+    if test "${p}" = "NEWCMT"; then
+      is_cmt=1
+    fi
+
+    if test ! "${is_cmt}" = "1"; then
+      unset ${p}CONFIG
+      unset ${p}ROOT
+    fi
+
+  done
+}
+
+#--------------------------------------------
+filter_path ()
+{
+  root=$1
+  p=$2
+
+  ##echo "filter_path for ${p}"
+
+  c=`ls ${p} 1>/dev/null 2>&1 `
+
+  if test ! $? = 0 ; then
+    p=
+  else
+    while `ls $p 1>/dev/null 2>&1` ; do
+
+      ##echo "in loop p=${p}"
+
+      a=`echo $p | sed -e "s#[.][.]/[^.][^/]*/##"`
+
+      ##echo "in loop a=${a}"
+
+      if test ${a} = ${p}; then
+        break;
+      else
+
+        c=`ls ${a} 1>/dev/null 2>&1`
+
+        if test ! $? = 0 ; then
+
+          ##echo "bad ls"
+
+          break
+        else
+
+          ##echo "ls ok"
+
+          p=$a
+        fi
+      fi
+    done
+  fi
+
+  echo $p | sed -e "s#^[.][.]/##" -e "s#^${root}##" -e "s#[/][/]*#/#g"
+}
+
+#--------------------------------------------
+#  $1  is the name of a file containing a list of file specs
+#  $2  is the name of a directory where files will be transfered
+#
+#  ${copycmd} is the command to use for doing the transfer
+#  ${tempcopydir} is the base location of the transfer destination
+#
+transfer_files ()
+{
+  ##echo "transfer_files> args=[$*]"
+
+  kind=$1
+  shift
+
+  list=$1
+  shift
+
+  branch=$1
+  shift
+
+  alt=
+  dir_prefix=
+
+  if test ! -f "${list}"; then return ; fi
+
+  cmt -quiet filter ${list} ${tempfile2}; mv ${tempfile2} ${list}
+  sort -u ${list} >${tempfile2}; mv ${tempfile2} ${list}
+
+  n=`wc -w ${list} | awk '{print $1}'`
+  if test "${n}" = 0; then
+    /bin/rm -f ${list}
+    return
+  fi
+
+  echo "create_kit> Now acquiring ${kind}"
+
+  #cat ${list}
+
+  for f in `cat ${list} | sort -u`; do
+
+    alt=`echo ${f} | egrep '^[-]s='`
+
+    if test ! "${alt}" = ""; then
+      alt=
+      dir_prefix=`echo ${f} | sed -e 's#^[-]s=##'`
+    else
+
+      test_absolute=`echo ${f} | egrep '^/'`
+
+      if test ! $? = 0; then
+        if test ! "${dir_prefix}" = ""; then
+          f=${dir_prefix}/${f}
+        fi
+      fi
+
+      ##echo "1) $f"
+
+      n=`(set -f; basename ${f})`
+      d=`(set -f; dirname ${f})`
+
+      if test -d ${d}; then
+        d=`(cd ${d}; pwd)`
+        ff=${d}/${n}
+
+        #echo "2) $ff ${tempcopydir}/${branch} d=${d}"
+
+        mkdir -p ${tempcopydir}/${branch}
+
+        is_dir=0
+        if test "`(set -f; echo ${ff}) | grep '[*]'`" = ""; then
+          if test -d `(set -f; echo ${ff})`; then
+            is_dir=1
+          fi
+        fi
+
+        ##------------------------------------
+        ## We compare ${d} and ${branch}
+        ## is ${branch} strictly included in ${d} ?
+        ## if yes, compute the offset to be added to ${branch}
+        ##
+
+        off=
+
+        aaa=`echo ${d} | grep -e ${branch}`
+
+        if test $? = 0; then
+          # echo "There may be an offset d=${d} branch=${branch}"
+          off=`echo "${d}" | sed -e 's#.*'"${branch}"'##' -e 's#^[/]##g'`
+          if test ! "${off}" = ""; then
+            off="/${off}"
+            mkdir -p ${tempcopydir}/${branch}${off}
+          fi
+          ##echo "off=${off}"
+        fi
+
+        ##echo "3) is_dir=$is_dir"
+
+        if test ${is_dir} = 1; then
+          ##echo "  > directory ${ff}"
+
+          ##echo "4) copycmd=[$copycmd]"
+
+          ${copycmd} ${ff} ${tempcopydir}/${branch}${off}/${n}
+        else
+          a=`eval "ls ${ff} 2>/dev/null"`
+
+          ##echo "4) a=[$a]"
+
+          for g in `echo ${a}`; do
+            nn=`basename ${g}`
+            ##echo "  > file ${g} branch=${branch}${off}"
+            if test ! -e ${tempcopydir}/${branch}${off}/${nn}; then
+              ${copycmd} ${g} ${tempcopydir}/${branch}${off}/${nn}
+	    fi
+          done
+        fi
+      else
+        echo "create_kit> Warning: Directory ${d} not found for file ${f}"
+      fi
+    fi
+  done
+
+  /bin/rm -f ${list}
+}
+
+get_libraries ()
+{
+  package=$1
+  shift
+
+  if test -d ../$CMTCONFIG; then
+    cd ../$CMTCONFIG
+
+    pwd=`pwd`
+
+    libraries | \
+      egrep -v '[.]java' | \
+      awk '{if ($3 == "-no_share") ext=".a"; else ext=".so"; print "'${pwd}/'lib" $2 ext}'
+
+  fi
+
+  ##macro_value ${package}_libraries
+}
+
+acquire_libraries ()
+{
+#---------------
+#  Acquire all exported shared libraries
+#
+#   Result is stored (symlinked) in ${tempcopydir}/lib
+#
+
+  get_libraries ${package} >| ${tempfile1}
+
+  transfer_files "libraries" ${tempfile1} ${project_install_area}/${CMTCONFIG}/lib
+}
+
+get_java ()
+{
+  if test -d ../classes; then
+    cd ../classes
+
+    pwd=`pwd`
+
+    find . -name '*.jar' | sed -e 's#[.]/#'${pwd}'/#'
+  fi
+}
+
+acquire_java ()
+{
+#---------------
+#  Acquire all exported java stuff
+#
+#   Result is stored (symlinked) in ${tempcopydir}/classes
+#
+
+  get_java >| ${tempfile1}
+
+  transfer_files "java files" ${tempfile1} ${project_install_area}/share/lib
+}
+
+get_applications ()
+{
+  if test -d ../$CMTCONFIG; then
+    cd ../$CMTCONFIG
+
+    pwd=`pwd`
+
+    applications | \
+      egrep -v '[.]java' | \
+      awk '{print "'${pwd}/'" $2 ".exe"}'
+
+    ##find . -name '*.exe' -type f | sed -e 's#[.]/#'${pwd}'/#'
+  fi
+}
+
+acquire_applications ()
+{
+#---------------
+#  Acquire all exported applications
+#
+#   Result is stored (symlinked) in ${tempcopydir}/bin
+#
+
+  get_applications >| ${tempfile1}
+
+  macro_value use_applications | \
+    grep -e "Package ${package} " | \
+    sed -e "s#.*use_applications : '##" -e "s#' for .*##" >>${tempfile1}
+
+  transfer_files "applications" ${tempfile1} ${project_install_area}/${CMTCONFIG}/bin
+}
+
+acquire_runtime_files ()
+{
+#---------------
+#  Acquire runtime files
+#
+#   Result is stored (symlinked) in ${tempcopydir}/share
+#
+
+  echo '$('"${package}"'_runtime)' >>${tempfile1}
+
+  transfer_files "runtime files" ${tempfile1} ${project_install_area}/share
+}
+
+acquire_xml_files ()
+{
+#---------------
+#  Acquire XML files
+#
+#   Result is stored (symlinked) in ${tempcopydir}/XML
+#
+
+  echo '$('"${package}"'_xmls)' >>${tempfile1}
+
+  transfer_files "XML files" ${tempfile1} ${project_install_area}/XML/${package}
+}
+
+acquire_jo_files ()
+{
+#---------------
+#  Acquire jobOption files
+#
+#   Result is stored (symlinked) in ${tempcopydir}/jobOptions
+#
+
+  echo '$('"${package}"'_joboptions)' >>${tempfile1}
+
+  transfer_files "jobOption files" ${tempfile1} ${project_install_area}/jobOptions/${package}
+}
+
+acquire_scripts_files ()
+{
+#---------------
+#  Acquire scripts files
+#
+#   Result is stored (symlinked) in ${tempcopydir}/share/bin
+#
+
+  echo '$('"${package}"'_scripts)' >>${tempfile1}
+
+  transfer_files "scripts files" ${tempfile1} ${project_install_area}/share/bin
+}
+
+acquire_python_modules_files ()
+{
+#---------------
+#  Acquire python_modules files
+#
+#   Result is stored (symlinked) in ${tempcopydir}/share/bin
+#
+
+  echo '$('"${package}"'_python_modules)' >>${tempfile1}
+
+  transfer_files "python_modules files" ${tempfile1} ${project_install_area}/python/${package}
+}
+
+acquire_headers ()
+{
+#---------------
+#  Acquire header files
+#
+#   Result is stored (symlinked) in ${tempcopydir}/include/<package>/<package>
+#
+
+  if test -d ../${package}; then
+
+    pwd=`(cd ../${package}; pwd)`
+    echo ${pwd} >${tempfile1}
+
+    transfer_files "header files" ${tempfile1} ${project_install_area}/include/${package}
+
+  fi
+}
+
+acquire_CMT_files ()
+{
+#---------------
+#  Acquire the CMT files (requirements + make_fragments) file
+#
+#   Result is stored (symlinked) in ${tempcopydir}/cmt
+#
+
+  echo `pwd` >${tempfile1}
+  if test -d ../fragments; then
+    up=`(cd ..; pwd)`
+    echo ${up}/fragments >>${tempfile1}
+  fi
+
+  if test -f version.cmt; then
+    versiondir=""
+  else
+    versiondir="/${version}"
+  fi
+
+  tempcmtbase=${project}/${offset}${package}${versiondir}
+
+  macro_value ${package}_CMT_files >>${tempfile1}
+
+  old_copycmd=${copycmd}
+  copycmd="cp -r"
+
+  transfer_files "CMT files" ${tempfile1} ${tempcmtbase}
+
+  copycmd=${old_copycmd}
+
+  chmod -R +w ${tempcopydir}/${tempcmtbase}/cmt
+  (cd ${tempcopydir}/${tempcmtbase}/cmt;
+   eval "/bin/rm -f setup.* cleanup.* *make* Makefile")
+
+  if test ! "${patch_requirements}" = ""; then
+    echo "create_kit> Patching requirements file with ${patch_requirements}"
+    cat requirements ${patch_requirements} >|${tempcopydir}/${tempcmtbase}/cmt/requirements
+  fi
+}
+
+acquire_lcg_modules ()
+{
+  echo ' -s=$(CMTINSTALLAREA)/${CMTCONFIG}/lib/modules $('"${package}"'_modules) ' >>${tempfile1}
+
+  transfer_files "LCG module files" ${tempfile1} ${project_install_area}/${CMTCONFIG}/lib/modules
+}
+
+acquire_export_installed_files ()
+{
+  echo ' -s=$(CMTINSTALLAREA) $('"${package}"'_export_installed_files) ' >>${tempfile1}
+
+  transfer_files "exported installed files" ${tempfile1} ${project_install_area}
+}
+
+make_tar_filename ()
+{
+  if test "${project_id}" = ""; then
+    if test "${native_version}" = ""; then
+      echo ${package}-${version}${platform_suffix} | sed -e 's#'${package}-${package}'#'${package}'#'
+    else
+      echo ${package}-${native_version}${platform_suffix}
+    fi
+  else
+    echo ${project_id}/${package}${platform_suffix}
+  fi
+}
+
+acquire_export_paths ()
+{
+  #
+  # Algo:
+  #
+  #  For each epi = export_paths[i], epsi = export_paths[i](STANDALONE) :
+  #    epsi = epsi - ${SITEROOT}
+  #   transfer_files 
+  #
+
+  echo "create_kit> Now Acquiring exported files from $*"
+
+  if test -f ${tempcopydir}/external_links.dat; then
+    /bin/rm -f ${tempcopydir}/external_links.dat
+  fi
+
+  if test -f ${tempcopydir}/excludes.dat; then
+    /bin/rm -f ${tempcopydir}/excludes.dat
+  fi
+
+  export_paths=$*
+
+  #
+  # Get the two values of export_paths for default tag and for STANDALONE tag
+  #
+  #   each value is formatted as a : separated list of paths
+  #
+  a1=`eval echo ":${export_paths}:" | sed -e 's#[ ][ ]*#:#g'`  
+  a20=`standalone_macro_value ${package}_export_paths`
+  a2=`eval echo ":${a20}:" | sed -e 's#[ ][ ]*#:#g' -e 's#[:][:]*#:#g' -e 's#'${SITEROOT}'/##g'`
+
+  echo "create_kit> Source=[${a1}]"
+  echo "create_kit> Dest=[${a2}]"
+
+  #
+  # Transform the two lists a1[n] a2[n] into a list of pairs <a1[i], a2[i]>
+  #
+  i=2
+  for f1 in `echo ${a1} | sed -e 's#:# #g'`; do
+    f2=`echo ${a2} | cut -d':' -f${i}`
+
+    ##echo "f1=[$f1] f2=[$f2]"
+
+    # Test whether the second item is strictly included in the first one.
+
+    a=`echo $f1 | egrep -e "${f2}$"`
+
+    if test $? = 0; then
+      ## exported path is included in the source path
+
+      off=${f1#${f2}}
+
+      a=`dirname ${f2}`
+      mkdir -p ${tempcopydir}/${a}
+
+    else
+
+      ## exported path is not included in the source path let's find the common part
+
+      n1=`echo $f1 | awk -F/ '{print NF}'`
+      n2=`echo $f2 | awk -F/ '{print NF}'`
+
+      b=""
+      while test ${n1} -gt 0 -a ${n2} -gt 0 ; do
+        s1=`echo $f1 | cut -d/ -f${n1}`
+        s2=`echo $f2 | cut -d/ -f${n2}`
+
+        if test ! "${s1}" = "${s2}"; then
+          break
+        fi
+
+	if test "${b}" = ""; then
+          b=${s1}
+        else
+          b="${s1}/${b}"
+        fi
+
+	n1=`expr ${n1} - 1`
+	n2=`expr ${n2} - 1`
+      done
+
+      a=${f1%${b}}
+      c=${f2%${b}}
+
+      if test ! -z "${b}"; then
+        d=`dirname ${b}`
+      else
+        d=
+      fi
+
+      mkdir -p ${tempcopydir}/${c}/${d}
+
+    fi
+
+    #
+    # Instead of creating symlinks to external items we instead
+    # create entries in one text file using :
+    #
+    #   <physical-loc>:<link-location>
+    #
+    # where <link-location> is the offset to be created in the tar
+    #
+    ##ln -s ${f1} ${tempcopydir}/${f2}
+
+    ##echo "f1=[${f1}] f2=[${f2}]"
+    echo "${f1}:${f2}" >>${tempcopydir}/external_links.dat
+
+    i=`expr ${i} + 1`
+  done
+}
+
+
+create_tar ()
+{
+#---------------
+# Prepare the production of the tar file.
+#
+#---------------
+
+#---------------
+# Create (or upgrade) the tar file
+#
+
+  ##echo "create_kit> Now creating tar file"
+
+  do_override=$1
+  shift
+
+  tar_file_name=`make_tar_filename`
+  t=${tar_file_name}.tar
+  plain_tar="${kits_dir}/${t}"
+  compressed_tar="${plain_tar}.gz"
+
+  if test ! "${do_override}" = "yes"; then
+    if test -f "${compressed_tar}"; then
+      echo "create_kit> The tar file ${compressed_tar} already exists. It won't be overwritten"
+      return
+    fi
+  fi
+
+  #
+  # In all cases a remaining plain tar file is a remnant of a previous interrupted build
+  #
+  if test -f "${plain_tar}"; then
+    /bin/rm -f ${plain_tar}
+  fi
+
+  zip_command="tar "
+  zip_basic_option="v"
+
+  if test ! "${project_id}" = ""; then
+    mkdir -p ${kits_dir}/${project_id}
+  fi
+
+  if test ! -d ${tempcopydir}; then
+    #
+    # Nothing has been collected to be sent to the tar. So create a dummy file
+    # to always really generate a tar ball
+    #
+    mkdir -p ${tempcopydir}/dummy
+    echo "${package}" >| ${tempcopydir}/dummy/${tar_file_name}.txt
+  fi
+
+  #
+  # The items to export to the tar bal have been collected into ${tempcopydir}:
+  # 
+  #  either as direct copies into this directory
+  #  or as a list of external directory specifications stored into the external_links.dat
+  #
+  #  [Those two options are currently mutually exclusive]
+  #
+
+  if test -f ${tempcopydir}/external_links.dat; then
+
+    for f in `cat ${tempcopydir}/external_links.dat`; do
+
+      echo "create_kit> Next entry in external_links.dat : ${f} "
+
+      #
+      # Entries in external_links.dat are lines fomratted with
+      #   <physical location>:<offset in tar>
+      #
+      # The tar operation is directly performed from the external location and symlinks are kept
+      #
+
+      if test -f ${plain_tar}; then 
+        zip_option="${zip_basic_option}u"
+      else 
+        zip_option="${zip_basic_option}c"
+      fi
+
+      a=`echo $f | cut -d: -f1`
+      b=`echo $f | cut -d: -f2`
+
+      has_external_links=
+      excludes_opt=
+      tar_sources_prefix=
+
+      d=`dirname ${b}`
+      mkdir -p ${tempcopydir}/${d}
+
+      if test -d "${a}"; then
+        #
+        # When the item is a directory, we have to detect symbolic links pointing to a location
+        # external to the tree starting from this item
+        #
+        ##echo "(cd ${a}; find . -type l -exec ${here}/filter_links.sh {} \;)"
+        ##has_external_links=`(cd ${a}; find . -type l -exec ${here}/filter_links.sh {} \;)`
+        echo "create_kit> ${here}/filter_links.sh ${a}"
+        has_external_links=`${here}/filter_links.sh ${a}`
+
+        if test ! -z "${has_external_links}"; then
+          #
+          # When this is true, we must follow the symlinks in the tar action
+          #
+          zip_option="${zip_option}h"
+        fi
+
+        #
+        # We have to exclude recursive symlinks to "."
+        #
+        (cd ${a}; find . -type l -lname . -o -lname "${a}*" ) >|${tempcopydir}/excludes.dat
+
+        if test -f "${tempcopydir}/excludes.dat"; then
+
+          if test ! -z `cat ${tempcopydir}/excludes.dat`; then
+            echo "create_kit> Excluding recursive or extern symlinks :"
+            cat ${tempcopydir}/excludes.dat
+            echo "  ----------------------------"
+            excludes_opt="-X ${tempcopydir}/excludes.dat"
+          fi
+        fi
+
+        tar_sources="${b}/*"
+
+      else
+
+        zip_option="${zip_option}h"
+        tar_sources="${b}"
+
+      fi
+
+      d=`dirname ${tempcopydir}/${b}`
+      mkdir -p ${d}
+
+      #
+      # A symlink creates the logical name of the sources as they will be seen
+      # in the tar ball, which may not be identical to the original package.
+      #
+      #  This is the logical mapping obtained for the STANDALONE floavour of the 
+      # export_paths macro
+      #
+      echo "ln -s ${a} ${tempcopydir}/${b}"
+      ln -s ${a} ${tempcopydir}/${b}
+
+      #
+      # To cope with very long list of source files, we create a text file containing
+      # the expanded list of file names.
+      #  When the source is a dirctory, we list this directory
+      #  otherwise, we list this simple file.
+      # 
+      tar_source_list="${tempcopydir}/tar_source_list.txt"
+      /bin/rm -f ${tar_source_list}
+
+      if test -d "${a}"; then
+        ls ${tempcopydir}/${b} | sed -e "s#^#${b}/#"> ${tar_source_list}
+      else
+        echo ${b} > ${tar_source_list}
+      fi
+
+      echo "(cd ${tempcopydir}; ${zip_command} ${zip_option}f ${plain_tar} ${excludes_opt} -X ${here}/excludes.txt --files-from=${tar_source_list} )"
+      (cd ${tempcopydir}; eval ${zip_command} ${zip_option}f ${plain_tar} ${excludes_opt} -X ${here}/excludes.txt --files-from=${tar_source_list} )
+
+      /bin/rm -rf ${tempcopydir}/${b}
+
+    done
+
+  else
+
+    #
+    # The tar operation is done against ${tempcopydir} where original stuff has been copied
+    #
+    #  Since symlinks may have been copied there, they must be resolved when sent to the tar
+    #  (using the -h option)
+    #
+
+    if test -f ${plain_tar}; then 
+      zip_option="${zip_basic_option}hu"
+    else 
+      zip_option="${zip_basic_option}hc"
+    fi
+
+    echo "(cd ${tempcopydir}; ${zip_command} ${zip_option}f ${plain_tar} -X ${here}/excludes.txt * )"
+    (cd ${tempcopydir}; ${zip_command} ${zip_option}f ${plain_tar} -X ${here}/excludes.txt * )
+
+  fi
+
+  gzip -f ${plain_tar}
+}
+
+create_RPM ()
+{
+  if test "${rpm}" = 1; then
+    echo 'create_kit> Now creating RPM files'
+
+    purge_variables
+
+    (cd ${kits_dir}; ${here}/make_RPM.sh ${package} ${version} "tar.gz")
+  fi
+}
+
+get_offset ()
+{
+  p=`pwd`
+  for f in `echo ${CMTPATH} | sed -e "s#[:]# #g"`; do
+    a=`echo ${p} | egrep -e "${f}/"`
+    if test $? = 0; then
+      echo ${p} | sed -e "s#${f}##" -e 's#/'${package}'/.*##' -e "s#^/##" -e "s#/^##"
+    fi
+  done
+}
+
+get_project ()
+{
+  if test ! "${cmtpath}" = ""; then
+    rr=`basename ${cmtpath}`
+    pr=`dirname ${cmtpath}`
+    pr=`basename ${pr}`
+    echo ${pr}/${rr}  
+  fi
+}
+
+#==================================================================
+#  filter_deps <cyclefile> <p> <p> ...
+#
+#  Remove from the list of <p>s all entries found in the cyclefile
+#
+function filter_deps ()
+{
+  cyclefile=$1
+  shift
+
+  cycles=`cat ${cyclefile} | awk '{if ($NF == "'${package}'") {print $1}}'`
+
+  alldeps=$*
+  for f in ${alldeps}; do 
+    found=0
+    p=`echo ${f} | cut -d: -f1`
+    for c in ${cycles}; do
+      if test "${c}" = "${p}"; then
+        found=1
+        break
+      fi
+    done
+    if test ${found} = 0; then
+      echo ${f}
+    fi
+  done
+}
+
+function usage ()
+{
+  echo "Make a distribution kit for a CMT package"
+  echo "Usage: create_kit.sh [ <option> ... ] <pacman-cache>"
+  echo " where option can be:"
+  echo "  -release <release-id>  : specify the release id"
+  echo "  -cycles <cycles-file>  : specify the cycles file"
+  echo "  -patches <patch-dir>   : specify a directory for patches "
+  echo "  -minimal               : only store CMT files into the tar ball"
+  echo "  -pacman_only           : do not generate the tar ball"
+  echo "  -platform <platform>   : specify a platform suffix"
+  echo "  -override              : override the existing tar balls"
+  echo "  -source                : generate the source kit"
+  echo "  -rpm                   : also generate RPM manifest files"
+  echo "Typical/example usage:"
+  echo "  cmt broadcast create_kit.sh -release 6.3.0 -cycles ${DEP}/cycles.txt /tmp "
+  exit
+}
+
+function get_pacman_file_version ()
+{
+  old_file=$1
+  shift
+
+  pacman_file_version=1
+  if test -f ${old_file};  then
+    pacman_file_version=`grep description ${old_file} | egrep '[(]v' | sed -e 's#.*(v##' -e 's#).*##'`
+    if test "${pacman_file_version}" = ""; then
+      pacman_file_version=1
+    else
+      pacman_file_version=`expr ${pacman_file_version} + 1`
+    fi
+  fi
+
+  echo "(v${pacman_file_version})"
+}
+
+function build_pacman ()
+{
+  # Set URL for further info and relative path from pacman file to source files"
+  # Should it be something else, e.g. URL of package in CVS or docs?
+
+  source='../kits'
+
+  # get package name and version from CMT
+  package=$1
+  version=$2
+  cmtpath=$3
+  project_id=$4
+  is_internal=$5
+
+  # External packages (those with export_paths) are split into two kits:
+  # o The internal part, which follows the naming convention for internal packages
+  # o The external part, which only refers to the package version (no mention of
+  #   the project)
+
+  # Naming cnvention:
+  #  external packages : <package>-<version>-<platform>
+  #  internal packages : <projectid>/<package>-<platform>
+
+  if test "${is_internal}" = "no"; then
+    # first build the pacman file for the external stuff
+
+    if test "${native_version}" = ""; then
+      vv=`echo ${version} | sed -e 's#'^${package}-'##'`
+      download_filename="${package}-${vv}${platform_suffix}"
+    else
+      vv=${native_version}
+      download_filename="${package}-${vv}${platform_suffix}"
+    fi
+
+    pacman_filename=${download_filename}.pacman
+
+    echo "build_pacman> Create pacman file for external stuff ${pacman_filename}"
+
+    pacman_file_version=`get_pacman_file_version ${cache_dir}/${pacman_filename}`
+
+    if test -f ${cache_dir}/${pacman_filename};  then
+      mv ${cache_dir}/${pacman_filename} ${cache_dir}/${pacman_filename}.bak
+      if test ! $? = 0; then
+        echo "create_kit> failed to rename ${cache_dir}/${pacman_filename} to ${cache_dir}/${pacman_filename}.bak"
+        exit 1
+      fi
+    fi
+
+    # write pacman file
+
+    cat <<EOF >>${cache_dir}/${pacman_filename}
+
+description ('External Package ${package} ${version} ${platform} ${pacman_file_version}')
+
+source = '${source}'
+download = { '*':'${download_filename}.tar.gz' }
+
+EOF
+
+  fi
+
+  # Figure out dependencies from CMT.
+  # Only take directly used packages, not those used indirectly;
+  #   let pacman handle the cascade.
+
+  #echo "CMTUSERCONTEXT=${CMTUSERCONTEXT}"
+
+  #${cmtexe} show uses
+
+  #
+  # Filter the requirements file patch if any to get the direct use statements.
+  # The cmt show uses does NOT show the use statements obtained from the CMTUSERCONTEXT thus
+  # they have to be added manually here.
+  #
+  depsv=`(if test ! "${patch_requirements}" = ""; then grep use ${patch_requirements} | sed -e 's/use /# use /'; fi; ${cmtexe} show uses) | cat | awk -f ${here}/get_depends.awk`
+
+  ### echo "depsv=[${depsv}]"
+
+  if test -f "${cyclefile}" ; then
+    new_depsv=`filter_deps ${cyclefile} ${depsv}`
+    if test ! "${new_depsv}" = "${depsv}"; then
+      echo "Filtered dependencies: "
+      echo "depsv=[${depsv}]"
+      echo "new_depsv=[${new_depsv}]"
+      depsv=${new_depsv}
+    fi
+  fi
+
+  if test "${project_id}" = ""; then
+    release_id=${release}
+    vv=`echo ${version} | sed -e 's#'^${package}-'##'`
+  else
+    release_id=${project_id}
+    vv=${project_id}
+  fi
+
+  echo "++++ project_id=${project_id} release_id=${release_id} vv=${vv}"
+
+  # Format the depend statement according to Pacman syntax 
+  #
+  if test "${depsv}" = ""; then
+    depends=""
+  else
+    project_dep=`echo ${project}${platform_suffix} | sed -e 's#/#-#'`
+    if test "${project_dep}" = "contrib-CMT${platform_suffix}"; then
+      project_dep="CMTCONFIG-${cmtversion}${platform_suffix}"
+    fi
+    depends="package ('${project_dep}')"
+    first=yes
+    for f in `echo ${depsv}`; do
+      p=`echo ${f} | cut -d: -f1`
+      v=`echo ${f} | cut -d: -f2`
+      pp=`echo ${f} | cut -d: -f3 | sed -e 's#/$##'`
+
+      for path_item in `echo ${CMTPATH} | sed -e "s#[:]# #g"`; do
+        if test "${path_item}" = "${pp}"; then break; fi
+	if test "${p}" = "CMT"; then break; fi
+        if test "${pp#${path_item}}" != "${pp}"; then
+	  pp=${path_item}
+	  break;
+        fi
+      done
+
+      proj=`basename ${pp}`
+
+      if test "${proj}" = "cmtdev"; then
+	  proj="CMT"
+      fi
+
+      if test "${proj}" = "contrib"; then
+	  proj="CMT"
+      fi
+
+      if test "${p}" = "CMT"; then
+	g="${v}"
+      else
+        g="${proj}/${p}${platform_suffix}"
+      fi
+
+      echo "create_kit> Add dependency to ${g}"
+
+      depends="${depends}
+package ('${g}')"
+    done
+
+    if test "${is_internal}" = "no"; then
+
+      if test "${native_version}" = ""; then
+        g=`echo "${package}-${version}${platform_suffix}" | sed -e 's#'${package}-${package}'#'${package}'#'`
+      else
+        g="${package}-${native_version}${platform_suffix}"
+      fi
+
+      depends="${depends}
+package ('${g}') "
+    fi
+
+  fi
+
+  ##echo "project=${project} project_id=${project_id} vv=${vv} depends=${depends}"
+
+  download_filename=${vv}/${package}${platform_suffix}
+  mkdir -p ${cache_dir}/${vv}
+
+  pacman_filename=${download_filename}.pacman
+
+  echo "build_pacman> Create pacman file ${pacman_filename}"
+
+
+  pacman_file_version=`get_pacman_file_version ${cache_dir}/${pacman_filename}`
+
+  if test -f ${cache_dir}/${pacman_filename};  then
+    mv ${cache_dir}/${pacman_filename} ${cache_dir}/${pacman_filename}.bak
+    if test ! $? = 0; then
+      echo "failed to rename ${cache_dir}/${pacman_filename} to ${cache_dir}/${pacman_filename}.bak"
+      exit 1
+    fi
+  fi
+
+  package_pacman_post_install=`macro_value ${package}_pacman_post_install`
+
+  if test ! -z "${package_pacman_post_install}"; then
+    package_pacman_post_install="${package_pacman_post_install};"
+  fi
+
+  if test -f version.cmt; then
+    versionpattern=""
+  else
+    versionpattern="/*"
+  fi
+
+  install="shell ('. "'$'"PACMAN_INSTALLATION/CMT/*/mgr/setup.sh; cd "'$'"PACMAN_INSTALLATION/${project}/${offset}${package}${versionpattern}/cmt; "'$'"CMTROOT/"'$'"CMTBIN/cmt.exe -quiet -no_cleanup config; ${package_pacman_post_install} a=1')"
+
+  # write pacman file
+
+  cat <<EOF >>${cache_dir}/${pacman_filename}
+
+description ('Package ${package} ${version} ${platform} in project=${project} ${pacman_file_version}')
+
+source = '${source}/${vv}'
+download = { '*':'${package}${platform_suffix}.tar.gz' }
+
+${default_depends}
+${depends}
+${install}
+
+EOF
+
+  status=$?
+
+  pacman_default_hints=`macro_value pacman_default_hints`
+  if test ! "${pacman_default_hints}" = ""; then
+    n=`basename ${pacman_default_hints}`
+    cmt -quiet filter ${pacman_default_hints} ${tempcopydir}/${n}
+    cat ${tempcopydir}/${n} >>${cache_dir}/${pacman_filename}
+    /bin/rm -f ${tempcopydir}/${n}
+  fi
+
+  package_pacman_hints=`macro_value ${package}_pacman_hints`
+  if test ! "${package_pacman_hints}" = ""; then
+    n=`basename ${package_pacman_hints}`
+    cmt -quiet filter ${package_pacman_hints} ${tempcopydir}/${n}
+    cat ${tempcopydir}/${n} >>${cache_dir}/${pacman_filename}
+    /bin/rm -f ${tempcopydir}/${n}
+  fi
+
+  ##echo ${status}
+
+}
+
+function acquire_sources ()
+{
+  echo "Now acquiring sources"
+  module=`cat ../CVS/Repository`
+  cvsroot=`cat ../CVS/Root`
+  #echo "version=${version}"
+  #echo "package=${package}"
+  #echo "offset=${offset}"
+  #echo "project=${project}"
+  #echo "kits_dir=${kits_dir}"
+  #echo "tempcopydir=${tempcopydir}"
+
+  project_id=`basename ${project}`
+  project_name=`dirname ${project}`
+
+  rm -rf ${tempcopydir}
+
+  mkdir -p ${tempcopydir}/${project}/${offset}
+
+  cvstag=`cvs status requirements | grep 'Sticky Tag' | awk '{print $3}'`
+  if test "${cvstag}" = "(none)"; then
+    cvstag="HEAD"
+  fi
+  echo "cvstag=${cvstag}"
+
+  echo "Now exporting the sources from CVS"
+  (cd ${tempcopydir}/${project}; cvs -d ${cvsroot} export -r ${cvstag} -d ${offset}${package} ${module})
+  ls ${tempcopydir}
+
+  echo "Now constructing the source tar ball"
+  mkdir -p ${kits_dir}/${project_id}
+  (cd ${tempcopydir}; tar czf ${kits_dir}/${project_id}/${package}-src.tar.gz . )
+}
+
+#--------------------------------------------
+# main
+#
+#   First argument is the location where all resulting 
+#  tar files will be created.
+#
+
+##set -x
+
+date
+
+##echo "args=[$*]"
+
+cmtexe=${CMTROOT}/${CMTBIN}/cmt.exe
+
+rpm=
+pacman_base=
+kits_dir=`pwd`/kits
+cache_dir=`pwd`/cache
+minimal=no
+pacman_only=no
+patch_dir=
+patch_requirements=
+platform=
+platform_suffix=
+override=no
+do_source_kit=no
+
+while test ! $# = 0; do
+
+  if test "$1" = "-rpm"; then
+    rpm=1
+  elif test "$1" = "-release"; then
+    shift
+    release=$1;
+  elif test "$1" = "-cycles"; then
+    shift
+    cyclefile=$1
+  elif test "$1" = "-patches"; then
+    shift
+    patch_dir=$1
+  elif test "$1" = "-minimal"; then
+    minimal=yes
+  elif test "$1" = "-pacman_only"; then
+    pacman_only=yes
+  elif test "$1" = "-platform"; then
+    shift
+    platform=$1
+    platform_suffix="-${platform}"
+  elif test "$1" = "-override"; then
+    override=yes
+  elif test "$1" = "-source"; then
+    do_source_kit=yes
+    platform="src"
+    platform_suffix="-src"
+  else
+    pacman_base=$1
+    kits_dir=${pacman_base}/kits
+    cache_dir=${pacman_base}/cache
+  fi
+  shift
+done
+
+if test "${pacman_base}" = ""; then
+  usage
+  exit 0
+fi
+
+if test ! -d ${kits_dir}; then
+  mkdir -p ${kits_dir}
+fi
+
+if test ! -d ${cache_dir}; then
+  mkdir -p ${cache_dir}
+fi
+
+#---------------
+# AWK scripts are expected at the same location as this one.
+#
+here=`dirname $0`
+here=`(cd ${here}; pwd)`
+#---------------
+
+#---------------
+# Prepare temporary file management
+#
+tempprefix=/tmp/CMT$$
+if test ! "${TMP}" = ""; then
+  tempprefix=${TMP}/CMT$$
+fi
+
+tempfile1=${tempprefix}/t$$
+tempfile2=${tempprefix}/u$$
+tempcopydir=${tempprefix}/c$$
+tempmacros=${tempprefix}/macros$$
+tempmacrosstandalone=${tempprefix}/macrosstandalone$$
+tempconstituents=${tempprefix}/constituents$$
+tempcmtusercontext=${tempprefix}/d$$
+
+trap "if test -d ${tempprefix} ; then chmod -R +w ${tempprefix}; fi; /bin/rm -rf ${tempprefix}" 0 1 2 15
+
+if test -d ${tempprefix} ; then chmod -R +w ${tempprefix}; fi
+/bin/rm -rf ${tempprefix}
+mkdir -p ${tempprefix}
+#---------------
+
+#---------------
+# Compute environment
+#
+
+h=`cmt -quiet show pwd`
+
+root=`dirname $h`
+
+cmtversion=`cmt version`
+version=`cmt -quiet show version`
+if test "${version}" = "v*"; then
+  version=v1
+fi
+
+cmt -quiet build tag_makefile > ${tempmacros}
+cmt -quiet filter ${tempmacros} ${tempmacros}A; mv ${tempmacros}A ${tempmacros}
+
+cmt -quiet -tag=STANDALONE build tag_makefile > ${tempmacrosstandalone}
+cmt -quiet -tag=STANDALONE filter ${tempmacrosstandalone} ${tempmacrosstandalone}A; mv ${tempmacrosstandalone}A ${tempmacrosstandalone}
+
+cmt -quiet show constituents > ${tempconstituents}
+cmt -quiet filter ${tempconstituents} ${tempconstituents}A; mv ${tempconstituents}A ${tempconstituents}
+
+package=`macro_value package`
+
+#offset=`get_offset`
+offset=`macro_value ${package}_offset`
+
+if test ! "${offset}" = ""; then
+  offset="${offset}/"
+fi
+
+cmtpath=`macro_value ${package}_cmtpath`
+if test "${cmtpath}" = ""; then
+  cmtpath=`macro_value ${package}_root`
+  cmtpath=`dirname ${cmtpath}`
+  cmtpath=`dirname ${cmtpath}`
+fi
+
+if test "${cmtpath}" = "/"; then
+  cmtpath="${cmtpath}${offset}"
+  offset=
+fi
+
+project=`get_project`
+if test ! "${project}" = ""; then
+  project_id=`basename ${project}`
+fi
+
+echo "# Working on ${package} ${version} ${offset} in ${cmtpath} of project ${project} ${project_id}"
+
+#---------------
+# Prepare temporary file management
+#
+tempprefix=/tmp/CMT$$
+if test ! "${TMP}" = ""; then
+  tempprefix=${TMP}/CMT$$
+fi
+
+tempfile1=${tempprefix}/t$$
+tempfile2=${tempprefix}/u$$
+tempcopydir=${tempprefix}/c$$
+tempcmtusercontext=${tempprefix}/d$$
+
+trap "if test -d ${tempprefix} ; then chmod -R +w ${tempprefix}; fi; /bin/rm -rf ${tempprefix}" 0 1 2 15
+
+if test -d ${tempprefix} ; then chmod -R +w ${tempprefix}; fi
+/bin/rm -rf ${tempprefix}
+#---------------
+
+#---------------
+# Prepare the patch structure
+#
+if test ! "${patch_dir}" = ""; then
+
+  if test -d ${patch_dir}/${project_id}; then
+
+    echo "create_kit> ${patch_dir}/${project_id}"
+
+    mkdir -p ${tempcmtusercontext}
+
+    export CMTUSERCONTEXT=${tempcmtusercontext}
+    export patch_requirements=${tempcmtusercontext}/requirements
+
+    echo "" >| ${patch_requirements}
+
+    if test -f ${patch_dir}/${project_id}/requirements; then
+      cat ${patch_dir}/${project_id}/requirements >>${patch_requirements}
+    fi
+
+    if test -f ${patch_dir}/${project_id}/${package}/requirements; then
+      cat ${patch_dir}/${project_id}/${package}/requirements >>${patch_requirements}
+    fi
+  fi
+fi
+#---------------
+
+native_version=`macro_value ${package}_native_version`
+export_paths=`macro_value ${package}_export_paths`
+
+if test "${export_paths}" = ""; then
+  is_internal="yes"
+else
+  is_internal="no"
+fi
+
+if test "${do_source_kit}" = "yes"; then
+  is_internal="yes"
+fi
+#---------------
+
+#---------------
+#  Prepare the temporary copy directory
+#
+mkdir -p ${tempcopydir}
+
+copycmd="ln -s"
+
+build_pacman ${package} ${version} ${cmtpath} ${project_id} ${is_internal}
+
+if test "${do_source_kit}" = "yes"; then
+
+  acquire_sources
+
+elif test "${pacman_only}" = "no"; then
+
+  acquire_CMT_files
+
+  if test ! "${minimal}" = "yes"; then
+
+    cmt_project_name=`macro_value project`
+    installarea_prefix=`macro_value ${cmt_project_name}_installarea_prefix`
+    project_install_area="${project}/${installarea_prefix}"
+
+    acquire_libraries
+    acquire_java
+    acquire_applications
+    acquire_runtime_files
+    acquire_jo_files
+    acquire_python_modules_files
+    acquire_xml_files
+    acquire_headers
+    acquire_scripts_files
+    acquire_lcg_modules
+    acquire_export_installed_files
+  fi
+
+  #
+  # First create the tar ball with internal stuff
+  #
+  echo "create_kit> create tar for internal contents"
+  create_tar yes
+
+  if test "${is_internal}" = "no"; then
+
+    /bin/rm -rf ${tempfile1} ${tempfile2} ${tempcopydir}
+
+    project_id=
+
+    if test ! "${minimal}" = "yes"; then
+
+      ##acquire_export_paths ${export_paths}
+
+      acquire_export_paths ${export_paths}
+    fi
+
+    echo "create_kit> create tar for exported files"
+    create_tar ${override}
+
+  fi
+fi
+
+#create_RPM
+
+date
+
+if test -d ${tempprefix} ; then chmod -R +w ${tempprefix}; fi
+/bin/rm -rf ${tempprefix}
+
+#---------------
+#  Eventually, all temporary directories are automatically removed by the trap
+#
+exit 0
Index: cmtpacman/HEAD/HEAD/scripts/create_project_kits.sh
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/create_project_kits.sh	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/create_project_kits.sh	(revision 53)
@@ -0,0 +1,160 @@
+
+function get_pacman_file_version ()
+{
+  old_file=$1
+  shift
+
+  pacman_file_version=1
+  if test -f ${old_file};  then
+    pacman_file_version=`grep description ${old_file} | egrep '[(]v' | sed -e 's#.*(v##' -e 's#).*##'`
+    if test "${pacman_file_version}" = ""; then
+      pacman_file_version=1
+    else
+      pacman_file_version=`expr ${pacman_file_version} + 1`
+    fi
+  fi
+
+  echo "(v${pacman_file_version})"
+}
+
+function build_one_project ()
+{
+  p_id=`basename ${project_path}`
+  p_name=`dirname ${project_path}`
+  p_name=`basename ${p_name}`
+
+  # echo "p_id=${p_id} p_name=${p_name} "
+
+  pacman_base_filename=${p_name}-${p_id}${platform_opt}
+  pacman_filename=${pacman_base_filename}.pacman
+
+  pacman_file_version=`get_pacman_file_version ${cache_dir}/${pacman_filename}`
+
+  if test -f ${cache_dir}/${pacman_filename};  then
+    mv ${cache_dir}/${pacman_filename} ${cache_dir}/${pacman_filename}.bak
+    if test ! $? = 0; then
+      echo "failed to rename ${cache_dir}/${pacman_filename} to ${cache_dir}/${pacman_filename}.bak"
+      exit 1
+    fi
+  fi
+
+  if test -f ${project_path}/cmt/project.cmt; then
+    download_filename="${pacman_base_filename}"
+    download_text="download = { '*':'${download_filename}.tar.gz' }"
+  fi
+
+  cat <<EOF >|${cache_dir}/${pacman_filename}
+
+description='Project description for ${p_name} ${p_id} ${platform_opt} ${pacman_file_version}'
+
+url = 'http://atlas.web.cern.ch/Atlas/GROUPS/SOFTWARE/OO/Development/'
+
+depends = [ '${previous}' ]
+
+usePackageRoot = 0
+
+source = '${source}'
+${download_text}
+
+paths = [ ['CMTPATH', '\$PACMAN_INSTALLATION/${p_name}/${p_id}'] ]
+
+EOF
+
+  if test -f ${project_path}/cmt/project.cmt; then
+
+    echo "Constructing the tar ball of the project file"
+
+    mkdir -p ${tempcopydir}/${p_name}/${p_id}
+    cp -R ${project_path}/cmt ${tempcopydir}/${p_name}/${p_id}
+    (cd ${tempcopydir}; tar czvf ${kits_dir}/${download_filename}.tar.gz ${p_name} --exclude=CVS)
+
+  fi
+
+  previous="${p_name}-${p_id}${platform_opt}"
+}
+
+#---------------
+# Prepare arguments and options
+#
+platform=
+platform_opt=
+
+while test ! $# = 0; do
+
+  if test "$1" = "-platform"; then
+    shift
+    platform=$1
+    platform_opt="-${platform}"
+  fi
+  shift
+done
+
+cmtversion=`cmt version`
+
+if test "${CMTPATH}" = ""; then
+  echo "Please define first CMTPATH"
+  exit 1
+fi
+
+#---------------
+
+#---------------
+# Prepare the pacman cache environment
+#
+if test "${PACMAN_CACHE}" = ""; then
+  echo "Please define first the PACMAN_CACHE"
+  exit 1
+fi
+
+cache_dir=${PACMAN_CACHE}/cache
+kits_dir=${PACMAN_CACHE}/kits
+source='../kits'
+
+if test ! -d ${cache_dir}; then
+  mkdir -p ${cache_dir}
+fi
+
+if test ! -d ${kits_dir}; then
+  mkdir -p ${kits_dir}
+fi
+#---------------
+
+
+#---------------
+# Revert the order of CMTPATH (ie of projects)
+#
+reverse=
+for f in `echo ${CMTPATH} | sed -e 's#[:]# #g'`; do
+  reverse="${f} ${reverse}"
+done
+#---------------
+
+#---------------
+# Prepare temporary file management
+#
+tempprefix=/tmp/CMT$$
+if test ! "${TMP}" = ""; then
+  tempprefix=${TMP}/CMT$$
+fi
+
+tempcopydir=${tempprefix}/c$$
+
+trap "if test -d ${tempprefix} ; then chmod -R +w ${tempprefix}; fi; /bin/rm -rf ${tempprefix}" 0 1 2 15
+
+if test -d ${tempprefix} ; then chmod -R +w ${tempprefix}; fi
+/bin/rm -rf ${tempprefix}
+#---------------
+
+#---------------
+# Loop over projects in reverse order
+#
+previous="CMTCONFIG-${cmtversion}${platform_opt}"
+
+for f in `echo ${reverse}`; do
+  echo "--------------------------------------------"
+  echo "Building kit for project_path=${f}"
+  project_path=${f}
+  build_one_project
+done
+#---------------
+
Index: cmtpacman/HEAD/HEAD/scripts/excludes.txt
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/excludes.txt	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/excludes.txt	(revision 53)
@@ -0,0 +1,13 @@
+CVS
+dot
+lefty
+neato
+cmtshowuses.exe
+setup.sh
+setup.csh
+cleanup.sh
+cleanup.csh
+Makefile
+*.make
+external_links.dat
+excludes.dat
Index: cmtpacman/HEAD/HEAD/scripts/filter_links.sh
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/filter_links.sh	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/filter_links.sh	(revision 53)
@@ -0,0 +1,76 @@
+
+##set -x
+
+check_external_link ()
+{
+  file=$1
+  shift
+
+  if test -z "${file}"; then return 1 ; fi
+  if test ! -L "${file}"; then return 1 ; fi
+
+  a=`ls -l $file | awk '{ print $9 ":" $11}'`
+
+  src=`echo $a | cut -d: -f1`
+  dest=`echo $a | cut -d: -f2`
+
+  if test -z "${dest}"; then
+    return 1
+  fi
+
+  d=`dirname ${src}`
+  if test "${d}" = "."; then d=; fi
+
+  hsrc=`(cd ${root}/${d}; pwd)`
+
+  d=`dirname ${dest}`
+  if test "${d}" = "."; then d=; fi
+
+  if test -z `echo ${d} | egrep -e '^/'`; then
+    hdest=`(cd ${hsrc}/${d}; pwd)`
+  else
+    hdest=`(cd ${d}; pwd)`
+  fi
+
+  while test ! -z `echo ${hdest} | egrep '[.][.]'`; do
+    ##echo hdest=${hdest}
+    newhdest=`echo ${hdest} | \
+      sed -e 's#/[^/]*/[.][.]/#/#g' \
+          -e 's#^[^/]*/[.][.]/#/#g' \
+          -e 's#/[^/]*/[.][.]$##'`
+    if test "${newhdest}" = "${hdest}"; then break; fi
+    hdest=${newhdest}
+  done
+
+  hsrc=`echo ${hsrc} | sed -e "s#${root}/##" -e "s#${root}##"`
+  hdest=`echo ${hdest} | sed -e "s#${root}/##" -e "s#${root}##" | egrep '^/'`
+
+  if test ! -z "${hdest}"; then
+    if test -z `egrep -e "${d}" ${here}/keep_links.dat` ; then 
+      echo "${src} ${dest}"
+      return 0
+    fi                                                                                            
+  fi
+
+  return 1
+}
+
+here=`dirname $0`
+if test "${here}" = "."; then here=`pwd`; fi
+if test -z "${here}"; then here=`pwd`; fi
+
+root=$1
+shift
+
+cd ${root}
+
+links=`find . -type l`
+
+for file in `echo ${links}`; do
+  check_external_link ${file}
+  status=$?
+  if test "${status}" = 0; then
+    break
+  fi
+done
+
Index: cmtpacman/HEAD/HEAD/scripts/get_applications.sh
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/get_applications.sh	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/get_applications.sh	(revision 53)
@@ -0,0 +1,19 @@
+
+
+if test -d ../$CMTCONFIG; then
+  cd ../$CMTCONFIG
+
+  pwd=`pwd`
+
+  cmt -quiet show constituents | \
+    grep application | \
+    egrep -v '[.]java' | \
+    awk '{print "'${pwd}/'" $2 ".exe"}'
+
+  ##find . -name '*.exe' -type f | sed -e 's#[.]/#'${pwd}'/#'
+fi
+
+
+
+
+
Index: cmtpacman/HEAD/HEAD/scripts/get_depends.awk
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/get_depends.awk	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/get_depends.awk	(revision 53)
@@ -0,0 +1,31 @@
+###BEGIN {deps = "CMT"}
+{
+  if ($0 ~ "^#[ ]use")
+  {
+    deps = deps " " $3
+  }
+  else if ($1 == "use")
+  {
+    p = $2;
+    v = $3;
+    sub (p "[-]", "", v);
+    version[p] = v;
+    if ($4 ~ "^[(]") {pp = $4} else {pp = $5}
+    if ($NF !~ "^[(]") {pp = $NF}
+    gsub ("[()]", "", pp);
+    path[p] = pp;
+  }
+}
+END {
+  n = split (deps,w);
+  for (i=1; i <= n; i++)
+  {
+    p=w[i];
+    v=version[p];
+    pp=path[p];
+    if (v != "")
+    {
+      print p ":" p "-" v ":" pp;
+    }
+  }
+}
Index: cmtpacman/HEAD/HEAD/scripts/get_java.sh
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/get_java.sh	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/get_java.sh	(revision 53)
@@ -0,0 +1,9 @@
+
+
+if test -d ../classes; then
+  cd ../classes
+
+  pwd=`pwd`
+
+  find . -name '*.jar' | sed -e 's#[.]/#'${pwd}'/#'
+fi
Index: cmtpacman/HEAD/HEAD/scripts/get_libraries.sh
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/get_libraries.sh	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/get_libraries.sh	(revision 53)
@@ -0,0 +1,25 @@
+
+
+package=$1
+shift
+
+
+if test -d ../$CMTCONFIG; then
+  cd ../$CMTCONFIG
+
+  pwd=`pwd`
+
+  cmt -quiet show constituents | \
+    grep library | \
+    egrep -v '[.]java' | \
+    awk '{if ($3 == "-no_share") ext=".a"; else ext=".so"; print "'${pwd}/'lib" $2 ext}'
+
+fi
+
+##cmt show macro_value ${package}_libraries
+
+
+
+
+
+
Index: cmtpacman/HEAD/HEAD/scripts/keep_links.dat
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/keep_links.dat	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/keep_links.dat	(revision 53)
@@ -0,0 +1,2 @@
+/usr/share/libtool
+
Index: cmtpacman/HEAD/HEAD/scripts/tcmt.py
===================================================================
--- cmtpacman/HEAD/HEAD/scripts/tcmt.py	(revision 53)
+++ cmtpacman/HEAD/HEAD/scripts/tcmt.py	(revision 53)
@@ -0,0 +1,31 @@
+
+# -*- coding: iso-8859-1 -*-
+
+import os
+import sys
+import string
+import popen2
+import stat
+import re
+from os import path
+#from optparse import OptionParser
+import tempfile
+import cmt
+import time
+
+#----------------------------------------------------
+# Main
+#----------------------------------------------------
+def main ():
+
+    print time.strftime ('%c')
+
+    pwd = os.getcwd ()
+
+    CMT = cmt.cmt ()
+
+    pack = CMT.macro_value ('package')
+    print 'package=' + pack
+
+if __name__ == '__main__':
+    main()
