OSDN Git Service

fixed
[alterlinux/LFBS.git] / docker-build.sh
index 9a98677..71032c3 100755 (executable)
@@ -11,7 +11,47 @@ if ! type docker >/dev/null 2>&1; then
     exit 1
 fi
 
+_usage () {
+    echo "usage ${0} [options]"
+    echo
+    echo " General options:"
+    echo "    -o | --build-opiton \"[options]\"     send the build option to ./lfbs"
+    echo "    -c | --clean                          Enable --no-cache option when build docker image"
+    echo "    -h | --help                           This help message and exit"
+    echo
+}
+
+# Start parse options
+ARGUMENT="${@}"
+while (( $# > 0 )); do
+    case ${1} in
+        -o | --build-opiton)
+            BUILD_OPT="${2}"
+            shift 2
+            ;;
+        -c | --clean)
+            NO_CACHE="--no-cache" # Enable --no-cache option
+            shift 1
+            ;;
+        -h | --help)
+            _usage
+            exit 0
+            ;;
+        --)
+            shift
+            break
+            ;;
+        *)
+            msg_error "Invalid argument '${1}'"
+            _usage 1
+            ;;
+    esac
+done
+
+
+# End parse options
+
 SCRIPT_DIR=$(cd $(dirname $0); pwd)
-cd $SCRIPT_DIR
-docker build -t lfbs-build:latest .
-docker run -e _DOCKER=true -t -i --privileged -v $SCRIPT_DIR/out:/lfbs/out -v /usr/lib/modules:/usr/lib/modules:ro lfbs-build
+cd ${SCRIPT_DIR}
+docker build ${NO_CACHE} -t lfbs-build:latest .
+docker run -t -i --privileged -v ${SCRIPT_DIR}/out:/lfbs/out -v /usr/lib/modules:/usr/lib/modules:ro -v ${SCRIPT_DIR}/cache:/lfbs/cache lfbs-build "${BUILD_OPT}"