#!/bin/sh # # @RDE_HEADER@ # $Id$ # $HeadURL$ # $Author$ # env file_location=`pwd` echo "Comment: current wd is: " `pwd` ### ### Presets ### PROJECT="GUEZ" xlsxfile=GUEZ_BWDLZ_BA-0_BA-IV_Transformationspunkte_201210_Korrektur_2021-12-16 xlsxfile=GUEZ_BWDLZ_BA-0_BA-IV_Transformationspunkte_201210_Korrektur_2021-12-16_Umbenn2022-02-24 SPD_BLDGS=../GuezBuildings/buildings LOCATIONS_LIST="ba0 ba1 ba2 ba3 ba4 salchau" echo "Comment: remove some temporary files... revert some other..." rm -v GUEZ_BWDLZ*.csv rm -v ./import*.csv rm -v ./${xlsxfile}* rm -v vwm_adjustment*.log rm -v checkProtective*.log rm -v checkDuplicateNames*.log ### ### revert *.spec ### svn revert *.spec ### ### check-out / revert bldgs ### echo "Comment: revert bldgs: $SPD_BLDGS ..." rm -rfv $SPD_BLDGS/bldg_3145_47 svn revert -R $SPD_BLDGS ### # remove uneeded: bldg_hierarchie.flt, directory bldg_EGCU_test ### rm -v $SPD_BLDGS/bldg_hierarchie.flt rm -rfv $SPD_BLDGS/bldg_EGCU_test mv -v $SPD_BLDGS/bldg_3145-47 $SPD_BLDGS/bldg_3145_47 find $SPD_BLDGS -iname "*egcu2room*" -delete find $SPD_BLDGS -iname "*.wrl" -delete find $SPD_BLDGS -iname "*.patch" -delete ### # fix syntax: bldg_3141_26.flt.VWM_Building.xml ### BEFORE="20<\/OuterWallProtectiveFactor>" AFTER="20<\/OuterWallProtectiveFactor>" sed -i "s/${BEFORE}/${AFTER}/g" $SPD_BLDGS/bldg_3141_26/bldg_3141_26.flt.VWM_Building.xml if [ $? -ne 0 ]; then echo "sed command failed" ; fi # Fix bldg_3101 (16.787/16.786 ; remove linear dependencies (GUEZE-605, GUEZE-717 ; CheckAwesOnBldg_3101_verteilt.sh) sed -i 's/16.787/16.786/g' $SPD_BLDGS/bldg_3101/bldg_3101.flt.xml sed -i 's/16.787/16.786/g' $SPD_BLDGS/bldg_3101/bldg_3101.flt.VWM_Building.xml # remove 1141n rm -rv $SPD_BLDGS/bldg_1141n ### ### Apply some patches: early to be idenpendent from modifications by replace_transistion_factors etc. ### # Do it here, because the final xml structure is avaible now (node.js converts to json and back to xml....) # # fix Bbox / placement of 4 roomnames at 3101: 102, 108, 109, 112 # # diff -Naur ./bldg_3100/bldg_3100.flt.VWM_Building.xml ./bldg_3100/bldg_3100.flt.VWM_Building.xmlOKAY # cp -v ./patches/* $SPD_BLDGS if [ $? -ne 0 ]; then echo "copy command (patches) failed" ; fi pushd $SPD_BLDGS if [ $? -ne 0 ]; then echo "cd command failed" ; fi echo "Comment: cd building ; patching.." echo "Comment: current wd is: " `pwd` dos2unix ./bldg_3101/bldg_3101.flt.xml cp ./bldg_3101/bldg_3101.flt.xml ./bldg_3101/bldg_3101.flt.xml_bak patch -p1 < patch_bldg_3101.flt.xml.patch if [ $? -ne 0 ]; then echo "patch (patch_bldg_3101.flt.xml.patch) failed" ; exit ; fi # add missing OuterWallProtectiveFactor # 2021-11-19: patch ist scheinbar obsolet: #dos2unix bldg_3100/bldg_3100.flt.VWM_Building.xml #patch -p1 < patch_bldg_3100.flt.VWM_Building.xml.patch # if [ $? -ne 0 ]; then echo "patch (patch_bldg_3100.flt.VWM_Building.xml.patch) failed" ; fi # add missing neigbors (bldg_2101: quick and dirty: just from top to bottom...) dos2unix bldg_2101/bldg_2101.flt.VWM_Building.xml cp bldg_2101/bldg_2101.flt.VWM_Building.xml bldg_2101/bldg_2101.flt.VWM_Building.xml_bak patch -p1 < patch_bldg_2101.flt.VWM_Building.xml.patch if [ $? -ne 0 ]; then echo "patch (patch_bldg_2101.flt.VWM_Building.xml.patch) failed" ; exit ; fi # move 2 REF_MOD / BSM from outdoor to correct room: bldg_1251.flt.xml (GUEZE-973) # patch_bldg_1251.flt.xml.patch not required anymore #dos2unix bldg_1251/bldg_1251.flt.xml #cp bldg_1251/bldg_1251.flt.xml bldg_1251/bldg_1251.flt.xml_bak #patch -p1 < patch_bldg_1251.flt.xml.patch # if [ $? -ne 0 ]; then echo "patch (patch_bldg_1251.flt.xml.patch) failed" ; exit ; fi popd ### ### check ProtectiveFactor according VEMAG ### # Wall -> 200 # Ceiling -> 200 # ExclusiveDoor -> 20 # ExclusiveWindow -> 0 # echo "Comment: checkProtectiveFactors ..." echo "Comment: current wd is: " `pwd` ./checkProtective.sh > checkProtective.log protectiveErrorCnt=`cat checkProtective.log | grep "failure" | wc -l` echo -e "Comment: Problems regarding wrong protectiveFactors at some files: cnt: $protectiveErrorCnt" ### ### xmllint ### echo "Comment: verify xml using xmllint on $SPD_BLDGS ..." rm /tmp/xmllintDummyout.xml find $SPD_BLDGS -iname "*.xml" | xargs xmllint > /tmp/xmllintDummyout.xml if [ $? -ne 0 ]; then echo "xmllint failed" ; exit else echo "xmllint successfull" fi ### ### check duplicate names ### echo "Comment: check duplicate names on $SPD_BLDGS ..." ./checkDuplicateNames.sh $SPD_BLDGS > checkDuplicateNames.log checkDuplicateNamesCnt=`cat checkDuplicateNames.log | grep "flt" | wc -l` echo -e "Comment: Problems regarding duplicate Names at some files: cnt: $checkDuplicateNamesCnt" ### ### update _Transformationspunkte ### #### echo "Comment: update _Transformationspunkte......" cd $SPD_BLDGS/../_Transformationspunkte svn up --username thoden --password SPDsvnTH cd - #### ### ### Create VERSION_STR (containing a) rev of SPD and b) of this scripts) ### # result will look like '4573.53084' # echo "Comment: create VERSION_STR..." echo "Comment: current wd is: " `pwd` # get last mod rev and remove whitespace VERSION_POST_PROC=`svn info . | grep -E 'Letzte ge|Last Changed Rev' | awk -F ':' '{print $2 }'` VERSION_POST_PROC=`echo $VERSION_POST_PROC | sed -e 's/[[:space:]]*$//'` echo "VERSION_POST_PROC = '$VERSION_POST_PROC'" if [ -z "$VERSION_POST_PROC" ] ; then echo "VERSION_POST_PROC could not be determined" ; exit; fi # get lst mod rev and remove whitespace VERSION1=`svn info $SPD_BLDGS | grep -E 'Letzte ge|Last Changed Rev' | awk -F ':' '{print $2 }'` VERSION1=`echo $VERSION1 | sed -e 's/[[:space:]]*$//'` echo "VERSION1 = '$VERSION1'" if [ -z "$VERSION1" ] ; then echo "VERSION1 could not be determined" ; exit; fi VERSION2=`svn info $SPD_BLDGS/../_Transformationspunkte | grep -E 'Letzte ge|Last Changed Rev' | awk -F ':' '{print $2 }'` VERSION2=`echo $VERSION2 | sed -e 's/[[:space:]]*$//'` echo "VERSION2 = '$VERSION2'" if [ -z "$VERSION2" ] ; then echo "VERSION2 could not be determined" ; exit; fi if (( $VERSION1 > $VERSION2 )); then VERSION_SPD_BLDGS=$VERSION1; else VERSION_SPD_BLDGS=$VERSION2; fi if [ -z "$VERSION_POST_PROC" ] ; then echo "VERSION_SPD_BLDGS could not be determined" ; exit; fi # Please do not add strings to VERSION_STR. rpm -Uhv will have problem with it.... echo "VERSION_SPD_BLDGS = '$VERSION_SPD_BLDGS'" echo "VERSION_POST_PROC = '$VERSION_POST_PROC'" VERSION_STR="${VERSION_SPD_BLDGS}.${VERSION_POST_PROC}" echo "VERSION_STR = '$VERSION_STR'" ### ### vwm_adjustment ### # NodeJS: # multiple dirs: 1st for jenkins, 2nd for CTCAP15/Norbert export NODE_PATH='/usr/lib/node_modules:../node_modules' echo "Comment: NODE_PATH=" $NODE_PATH echo "Comment: vwm_adjustment at dir $SPD_BLDGS" node ./vwm_adjustment/RECURSIV/pos_dir_guez.js $SPD_BLDGS &> vwm_adjustment.log if [ $? -ne 0 ]; then echo " node vwm_adjustment failed" ; tail -n200 vwm_adjustment.log; exit else echo " node vwm_adjustment finished"; fi # Renoir-repos has xml files without svn:eol-style. # So 'svn co' on unix will create files with CR+LF (Windows EOL) # To ensure usefull 'svn diff' showing only the real differences, convert to CR+LF: # execute unix2dos on all files adjusted (vwm_adjustment) echo "Comment: unix2dos (quiet)" find $FILE -name "*flt.xml" | xargs unix2dos -q find $FILE -name "*VWM_Building.xml" | xargs unix2dos -q # for debug: # svn st ../GuezBuildings/buildings/bldg_0910/ # svn diff ../GuezBuildings/buildings/bldg_0910/ # svn diff ../GuezBuildings/buildings/bldg_0910/bldg_0910.flt.xml ### seperate sheets: # xlsx to xls FILE=$SPD_BLDGS/../_Transformationspunkte/${xlsxfile}.xlsx if [ ! -f "$FILE" ]; then echo "$FILE does not exist." ; exit; fi cp -v $FILE . if [ $? -ne 0 ]; then echo "copy command failed" ; fi FILE=./${xlsxfile}.xlsx if [ ! -f "$FILE" ]; then echo "$FILE does not exist." ; exit; fi soffice --headless --convert-to SOFFICE_CONVERTED.xls $FILE #-> GUEZ_BWDLZ_BA-0_BA-IV_Transformationspunkte_201210.SOFFICE_CONVERTED.xls if [ $? -ne 0 ]; then echo "soffice command failed" ; fi # xls to csv echo "Comment: xlsx to xls..." xlsfile=${xlsxfile}.SOFFICE_CONVERTED.xls echo "Comment: xls to single csv files..." xls2csv -x ${xlsfile} -n1 -c GUEZ_BWDLZ_salchau.csv xls2csv -x ${xlsfile} -n2 -c GUEZ_BWDLZ_ba0.csv xls2csv -x ${xlsfile} -n3 -c GUEZ_BWDLZ_ba1.csv xls2csv -x ${xlsfile} -n4 -c GUEZ_BWDLZ_ba2.csv xls2csv -x ${xlsfile} -n5 -c GUEZ_BWDLZ_ba3.csv xls2csv -x ${xlsfile} -n6 -c GUEZ_BWDLZ_ba4.csv # sort for loc in ${LOCATIONS_LIST} do cat GUEZ_BWDLZ_${loc}.csv | sort > temp.txt mv temp.txt GUEZ_BWDLZ_${loc}.csv done rm temp.txt # replace some strings # like BN_Kan -> BN_Kanaele and so on sed -i 's/BN_Kan/BN_Kanaele/g' GUEZ_BWDLZ_salchau.csv if [ $? -ne 0 ]; then echo "sed command failed" ; fi sed -i 's/U-Bahn/U_Bahn/g' GUEZ_BWDLZ_salchau.csv if [ $? -ne 0 ]; then echo "sed command failed" ; fi sed -i 's/^571/salchau_571/g' GUEZ_BWDLZ_salchau.csv if [ $? -ne 0 ]; then echo "sed command failed" ; fi sed -i 's/^574/salchau_574/g' GUEZ_BWDLZ_salchau.csv if [ $? -ne 0 ]; then echo "sed command failed" ; fi sed -i 's/^575/salchau_575/g' GUEZ_BWDLZ_salchau.csv if [ $? -ne 0 ]; then echo "sed command failed" ; fi sed -i 's/^576/salchau_576/g' GUEZ_BWDLZ_salchau.csv if [ $? -ne 0 ]; then echo "sed command failed" ; fi sed -i 's/^577/salchau_577/g' GUEZ_BWDLZ_salchau.csv if [ $? -ne 0 ]; then echo "sed command failed" ; fi sed -i 's/^tunnel/salchau_tunnel/g' GUEZ_BWDLZ_salchau.csv if [ $? -ne 0 ]; then echo "sed command failed" ; fi # ^314126 -> ^3141_26 ; # ^314127 -> ^3141_27 sed -i 's/^314126/3141_26/' GUEZ_BWDLZ_ba3.csv if [ $? -ne 0 ]; then echo "sed command failed" ; fi sed -i 's/^314127/3141_27/' GUEZ_BWDLZ_ba3.csv if [ $? -ne 0 ]; then echo "sed command failed" ; fi # bldg 3145-47 -> bldg 3145_47 cat GUEZ_BWDLZ_ba3.csv | grep -v BN_3146 > copy_GUEZ_BWDLZ_ba3.csv cp copy_GUEZ_BWDLZ_ba3.csv GUEZ_BWDLZ_ba3.csv rm copy_GUEZ_BWDLZ_ba3.csv sed -i 's/^3145/3145_47/g' GUEZ_BWDLZ_ba3.csv ### ### convert_coordinate.py ### echo "Comment: convert_coordinates.py angles" echo "Comment: current wd is: " `pwd` FILE=./convert_coordinates.py if [ ! -f "$FILE" ]; then echo "$FILE does not exist." ; exit; fi for loc in ${LOCATIONS_LIST} do csv_cnt=`cat import_${loc}.csv | grep -v "^#" | wc -l` python ./convert_coordinates.py GUEZ_BWDLZ_${loc}.csv ./import_${loc}.csv cat GUEZ_BWDLZ_${loc}.csv | sort > temp.txt mv temp.txt GUEZ_BWDLZ_{loc}.csv done ### ### Copy some files to $SPD_BLDGS ### echo "Comment: cd building ; osgconv.sh" echo "Comment: current wd is: " `pwd` cp -v ./osgconv.sh $SPD_BLDGS if [ $? -ne 0 ]; then echo "copy command (osgconv.sh) failed" ; fi pushd $SPD_BLDGS if [ $? -ne 0 ]; then echo "cd command failed" ; fi for loc in ${LOCATIONS_LIST} do ./osgconv.sh $VERSION_STR ${loc} ${file_location}/import_${loc}.csv done ### back to location of this file popd echo "Comment: rpmbuild..." echo "Comment: current wd is: " `pwd` ### ### Prepare spec files: ### echo "Comment: replace some vars at *.spec" echo "VERSION_STR = '$VERSION_STR'" sed -i "s/@VERSION@/$VERSION_STR/g" guez_buildings*buildingviewer.spec if [ $? -ne 0 ]; then echo "sed command failed" ; fi ### ### JENKINS: ### if [ -z "$BUILD_TAG" ] ; then echo "JENKINS BUILD_TAG not defined, set to '-'" ; BUILD_TAG="NoTag" ; fi if [ -z "$BUILD_NUMBER" ] ; then echo "JENKINS BUILD_NUMBER not defined, set to '0'" ; BUILD_NUMBER=0 ; fi JENKINS_BUILD_TAG="${BUILD_TAG}" echo "JENKINS_BUILD_TAG: ${JENKINS_BUILD_TAG}" sed -i "s/@JENKINS_BUILD_TAG@/${JENKINS_BUILD_TAG}/g" guez_buildings*buildingviewer.spec if [ $? -ne 0 ]; then echo "sed command JENKINS_BUILD_TAG failed" ; fi sed -i "s/@RELEASE@/${BUILD_NUMBER}/g" guez_buildings*buildingviewer.spec if [ $? -ne 0 ]; then echo "sed command RELEASE failed" ; fi for loc in ${LOCATIONS_LIST} do rpmbuild -bb --target=noarch guez_buildings_${loc}_buildingviewer.spec if [ $? -ne 0 ]; then echo "rpmbuild command failed for spec 'guez_buildings_${loc}_buildingviewer.spec'" ; fi done echo "rpmbuild... finished" csv_cnt_sum=0 rpm_cnt_sum=0 for loc in ${LOCATIONS_LIST} do csv_cnt=`cat import_${loc}.csv | grep -v "^#" | wc -l` rpm_cnt=`rpm -ql ~/rpmbuild/RPMS/noarch/guez_buildings_${loc}_buildingviewer-${VERSION_STR}-0.noarch.rpm | grep flt.xml | wc -l` echo -e "Comment: #bldgs: csv: $csv_cnt \t - rpm: $rpm_cnt \t at import_${loc}.csv" csv_cnt_sum=$(($csv_cnt_sum + $csv_cnt)) rpm_cnt_sum=$(($rpm_cnt_sum + $rpm_cnt)) done echo -e "Comment: #bldgs: csv: $csv_cnt_sum \t - rpm: $rpm_cnt_sum - Over all" echo "Comment: Problems of EGCU_CONF..." grep "EGCU pro Etage" vwm_adjustment.log | sort -u grep "EGCU pro Etage" vwm_adjustment.log | sort -u | wc -l echo -e "Comment: Problems regarding wrong protectiveFactors at some files: cnt: $protectiveErrorCnt" echo -e "Comment: Problems regarding duplicate Names at some files: cnt: $checkDuplicateNamesCnt" ## JENKINS? if [ -z ${WORKSPACE} ] then echo "rpmbuild... move to - skipped" else echo "rpmbuild... move to " echo "VERSION_STR = '$VERSION_STR'" DST_DIR=${WORKSPACE}/rpms/ mkdir ${DST_DIR} mv -v ~/rpmbuild/RPMS/noarch/guez_buildings*$VERSION_STR*.rpm ${DST_DIR} fi