#!/bin/bash # # Program to build all and generate all image server (i686 & x86_64) # Copyright (C) 2017 AleaJactaEst # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . declare -i AUTO=1 declare -i BUILD_i686=0 declare -i GENERATE_CONTAINER_i686=0 declare -i GENERATE_IMAGE_i686=0 declare -i BUILD_x86_64=0 declare -i GENERATE_CONTAINER_x86_64=0 declare -i GENERATE_IMAGE_x86_64=0 declare -i CLEAN=0 calldir="$(dirname $0)" basedir=$(cd $calldir; pwd) usage() { cat << EOF usage:$0 [options] script to build all environment options: -h, --help : Show this help -d, --debug : Show debug message --build-i686 : Build server and client i686 --generate-container-i686 : Generate container docker for i686 (share data with host) --generate-image-i686 : Generate image docker for i686 (image have all opennel) --build-x86_64 : Build server and client x86_64 --generate-container-x86_64 : Generate container docker for x86_64 (share data with host) --generate-image-x86_64 : Generate image docker for x86_64 (image have all opennel) --clean : remove build & server data EOF } function msg_debug() { if [[ $DEBUG -ne 0 ]] then echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*" fi } function msg_info() { msg="$(date "+%Y/%m/%d %H:%M:%S") INFO - $*" echo "$msg" echo "$msg" >> ${basedir}/build/state.log } function msg_error() { msg="$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" echo "$msg" echo "$msg" >> ${basedir}/build/state.log exit 2 } while test $# -gt 0 do case "$1" in -h|--help) usage exit 1 ;; -d|--debug) DEBUG=1 shift ;; --build-i686) AUTO=0 BUILD_i686=1 shift ;; --generate-container-i686) AUTO=0 GENERATE_CONTAINER_i686=1 shift ;; --generate-image-i686) AUTO=0 GENERATE_IMAGE_i686=1 shift ;; --build-x86_64) AUTO=0 BUILD_x86_64=1 shift ;; --generate-container-x86_64) AUTO=0 GENERATE_CONTAINER_x86_64=1 shift ;; --generate-image-x86_64) AUTO=0 GENERATE_IMAGE_x86_64=1 shift ;; --clean) CLEAN=1 shift ;; *) usage msg_error "options '$1' not recognize" ;; esac done mkdir -p "${basedir}/build" msg_info "BEGIN" if [[ $AUTO ]] then BUILD_i686=1 GENERATE_CONTAINER_i686=1 GENERATE_IMAGE_i686=1 BUILD_x86_64=1 GENERATE_CONTAINER_x86_64=1 GENERATE_IMAGE_x86_64=1 fi if [[ $CLEAN -ne 0 ]] then msg_debug "CLEAN" rm -rf $basedir/build $basedir/output || msg_error "CLEAN" fi if [[ $BUILD_i686 -ne 0 ]] then msg_debug "BUILD DEBIAN JESSIE i686" builder/debian/jessie/i686/build.sh -c -j 12 -a '-DWITH_SSE2=OFF' -a '-DWITH_SYMBOLS=ON' -m '-m 20g' -d || msg_error "BUILD DEBIAN JESSIE i686" fi if [[ $GENERATE_CONTAINER_i686 -ne 0 ]] then msg_debug "GENERATE SERVER CONTAINER DEBIAN JESSIE i686" server/debian/jessie/i686/server-container.sh -r -b -k -w -c -n || msg_error "GENERATE SERVER CONTAINER DEBIAN JESSIE i686" fi if [[ $GENERATE_IMAGE_i686 -ne 0 ]] then msg_debug "GENERATE SERVER IMAGE DEBIAN JESSIE i686" server/debian/jessie/i686/server-image.sh -b -k -w -c -n || msg_error "GENERATE SERVER IMAGE DEBIAN JESSIE i686" fi if [[ $BUILD_x86_64 -ne 0 ]] then msg_debug "BUILD DEBIAN JESSIE x86_64" builder/debian/jessie/x86_64/build.sh -c -j 12 -a '-DWITH_SYMBOLS=ON' -m '-m 20g' -d || msg_error "BUILD DEBIAN JESSIE x86_64" fi if [[ $GENERATE_CONTAINER_x86_64 -ne 0 ]] then msg_debug "GENERATE SERVER CONTAINER DEBIAN JESSIE x86_64" server/debian/jessie/x86_64/server-container.sh -r -b -k -g -w -c -n || msg_error "GENERATE SERVER CONTAINER DEBIAN JESSIE x86_64" fi if [[ $GENERATE_IMAGE_x86_64 -ne 0 ]] then msg_debug "GENERATE SERVER IMAGE DEBIAN JESSIE x86_64" server/debian/jessie/x86_64/server-image.sh -b -k -w -c -n || msg_error "GENERATE SERVER IMAGE DEBIAN JESSIE x86_64" fi msg_info "END"