3 #---------- DEBUG_BEGIN ----------
4 #ARG="-d" # debug-on flag, might be set as $1
5 # keyprompt "introductory message" -- wait until any key pressed
6 function keyprompt { echo -ne "\n\e[1;31m$1 -- " && read -n 1 && echo -e "\n\e[0m"; }
7 # d_bp -- breakpoint at which user need to press any key to proceed
8 function d_bp { if [[ "$ARG" == "-d" ]]; then keyprompt "d >> Press any key"; fi }
9 # d_showVar VARNAME -- print bash variable name
10 function d_showVar { if [ "$ARG" == "-d" -a -n "$1" ]; then echo "d >> ${1} = ${!1}"; fi }
11 # d_print "message" -- print a debug message
12 function d_print { if [ "$ARG" == "-d" -a -n "$1" ]; then echo -e "d >> $1"; fi }
13 #---------- DEBUG_END ----------
15 PROJECT_DIR="$(cd "$(dirname $0)" && pwd)"
18 function gbs_profile {
21 my \$Config = Config::Tiny->read( \"\$ENV{HOME}/.gbs.conf\" );
22 my \$profile = \$Config->{general}->{profile};
23 \$profile =~ s/profile.//;
28 RPM_DIR="$HOME/GBS-ROOT/local/repos/$PROFILE/armv7l/RPMS"
33 if [ -z "$1" ]; then echo "Usage: `basename $0` addmod <module_name> [module_lib_name]"; exit 1; fi
37 MODULE_NAME_C=$(echo $MODULE_NAME | sed -e 's/-\([a-z]\)/\U\1/' -e 's/^\([a-z]\)/\U\1/')
38 d_showVar MODULE_NAME_C
39 MODULE_NAME_U=$(echo $MODULE_NAME | sed -e 's/-/_/')
40 d_showVar MODULE_NAME_U
41 # MODULE_LIBNAME=${2:-capi-$MODULE_NAME}
43 d_showVar MODULE_LIBNAME
45 echo "Adding $MODULE_NAME module to project..."
49 echo "-- Generating packaging/core-$MODULE_NAME-tests.spec file"
50 if [ ! -d packaging ]; then mkdir packaging; fi
51 sed -e "s:\[MODULE_NAME\]:$MODULE_NAME:g" -e "s:\[MODULE_LIBNAME\]:$MODULE_LIBNAME:g" \
52 templates/core-\[module_name\]-tests.spec > packaging/core-$MODULE_NAME-tests.spec
53 # prepare src directory
54 mkdir src/$MODULE_NAME
55 echo "-- Generating src/$MODULE_NAME/CMakeLists.txt file"
56 sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" -e "s:%{MODULE_LIBNAME}:$MODULE_LIBNAME:g" \
57 templates/src-directory/CMakeLists.txt > src/$MODULE_NAME/CMakeLists.txt
58 echo "-- Generating src/$MODULE_NAME/tct-$MODULE_NAME-core.c file"
59 sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" \
60 templates/src-directory/tct-\[module_name\]-core.c > src/$MODULE_NAME/tct-$MODULE_NAME-core.c
61 echo "-- Generating src/$MODULE_NAME/utc-$MODULE_NAME.c file"
62 sed -e "s:%{MODULE_NAME_U}:$MODULE_NAME_U:g" -e "s:%{MODULE_NAME_C}:$MODULE_NAME_C:g" \
63 templates/src-directory/utc-\[module_name\].c > src/$MODULE_NAME/utc-$MODULE_NAME.c
64 echo "Task finished successfully"
69 if [ -z "$1" ]; then echo "Usage: `basename $0` rmmod <module_name>"; exit 1; fi
74 echo "Removing $MODULE_NAME module from project..."
76 echo "---- Updating /opt/tct/packages/package_list.xml"
77 scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/packages/package_list.xml 1
78 if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
79 # echo "---- Updating test plans"
80 # scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/manager/plan/*.xml 1
81 # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
84 echo "-- Removing packaging/core-$MODULE_NAME-tests.spec file"
85 rm packaging/core-$MODULE_NAME-tests.spec
86 echo "-- Removing src/$MODULE_NAME directory"
87 rm -r src/$MODULE_NAME
88 echo "Task finished successfully"
93 (cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h)
94 if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
95 cp packaging/core-$1-tests.spec ../packaging
96 cp .gitignore-without-autogenerated-files .gitignore
97 gbs build -A armv7l --spec core-$1-tests.spec --include-all --keep-packs | \
98 tee build.log | stdbuf -o0 sed -e 's/error:/\x1b[1;91m&\x1b[0m/' \
99 -e 's/warning:/\x1b[93m&\x1b[0m/'
100 rm ../packaging/core-$1-tests.spec
101 cp .gitignore-with-autogenerated-files .gitignore
103 echo "Build requires a module name"
111 for mod in `ls -1 src/ | grep -v CMakeLists`
114 if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
116 PKG_NAME="core-$mod-tests"
118 VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }')
120 PKG_VNAME="$PKG_NAME-$VER"
122 PKG_FNAME="$PKG_VNAME-0.armv7l.rpm"
125 if [ -f "$RPM_DIR/$PKG_FNAME" ]
137 PKG_NAME="core-$MOD_NAME-tests"
139 VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }')
141 PKG_VNAME="$PKG_NAME-$VER"
143 PKG_FNAME="$PKG_VNAME-0.armv7l.rpm"
145 TCT_DIR="opt/tct-$MOD_NAME-core-tests"
148 echo "Deploying $MOD_NAME suite to tct-mgr..."
150 # prepare tct directory and files
151 echo "-- Preparing suite .zip file..."
152 echo "---- Creating /tmp/$TCT_DIR directory"
153 rm -r /tmp/opt > /dev/null 2>&1
154 mkdir -p /tmp/$TCT_DIR
156 echo "---- Copying /tmp/$TCT_DIR"
157 cp templates/tct-package/README /tmp/$TCT_DIR
159 echo "---- Copying /tmp/$TCT_DIR package"
160 cp $RPM_DIR/$PKG_FNAME /tmp/$TCT_DIR
161 if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
163 echo "---- Generating /tmp/$TCT_DIR/inst.sh file"
164 sed -e "s:%{PKG_NAME}:\"$PKG_NAME\":g" -e "s:%{PKG_FULLNAME}:\"$PKG_FNAME\":g" \
165 -e "s:%{PKG_DIR}:\"/opt/usr/media/tct/$TCT_DIR\":g" \
166 templates/tct-package/inst.sh > /tmp/$TCT_DIR/inst.sh
167 chmod a+x /tmp/$TCT_DIR/inst.sh
169 echo "---- Generating /tmp/$TCT_DIR"
170 scripts/tctestsgen.sh $MOD_NAME /tmp/$TCT_DIR target
171 if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
173 echo "---- Preparing /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip file"
175 rm -r /tmp/tct/packages > /dev/null 2>&1
176 mkdir -p /tmp/tct/packages
178 ( cd /tmp; zip -r /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip opt > /dev/null 2>&1; )
180 echo "-- Suite deployment..."
181 echo "---- Copying /opt/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip"
182 cp /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip /opt/tct/packages/
183 echo "---- Updating /opt/tct/packages/package_list.xml"
184 scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/packages/package_list.xml 0
185 if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
186 # echo "---- Updating test plans"
187 # for file in `grep -r tct-$MOD_NAME-core-tests /opt/tct/manager/plan/ | cut -d: -f1 | uniq`
189 # scripts/tcpackageslistsgen.sh $MOD_NAME $file
191 # scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/manager/plan/Full_test.xml
192 # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
193 echo "Task finished successfully"
199 echo "Usage: `basename $0` <addmod|rmmod|build|install> <module_name> [module_lib_name]"
201 elif [ "addmod" == "$1" ]; then
204 elif [ "rmmod" == "$1" ]; then
207 elif [ "build" == "$1" ]; then
210 elif [ "install" == "$1" ]; then
214 echo "Invalid subcommand: $1"