adding autodetect on build command

This commit is contained in:
Jerome Sagnole 2017-09-03 15:20:49 +02:00
parent f2e70b182e
commit 4ac04c6f51
2 changed files with 24 additions and 20 deletions

View file

@ -8,7 +8,7 @@
# Created by : AleaJactaEst # Created by : AleaJactaEst
declare -i REMOVE=0 declare -i REMOVE=0
declare -i IMAGE=1 declare -i IMAGE=0
declare -i BUILD=1 declare -i BUILD=1
declare -i DEBUG=0 declare -i DEBUG=0
declare JOBS="" declare JOBS=""
@ -16,6 +16,7 @@ declare CMAKEOPTS=""
declare DOCKEROPTS="" declare DOCKEROPTS=""
declare DIRBUILD="" declare DIRBUILD=""
declare CLEANDOCKER=0 declare CLEANDOCKER=0
declare -i AUTODETEC=1
declare IMAGEDOCKER="builder_khanat_debian_jessie_i686" declare IMAGEDOCKER="builder_khanat_debian_jessie_i686"
declare LOCALBUILDDIR="build/$IMAGEDOCKER" declare LOCALBUILDDIR="build/$IMAGEDOCKER"
@ -38,8 +39,7 @@ options:
-h, --help : Show this help -h, --help : Show this help
-d, --debug : Show debug message -d, --debug : Show debug message
-r, --remove : Remove old build repository -r, --remove : Remove old build repository
-i, --image-only : Just create image (no build) -f, --force-create-image : force to create docker image (use to build khanat) - default autodetec.
-b, --build-only : Just build (no create new image)
-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg. -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
-a OPTS, --add-opts-cmake=OPTS : Adding options on cmake command (before build) -a OPTS, --add-opts-cmake=OPTS : Adding options on cmake command (before build)
-c, --clean-container : remove all container in state Exited -c, --clean-container : remove all container in state Exited
@ -97,16 +97,10 @@ do
REMOVE=1 REMOVE=1
shift shift
;; ;;
-i|--image-only) -f|--force-create-image)
BUILD=0
IMAGE=1 IMAGE=1
shift shift
;; ;;
-b|--build-only)
BUILD=1
IMAGE=0
shift
;;
-j) -j)
shift shift
# search next argument is value or new argument # search next argument is value or new argument
@ -170,6 +164,14 @@ then
exit 2 exit 2
fi fi
if [[ $AUTODETEC -ne 0 ]]
then
if [[ $(docker images -f "reference=$IMAGEDOCKER" | wc -l) -lt 2 ]]
then
IMAGE=1
fi
fi
DIRBUILD="${rootdir}/code/${LOCALBUILDDIR}" DIRBUILD="${rootdir}/code/${LOCALBUILDDIR}"
msg_debug "calldir: $calldir" msg_debug "calldir: $calldir"

View file

@ -8,7 +8,7 @@
# Created by : AleaJactaEst # Created by : AleaJactaEst
declare -i REMOVE=0 declare -i REMOVE=0
declare -i IMAGE=1 declare -i IMAGE=0
declare -i BUILD=1 declare -i BUILD=1
declare -i DEBUG=0 declare -i DEBUG=0
declare JOBS="" declare JOBS=""
@ -16,6 +16,7 @@ declare CMAKEOPTS=""
declare DOCKEROPTS="" declare DOCKEROPTS=""
declare DIRBUILD="" declare DIRBUILD=""
declare CLEANDOCKER=0 declare CLEANDOCKER=0
declare -i AUTODETEC=1
declare IMAGEDOCKER="builder_khanat_debian_jessie_x86_64" declare IMAGEDOCKER="builder_khanat_debian_jessie_x86_64"
declare LOCALBUILDDIR="build/$IMAGEDOCKER" declare LOCALBUILDDIR="build/$IMAGEDOCKER"
@ -38,8 +39,7 @@ options:
-h, --help : Show this help -h, --help : Show this help
-d, --debug : Show debug message -d, --debug : Show debug message
-r, --remove : Remove old build repository -r, --remove : Remove old build repository
-i, --image-only : Just create image (no build) -f, --force-create-image : force to create docker image (use to build khanat) - default autodetec.
-b, --build-only : Just build (no create new image)
-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg. -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
-a OPTS, --add-opts-cmake=OPTS : Adding options on cmake command (before build) -a OPTS, --add-opts-cmake=OPTS : Adding options on cmake command (before build)
-c, --clean-container : remove all container in state Exited -c, --clean-container : remove all container in state Exited
@ -99,16 +99,10 @@ do
REMOVE=1 REMOVE=1
shift shift
;; ;;
-i|--image-only) -f|--force-create-image)
BUILD=0
IMAGE=1 IMAGE=1
shift shift
;; ;;
-b|--build-only)
BUILD=1
IMAGE=0
shift
;;
-j) -j)
shift shift
# search next argument is value or new argument # search next argument is value or new argument
@ -176,6 +170,14 @@ then
exit 2 exit 2
fi fi
if [[ $AUTODETEC -ne 0 ]]
then
if [[ $(docker images -f "reference=$IMAGEDOCKER" | wc -l) -lt 2 ]]
then
IMAGE=1
fi
fi
DIRBUILD="${rootdir}/code/${LOCALBUILDDIR}" DIRBUILD="${rootdir}/code/${LOCALBUILDDIR}"
msg_debug "calldir: $calldir" msg_debug "calldir: $calldir"