slsDetectorPackage/updateAPIVersion.sh
Dhanya Thattil 5bcde789ac
Readoutflags (#61)
* WIP

* eiger binary back wih versioning

* fixed readout flag in ctbgui, added speedLevel enum

* ctbgui: fixed a print out error

* ctb readout bug fix

* WIP

* WIP

* WIP
2019-09-02 19:27:27 +02:00

44 lines
881 B
Bash
Executable File

#require 2 arguments, API_NAME API_DIR (relative to package)
if [ $# -lt 2 ]; then
echo "wrong usage of updateVersion.sh"
exit -1
fi
API_NAME=$1
PACKAGE_DIR=$PWD
API_DIR=$PACKAGE_DIR/$2
API_FILE=$PACKAGE_DIR/slsSupportLib/include/versionAPI.h
CURR_DIR=$PWD
#go to directory
cd $API_DIR
#deleting line from file
NUM=$(sed -n '/'$API_NAME' /=' $API_FILE)
#echo $NUM
if [ "$NUM" -gt 0 ]; then
sed -i ${NUM}d $API_FILE
fi
#find new API date
API_DATE="find . -printf \"%T@ %CY-%Cm-%Cd\n\"| sort -nr | cut -d' ' -f2- | egrep -v '(\.)o' | head -n 1"
API_DATE=`eval $API_DATE`
API_DATE=$(sed "s/-//g" <<< $API_DATE | awk '{print $1;}' )
#extracting only date
API_DATE=${API_DATE:2:6}
#prefix of 0x
API_DATE=${API_DATE/#/0x}
echo "date="$API_DATE
#copy it to versionAPI.h
echo "#define "$API_NAME $API_DATE >> $API_FILE
#go back to original directory
cd $CURR_DIR