if test ! "${KITDEBUG}" = ""; then set -x fi #-------------------------------------------- # # create_kit.sh [options] # # options are: # # -rpm optional (default to norpm) # -cycles optional cycles file (output of cmt show cycles) # -release optional current release id # -platform 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 # ..//* # - 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// # 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 # 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 : # # : # # where 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 # : # # 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

... # # Remove from the list of

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 [