MY_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
NNFW_ROOT=$MY_PATH/../..
+DOCKER_NNFW_HOME=/home/nnfw
+DOCKER_RPM_HOME=/home/rpm
+
+if [ "${GBS_RPM_DIR}" == "" ];
+then
+ GBS_RPM_DIR=$NNFW_ROOT/Product/out/rpm
+ mkdir -p ${GBS_RPM_DIR}
+fi
+
if [ -z ${DOCKER_IMAGE} ];
then
# use default docker image from https://github.sec.samsung.net/chunseok-lee/gbs_docker
DOCKER_IMAGE=nnfw_docker_tizen:latest
fi
-CMD="gbs -c /home/nnfw/scripts/command/gbs.conf build -A armv7l --profile=profile.tizen --clean --include-all"
-docker run --rm -v $NNFW_ROOT:/home/nnfw -w /home/nnfw ${DOCKER_ENV_VARS:-} ${DOCKER_IMAGE} sh -c "$CMD"
+DOCKER_VOLUMES+=" -v ${GBS_RPM_DIR}:${DOCKER_RPM_HOME} -v $NNFW_ROOT:${DOCKER_NNFW_HOME}"
+DOCKER_RUN_OPTS+=" --rm"
+DOCKER_RUN_OPTS+=" -w ${DOCKER_NNFW_HOME}"
+
+CMD="gbs -c ${DOCKER_NNFW_HOME}/scripts/command/gbs.conf build -A armv7l --profile=profile.tizen --clean --include-all &&
+ cp -rf /home/GBS-ROOT/local/repos/tizen/armv7l/RPMS/*.rpm ${DOCKER_RPM_HOME}/."
+docker run $DOCKER_RUN_OPTS $DOCKER_VOLUMES ${DOCKER_ENV_VARS:-} ${DOCKER_IMAGE} sh -c "$CMD"
+
+# change owner of root dir and delete rootfs dir
+NNFW_OWNER_UID=$(stat -c "%u" $NNFW_ROOT)
+NNFW_OWNER_GID=$(stat -c "%g" $NNFW_ROOT)
+
+CMD="chown -R $NNFW_OWNER_UID:$NNFW_OWNER_GID ${DOCKER_NNFW_HOME} && chown -R $NNFW_OWNER_UID:$NNFW_OWNER_GID ${DOCKER_RPM_HOME}"
+docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE sh -c "$CMD"