diff options
author | Elan Ruusamäe | 2018-12-31 09:28:18 (GMT) |
---|---|---|
committer | Elan Ruusamäe | 2018-12-31 09:28:18 (GMT) |
commit | 2da31caa754f920335a6c371f2b883b570fe717f (patch) | |
tree | 0cb78a554af9bca3576e0b5deee9b5b6bcc429f6 | |
parent | 8447721f088e61dc473663e15af18340155776d1 (diff) | |
download | cleanbuild-2da31caa754f920335a6c371f2b883b570fe717f.zip cleanbuild-2da31caa754f920335a6c371f2b883b570fe717f.tar.gz |
add --tmpfs=2G to specicify size of build tmpfs size
-rwxr-xr-x | cleanbuild-docker.sh | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/cleanbuild-docker.sh b/cleanbuild-docker.sh index 8f4f7c3..6a9ac30 100755 --- a/cleanbuild-docker.sh +++ b/cleanbuild-docker.sh @@ -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 |