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 <|${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 #---------------