Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:21

0001 #!/bin/bash
0002 
0003 getExternals()
0004 {
0005     mkdir  ${tard}/external
0006 
0007     ext=$CMS_PATH/$SCRAM_ARCH/external # this used to be CMSSW_DATA_PATH
0008     echo "=========================================================="
0009     echo "=========================================================="
0010 
0011     cd $CMSSW_BASE
0012         echo "Copy gcc subdirs"
0013     scram tool tag gcc-ccompiler GCC_CCOMPILER_BASE
0014     gccd_src=`scram tool tag gcc-ccompiler GCC_CCOMPILER_BASE`
0015 set -x
0016     gccd_target=${tard}/external/gcc
0017     mkdir $gccd_target
0018         cp -a $gccd_src/include $gccd_target
0019         cp -a $gccd_src/bin $gccd_target
0020 
0021     if [ `uname` = "Darwin" ]; then
0022            cp -a $gccd_src/lib $gccd_target/lib64
0023     else
0024        cp -a $gccd_src/lib64 $gccd_target/lib64
0025     fi
0026     exit
0027     echo "=========================================================="
0028     echo "=========================================================="
0029 
0030     echo "Copying external libraries from $ext to $extdl."
0031 
0032    # external libraries
0033     extdl=${tard}/external/lib
0034     mkdir $extdl
0035     extt=/tmp/cmsswExt
0036     ls -l $CMSSW_RELEASE_BASE/external/$SCRAM_ARCH/lib/* > $extt
0037    # cp -a $ext/*/*/lib/*  ${tard}/external/lib
0038     for i in boost bz2lib castor clhep dcap db4 dcap \
0039         expat fftw3 gdbm gsl hepmc\
0040         libjpg libpng libtiff libungif \
0041         openssl pcre \
0042         sigcpp  xrootd zlib xz freetype tbb
0043     do
0044         export i;
0045         ever=`grep $i $extt |  perl -ne 'if ($_ =~ /$ENV{i}\/(.*)\/lib\/(.*)/ ) {print "$1\n"; last;}'`
0046         echo "copy $i $ever"
0047         if [ -z "$ever" ]; then
0048             echo "!!!!!!!! can't get externals for $i"
0049         fi
0050         # echo "cp -a $ext/$i/$ever/lib/* === ${extdl}"
0051         cp -a $ext/$i/$ever/lib/* ${extdl}
0052     done
0053 
0054     
0055     echo "=========================================================="
0056     echo "=========================================================="
0057     echo "Copying external headers."
0058 
0059     mkdir ${tard}/external/var-inc
0060     for i in CLHEP HepMC boost sigcpp; do
0061       # scram tool info $i | grep INCL | head -1
0062        edir=`scram tool info $i | grep INCL | head -1| perl -ne 'if ($_ =~/\=(.*)$/) {print "$1\n"}'`
0063        if [ -n $edir ]; then
0064           cp -r $edir/* ${tard}/external/var-inc
0065        fi
0066     done
0067 
0068     echo "=========================================================="
0069     echo "=========================================================="
0070    # can be linked or installed at $ROOTSYS   
0071     ROOTSYS=`echo $ROOTSYS |  sed 's/\/$//'` # remove '/' character  at end of string, becuse it invalidates symblic link interpretation
0072     origr=$ROOTSYS
0073     if [ -L ${ROOTSYS} ]; then
0074         b=`dirname ${ROOTSYS}`   
0075         if [ `uname` = "Linux" ]; then
0076             origr=`readlink -f ${ROOTSYS}`
0077         else
0078             origr=`readlink ${ROOTSYS}`
0079         fi
0080     fi
0081     
0082     echo "copy root from $origr to ${tard}/external/root"
0083    # pushd $PWD
0084    # cd $ROOTSYS
0085    # ROOTSYS=${tard}/external/root make install
0086    # popd
0087     cp -a $origr  ${tard}/external/root
0088      
0089 }
0090 
0091 #----------------------------------------------------------------
0092 getCmsSources()
0093 {
0094     echo "get list from $fwpl"
0095     for i in `cat $fwl` $extra_list
0096     do
0097         # run-away headers
0098         if [ -f $CMSSW_RELEASE_BASE/src/${i} ]; then
0099            mkdir -p  $tard/src/`dirname $i`
0100            cp $CMSSW_RELEASE_BASE/src/$i $tard/src/$i
0101         fi
0102 
0103 
0104         mkdir -p $tard/src/$i
0105         mkdir -p $tard/src/$i/src
0106 
0107         if [ -e  $CMSSW_BASE/src/$i ]; then
0108            cp -rf $CMSSW_BASE/src/${i}/interface $tard/src/$i
0109            cp -rf $CMSSW_BASE/src/${i}/src/*.h $tard/src/$i/src
0110         else
0111            cp -rf $CMSSW_RELEASE_BASE/src/${i}/interface $tard/src/$i
0112            cp -rf $CMSSW_RELEASE_BASE/src/${i}/src/*.h $tard/src/$i/src
0113         fi
0114     done;
0115 }
0116 
0117 #----------------------------------------------------------------
0118 
0119 getFireworksSources()
0120 {
0121    echo "=========================================================="
0122    echo "=========================================================="
0123    echo "getting Fireworks info/config files."
0124    # binary 
0125    mkdir ${tard}/libexec
0126    cp $CMSSW_RELEASE_BASE/bin/$SCRAM_ARCH/cmsShow.exe ${tard}/libexec
0127    cp $CMSSW_RELEASE_BASE/bin/$SCRAM_ARCH/cmsShowSendReport ${tard}/libexec
0128 
0129    if [ -e $CMSSW_BASE/bin/$SCRAM_ARCH/cmsShow.exe ]; then 
0130       cp -f $CMSSW_BASE/bin/$SCRAM_ARCH/cmsShow.exe ${tard}/libexec
0131    fi
0132    if [ -e $CMSSW_BASE/bin/$SCRAM_ARCH/cmsShowSendReport ]; then 
0133       cp -f $CMSSW_BASE/bin/$SCRAM_ARCH/cmsShowSendReport ${tard}/libexec
0134    fi
0135    
0136    # src
0137    srcDir="${tard}/src/Fireworks/Core"
0138    mkdir -p $srcDir
0139    cp -a  $CMSSW_BASE/src/Fireworks/Core/macros $srcDir
0140    cp -a  $CMSSW_BASE/src/Fireworks/Core/icons $srcDir
0141    cp -a  $CMSSW_BASE/src/Fireworks/Core/data $srcDir
0142    cp -a  $CMSSW_BASE/src/Fireworks/Core/scripts $srcDir
0143    
0144    # version info
0145    cv=$tversion;
0146    if [ -z $cv ]; then
0147       cv=`perl -e 'if ($ENV{CMSSW_VERSION} =~ /CMSSW_(\d+)_(\d+)_/) {print "${1}.${2}";}'`
0148    fi
0149    echo $cv > $srcDir/data/version.txt
0150    echo "DataFormats: $CMSSW_VERSION" >> $srcDir/data/version.txt
0151    # cat $srcDir/data/version.txt
0152    cp -a $CMSSW_RELEASE_BASE/src/Fireworks/Core/scripts $srcDir
0153 
0154    # link to config files
0155    cd  $tard
0156    ln -s  src/Fireworks/Core/macros/aod.fwc .
0157    ln -s  src/Fireworks/Core/macros/ispy.fwc .
0158    ln -s  src/Fireworks/Core/macros/pflow.fwc .
0159    ln -s  src/Fireworks/Core/macros/miniaod.fwc .
0160    ln -s  src/Fireworks/Core/macros/simGeo.fwc .
0161    ln -s  src/Fireworks/Core/macros/overlaps.fwc .
0162    
0163    ln -s  src/Fireworks/Core/scripts/cmsShow .   
0164 }
0165 
0166 #----------------------------------------------------------------
0167 
0168 getCmsLibs()
0169 {
0170 mkdir -p $tard/lib
0171     echo "=========================================================="
0172     echo "=========================================================="
0173     echo "get CMS libs"
0174 
0175     libext=".so";
0176     if [ `uname` = "Darwin" ]; then
0177       libext=".dylib";
0178     fi
0179 
0180     cat $fwl | grep -v '\.h$' >  ${fwl}tmp
0181     # remove package without libs
0182     perl -i -ne 'print unless /Fireworks\/Macros/'         ${fwl}tmp
0183     perl -i -ne 'print unless /FWCore\/PythonUtilities/'   ${fwl}tmp
0184     perl -i -ne 'print unless /DataFormats\/MuonData/'     ${fwl}tmp
0185     perl -i -ne 'print unless /Utilities\/ReleaseScripts/' ${fwl}tmp
0186 
0187 
0188     libl=`cat ${fwl}tmp |  perl -ne 'if( ~/(.+)\/(.+)$/){print "$1$2 ";}'`
0189     libl_extra=`echo $extra_list | perl -pe '{ s/\///og;}'`
0190 
0191     echo "get FWLite libraries"
0192 
0193     cn=${tard}/lib/.edmplugincache;
0194     for i in $libl $libl_extra; do
0195        if [ -e  $CMSSW_BASE/lib/$SCRAM_ARCH/lib${i}.$libext ]; then
0196               cp -f $CMSSW_BASE/lib/$SCRAM_ARCH/*${i}* $tard/lib
0197        else
0198               cp -f $CMSSW_RELEASE_BASE/lib/$SCRAM_ARCH/*${i}* $tard/lib
0199        fi
0200            grep $i  $CMSSW_RELEASE_BASE/lib/$SCRAM_ARCH/.edmplugincache  >> $cn
0201            grep $i  $CMSSW_BASE/lib/$SCRAM_ARCH/.edmplugincache  >> $cn
0202     done
0203 
0204     echo "getting libs from $CMSSW_BASE/lib/$SCRAM_ARCH"
0205     cp -f $CMSSW_BASE/lib/$SCRAM_ARCH/* ${tard}/lib/
0206 
0207     sort -u  $cn -o  $cn
0208     
0209     rm ${fwl}tmp
0210 }
0211 
0212 #----------------------------------------------------------------
0213 
0214 getDataFiles()
0215 {
0216    echo "=========================================================="
0217    echo "=========================================================="
0218    echo "get data files"
0219    # sample files
0220    cd ${tard}
0221    name=`perl -e '($ver, $a, $b, $c) = split('_', $ENV{CMSSW_VERSION}); print  "data", $a, $b, ".root"  '`
0222    $dwnCmd data.root  http://amraktad.web.cern.ch/amraktad/scratch0/data/$name
0223 
0224  #  mc_name=`perl -e '($ver, $a, $b, $c) = split('_', $ENV{CMSSW_VERSION}); print  "mc", $a, $b, ".root"  '`
0225  #  $dwnCmd mc.root http://amraktad.web.cern.ch/amraktad/mail/scratch0/data/$mc_name
0226 
0227    #geometry files
0228    cp $CMSSW_RELEASE_BASE/external/$SCRAM_ARCH/data/Fireworks/Geometry/data/cmsSimGeom-* ${tard}
0229    cp $CMSSW_RELEASE_BASE/external/$SCRAM_ARCH/data/Fireworks/Geometry/data/cmsGeom10.root ${tard}
0230 }
0231 
0232 #----------------------------------------------------------------
0233 
0234 makeTar()
0235 {
0236    bdir=`dirname $tard`
0237    cd $bdir
0238    tname=`basename $tard`
0239    if [ `uname` = "Darwin" ]; then
0240        echo "Packing tarball ${tname}.mac.tar.gz"
0241        tar -czf ${tname}.mac.tar.gz $tname
0242    else
0243        echo "Packing tarball ${tname}.linux.tar.gz"
0244        tar -czf ${tname}.linux.tar.gz $tname
0245    fi
0246 }
0247 
0248 
0249 #----------------------------------------------------------------
0250 #----------------------------------------------------------------
0251 #----------------------------------------------------------------
0252 
0253 usage() { echo "Usage: $0  --tar --version=<version> --dir=<destDir> --verbose --force" ; exit;}
0254 
0255 for i in "$@"
0256 do
0257 case $i in
0258     --dir=*)
0259     tard="${i#*=}"
0260     echo "Destination directory  == [$tard]"
0261     shift;
0262     ;;
0263     --version=*)
0264     tversion="${i#*=}"
0265     echo "Tarball version  == $tversion"
0266     shift;
0267     ;;
0268     --tar)
0269     doTar=YES
0270     echo "Do tar&zip after extraction"
0271     shift;
0272     ;;
0273     --verbose)
0274     set -x
0275     shift;
0276     ;;
0277     --force)
0278     doForce=1;
0279     shift;
0280     ;;
0281     --fwlite=*)
0282     fwlite_list="${i#*=}"
0283     shift;
0284     ;;
0285     *)
0286 echo "usage [$i] ----"
0287     usage
0288     ;;
0289 esac
0290 done
0291 
0292 export tard
0293 tard=`perl -e '{$a = $ENV{tard}; $a =~ s/^~/$ENV{HOME}/;$a =~ s/^\./$ENV{PWD}/; print "$a"; }'`
0294 
0295 
0296 if [ -z $tard ]; then
0297 echo "Destination directory not specified"
0298 usage
0299 fi
0300 
0301 echo -e "Start packaging .... \n"
0302 
0303 
0304 
0305 if [ -z $doForce ] && [ -e $tard ] ; then
0306    echo "Destination directory  [$tard] already exists. Use --force option."
0307    exit 1;
0308 fi
0309 
0310 mkdir $tard
0311 
0312 dwnCmd="wget --no-check-certificate -O "
0313 if [ `uname` = "Darwin" ]; then
0314     dwnCmd="curl --insecure -o "
0315 fi
0316 
0317 origd=$PWD
0318 
0319 if [ -z fwlite_list ]; then
0320    fwl="/tmp/fwlite_build_set.file"
0321    $dwnCmd $fwl https://raw.githubusercontent.com/cms-sw/cmsdist/IB/CMSSW_7_3_X/stable/fwlite_build_set.file
0322 else
0323    fwl=$fwlite_list
0324 fi
0325 extra_list="/CondFormats/Serialization /Geometry/CommonDetUnit /DataFormats/MuonSeed"
0326 
0327 
0328 getExternals
0329 getCmsSources
0330 getFireworksSources
0331 
0332 
0333 getCmsLibs
0334 
0335 
0336 getDataFiles
0337 echo $tard
0338 if [ -n "$doTar" ] ; then
0339    makeTar
0340 fi
0341