+ echo "Set the profile : $PROFILE"
+
+ if [ "$ARCHITECTURE" == "" ]; then
+ ARCHITECTURE=armv7l
+ fi
+ echo "Set the architecture : $ARCHITECTURE"
+
+ if [ "$(echo "${PROFILE}" | grep -P "tz_standard")" != "" -a "$NOINIT" == 0 ]; then
+ processRpmlintOption $PROFILE $RPMLINT
+ fi
+ local BRANCH=$(echo $(basename $(git symbolic-ref HEAD)))
+ if [ "$(echo $BRANCH | grep dev)" != "" ]; then
+ BRANCH=dev
+ elif [ "$(echo $BRANCH | grep beta)" != "" ]; then
+ BRANCH=beta
+ else
+ BRANCH=release
+ fi
+ local CHROMIUM_VERSION=$(echo $(head -n 1 chrome/VERSION) | sed -e 's/MAJOR=//g')
+
+ local GBS_ROOT_OPT=
+ if [ "$USE_GLOBAL_GBS_CONF" == "" ]; then
+ CONF_FLAG="--conf ${SCRIPTDIR}/gbs.conf"
+ if [ "$GBS_ROOT" == "" ]; then
+ if [ "$BUILD_CHROME" == "1" ]; then
+ GBS_ROOT_OPT="-B ~/GBS-ROOT-M${CHROMIUM_VERSION}-${PROFILE^^}-TIZEN_${DEFAULT_TIZEN_VERSION^^}-CHROME-${BRANCH^^}"
+ else
+ GBS_ROOT_OPT="-B ~/GBS-ROOT-M${CHROMIUM_VERSION}-${PROFILE^^}-TIZEN_${DEFAULT_TIZEN_VERSION^^}-${BRANCH^^}"
+ fi
+ else
+ GBS_ROOT_OPT="-B $GBS_ROOT"
+ fi
+ fi
+
+ processICU initialize_icu
+ gbs $CONF_FLAG build -P $PROFILE --include-all -A $ARCHITECTURE "${ARGS[@]}" $BUILD_CONF_OPTS --incremental $GBS_ROOT_OPT
+ local RESULT=$?
+
+ undoReplacedGn $platform
+ processICU restore_icu
+
+ if [[ $RESULT != 0 ]]; then
+ exit $RESULT
+ fi
+}
+
+function processICU() {
+ local ICU_PATH="$TOPDIR/third_party/icu/source"
+ local ICU_REPLACE_PATH="$TOPDIR/third_party/icu/source_replace"
+
+ if [ "$1" == "replace_icu" ]; then
+ if [ ! -e $ICU_REPLACE_PATH ] && [ -e $ICU_PATH ]; then
+ echo "** third_party/icu/source is replaced to use system icu."
+ mv $ICU_PATH $ICU_REPLACE_PATH
+ fi
+ elif [ "$1" == "restore_icu" ]; then
+ if [ -e $ICU_REPLACE_PATH ] && [ ! -e $ICU_PATH ]; then
+ echo "** third_party/icu/source is restored."
+ mv $ICU_REPLACE_PATH $ICU_PATH
+ fi
+ elif [ "$1" == "initialize_icu" ]; then
+ if [ -e $ICU_REPLACE_PATH ]; then
+ echo "** third_party/icu/source is initialized."
+ rm -rf $ICU_PATH
+ mv $ICU_REPLACE_PATH $ICU_PATH
+ fi
+ fi
+}
+
+function processRpmlintOption() {
+ local PROFILE=$1
+ local RPMLINT=$2
+ local URL_TARGET=
+ export BUILD_CONF_OPTS=
+
+ echo "** Process rpmlint option"
+
+ local PREVIOUS_RPMLINT="!rpmlint"
+ if [ ! -f "$PREVIOUS_BUILD_CONF_PATH" ]; then
+ # Never built before
+ PREVIOUS_RPMLINT=""
+ elif [ "$(grep -Po "\!rpmlint" "$PREVIOUS_BUILD_CONF_PATH" | uniq -d)" != "!rpmlint" ]; then
+ # Once built with rpmlint
+ PREVIOUS_RPMLINT="rpmlint"
+ fi
+
+ # Disable rpmlint
+ if [ "$RPMLINT" == 0 ]; then
+ echo "** Disable rpmlint"
+ BUILD_CONF_DIR=$SCRIPTDIR/build_conf
+ rm -rf $BUILD_CONF_DIR
+ mkdir $BUILD_CONF_DIR
+ URL_TARGET=$(echo $PROFILE | sed -e 's#.*\.[0-9]*_\([-a-zA-Z0-9]*\).*#\1#;s/tz_//g')
+ # The latest version doesn't have tizen version in snapshot repository url.
+ if [ "$DEFAULT_TIZEN_VERSION" == "${LATEST_TIZEN_VERSION}" ]; then
+ URL_TIZEN_VERSION=
+ else
+ URL_TIZEN_VERSION=-$DEFAULT_TIZEN_VERSION
+ fi
+ REPO=http://download.tizen.org/snapshots/TIZEN/Tizen$URL_TIZEN_VERSION/Tizen$URL_TIZEN_VERSION-$platform/latest/repos/$URL_TARGET/packages/repodata/
+ echo "** Repo : $REPO"
+ wget $REPO -O $BUILD_CONF_DIR/index.html > /dev/null 2>&1
+ BUILD_CONF_GZ=$(grep "build.conf.gz" $BUILD_CONF_DIR/index.html | sed -e 's#.*\=\"\(.*\)\".*#\1#')
+ BUILD_CONF=$(basename $BUILD_CONF_GZ .gz)
+ wget $REPO$BUILD_CONF_GZ -P $BUILD_CONF_DIR > /dev/null 2>&1
+ if [ ! -f "$BUILD_CONF_DIR/$BUILD_CONF_GZ" ]; then
+ echo "It's failed to donwload build.conf. Please contact system administrator."
+ exit 1
+ fi
+ gunzip $BUILD_CONF_DIR/$BUILD_CONF_GZ
+ sed -i 's/rpmlint-mini\ rpmlint-tizen/!rpmlint-mini\ !rpmlint-tizen/g' $BUILD_CONF_DIR/$BUILD_CONF
+ if [ "$DEFAULT_TIZEN_VERSION" == "6.0" ]; then
+ sed -i 's/tizen_version_major 5/tizen_version_major 6/g' $BUILD_CONF_DIR/$BUILD_CONF
+ sed -i 's/tizen_version_minor 5/tizen_version_minor 0/g' $BUILD_CONF_DIR/$BUILD_CONF
+ fi
+ BUILD_CONF_OPTS="-D $BUILD_CONF_DIR/$BUILD_CONF"
+ if [ "$PREVIOUS_RPMLINT" == "rpmlint" ]; then
+ echo "** Once built with rpmlint"
+ BUILD_CONF_OPTS+=" --clean"
+ fi
+ else # Enable rpmlint
+ echo "** Enable rpmlint"
+ BUILD_CONF_OPTS=""
+ if [ "$PREVIOUS_RPMLINT" == "!rpmlint" ]; then
+ BUILD_CONF_OPTS="--clean"
+ fi
+ fi