]> git.pld-linux.org Git - projects/cleanbuild.git/commitdiff
add --tmpfs=2G to specicify size of build tmpfs size
authorElan Ruusamäe <glen@pld-linux.org>
Mon, 31 Dec 2018 09:28:18 +0000 (11:28 +0200)
committerElan Ruusamäe <glen@pld-linux.org>
Mon, 31 Dec 2018 09:28:18 +0000 (11:28 +0200)
cleanbuild-docker.sh

index 8f4f7c3e1ac9421c7230eda04f6ac5c9ffa8bf1d..6a9ac30f73aa992efb74d72c56b5d448df6f3a38 100755 (executable)
@@ -7,19 +7,44 @@ PROGRAM=${0##*/}
 : ${PACKAGE_NAME=''}
 : ${NETWORKING=false}
 : ${TRACING=false}
-: ${TMPFS=true}
+: ${TMPFS="4G"}
 
 dir=$(pwd)
 image=registry.gitlab.com/pld-linux/cleanbuild
 topdir=$dir/rpm
 home=/home/builder
-buildsize="4G"
 
 die() {
        echo >&2 "$0: $*"
        exit 1
 }
 
+is_no() {
+       # Test syntax
+       if [ $# = 0 ]; then
+               return 2
+       fi
+
+       case "$1" in
+       no|No|NO|false|False|FALSE|off|Off|OFF|N|n|0)
+               # true returns zero
+               return 0
+               ;;
+       *)
+               # false returns one
+               return 1
+               ;;
+       esac
+}
+
+tmpfs() {
+       if is_no "${TMPFS:-true}" || [ "$TMPFS" -le 0 ]; then
+               return
+       fi
+
+       echo "--tmpfs $home/rpm/BUILD:rw,exec,nosuid,size=$TMPFS"
+}
+
 create_container() {
        # cleanup first
        docker kill $name >/dev/null 2>&1 || :
@@ -34,7 +59,7 @@ create_container() {
                -v $dir:$home/cleanbuild \
                -v $dir/cache/poldek:/var/cache/poldek \
                -v $dir/cache/ccache/$PACKAGE_NAME:$home/.ccache \
-               $($TMPFS && echo "--tmpfs $home/rpm/BUILD:rw,exec,nosuid,size=$buildsize") \
+               $(tmpfs) \
                $image
 
        # set the homedir
@@ -108,7 +133,7 @@ package_build() {
 
 parse_options() {
        local t
-       t=$(getopt -o 'x' --long 'network,no-tmpfs,notmpfs' -n "$PROGRAM" -- "$@")
+       t=$(getopt -o 'x' --long 'network,no-tmpfs,notmpfs,tmpfs:' -n "$PROGRAM" -- "$@")
        [ $? != 0 ] && exit $?
        eval set -- "$t"
 
@@ -123,6 +148,10 @@ parse_options() {
                --no-tmpfs|--notmpfs)
                        TMPFS=false
                        ;;
+               --tmpfs)
+                       shift
+                       TMPFS="$1"
+                       ;;
                --)
                        shift
                        break
This page took 0.138618 seconds and 4 git commands to generate.