Skip to content

Commit

Permalink
Merge #254: Enable use of USE_* variables with values 0 or 1
Browse files Browse the repository at this point in the history
581120b USE_* variables: compare strings instead of integers (AbcSxyZ)
98f408d Enable use of USE_* variables with 0 or 1 (AbcSxyZ)
  • Loading branch information
devrandom committed Sep 19, 2021
2 parents 32b1145 + 581120b commit 4609325
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions bin/gbuild
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def build_one_configuration(suite, arch, build_desc)

bits = @bitness[arch] or raise "unknown architecture ${arch}"

if ENV["USE_LXC"]
if ENV["USE_LXC"] == "1"
ENV["LXC_ARCH"] = arch
ENV["LXC_SUITE"] = suite
end
Expand Down Expand Up @@ -228,7 +228,7 @@ OptionParser.new do |opts|
end
end.parse!

if !ENV["USE_LXC"] and !ENV["USE_DOCKER"] and !ENV["USE_VBOX"] and !File.exist?("/dev/kvm")
if ENV["USE_LXC"] != "1" and ENV["USE_DOCKER"] != "1" and ENV["USE_VBOX"] != "1" and !File.exist?("/dev/kvm")
$stderr.puts "\n************* WARNING: kvm not loaded, this will probably not work out\n\n"
end

Expand Down Expand Up @@ -273,7 +273,7 @@ docker_image_digests = build_desc["docker_image_digests"] || []
# if docker_image_digests are supplied, it must be the same length as suites
if docker_image_digests.size > 0 and suites.size != docker_image_digests.size
raise "`suites` and `docker_image_digests` must both be the same size if both are supplied"
elsif ENV["USE_DOCKER"] and docker_image_digests.size > 0 and suites.size == docker_image_digests.size
elsif ENV["USE_DOCKER"] == "1" and docker_image_digests.size > 0 and suites.size == docker_image_digests.size
suites = docker_image_digests
end

Expand Down
10 changes: 5 additions & 5 deletions libexec/copy-from-target
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ if [ $# = 0 ] ; then
exit 1
fi

if [ -n "$USE_DOCKER" ]; then
if [ "$USE_DOCKER" = "1" ]; then
# Use tar, so that files are created with the correct owner on the host
docker exec -u $TUSER gitian-target tar -C `dirname "$1"` -cf - `basename "$1"` | tar -C "$2" -xf -
elif [ -z "$USE_LXC" ]; then
src="${1%/}" # remove trailing / which triggers special rsync behaviour
rsync --checksum -a $QUIET_FLAG -e "ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT" "$TUSER@localhost:${src}" "$2"
else
elif [ "$USE_LXC" = "1" ]; then
config-lxc
sudo $LXC_EXECUTE -n gitian -f var/lxc.config -- sudo -i -u $TUSER tar -C `dirname "$1"` -cf - `basename "$1"` | tar -C "$2" -xf -
else
src="${1%/}" # remove trailing / which triggers special rsync behaviour
rsync --checksum -a $QUIET_FLAG -e "ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT" "$TUSER@localhost:${src}" "$2"
fi
10 changes: 5 additions & 5 deletions libexec/copy-to-target
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ if [ $# = 0 ] ; then
exit 1
fi

if [ -n "$USE_DOCKER" ]; then
if [ "$USE_DOCKER" = "1" ]; then
docker exec -u $TUSER gitian-target mkdir -p "/home/$TUSER/$2"
docker cp "$1" gitian-target:"/home/$TUSER/$2"
docker exec -u root gitian-target chown -R $TUSER:$TUSER "/home/$TUSER/$2"
elif [ -z "$USE_LXC" ]; then
src="${1%/}" # remove trailing / which triggers special rsync behaviour
rsync --checksum -a $QUIET_FLAG -e "ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT" "${src}" "$TUSER@localhost:$2"
else
elif [ "$USE_LXC" = "1" ]; then
config-lxc
tar -C `dirname "$1"` -cf - `basename "$1"` | sudo $LXC_EXECUTE -n gitian -f var/lxc.config -- sudo -i -u $TUSER tar -C "$2" -xf -
else
src="${1%/}" # remove trailing / which triggers special rsync behaviour
rsync --checksum -a $QUIET_FLAG -e "ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT" "${src}" "$TUSER@localhost:$2"
fi
2 changes: 1 addition & 1 deletion libexec/gconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VM_SSH_PORT=2223
if [ -n "$USE_LXC" ]; then
if [ "$USE_LXC" = "1" ]; then
if [ -z "$LXC_EXECUTE" ]; then
ver=`lxc-start --version`
if dpkg --compare-versions $ver ge 1.0.0 ; then
Expand Down
6 changes: 3 additions & 3 deletions libexec/make-clean-vm
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ SUITE=xenial
ARCH=amd64

VMSW=KVM
if [ -n "$USE_LXC" ]; then
if [ "$USE_LXC" = "1" ]; then
VMSW=LXC
elif [ -n "$USE_VBOX" ]; then
elif [ "$USE_VBOX" = "1" ]; then
VMSW=VBOX
elif [ -n "$USE_DOCKER" ]; then
elif [ "$USE_DOCKER" = "1" ]; then
VMSW=DOCKER
fi

Expand Down
8 changes: 4 additions & 4 deletions libexec/on-target
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ fi
# exit 1
#fi

if [ -n "$USE_DOCKER" ]; then
if [ "$USE_DOCKER" = "1" ]; then
docker exec -u $TUSER -i gitian-target $*
elif [ -z "$USE_LXC" ]; then
ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT $TUSER@localhost $*
else
elif [ "$USE_LXC" = "1" ]; then
config-lxc
sudo $LXC_EXECUTE -n gitian -f var/lxc.config -- sudo -u $TUSER $ENV -i -- $*
else
ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT $TUSER@localhost $*
fi
6 changes: 3 additions & 3 deletions libexec/start-target
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ ARCH=qemu$1
SUFFIX=$2

VMSW=KVM
if [ -n "$USE_LXC" ]; then
if [ "$USE_LXC" = "1" ]; then
VMSW=LXC
elif [ -n "$USE_VBOX" ]; then
elif [ "$USE_VBOX" = "1" ]; then
VMSW=VBOX
elif [ -n "$USE_DOCKER" ]; then
elif [ "$USE_DOCKER" = "1" ]; then
VMSW=DOCKER
fi

Expand Down
6 changes: 3 additions & 3 deletions libexec/stop-target
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/sh

VMSW=KVM
if [ -n "$USE_LXC" ]; then
if [ "$USE_LXC" = "1" ]; then
VMSW=LXC
elif [ -n "$USE_VBOX" ]; then
elif [ "$USE_VBOX" = "1" ]; then
VMSW=VBOX
elif [ -n "$USE_DOCKER" ]; then
elif [ "$USE_DOCKER" = "1" ]; then
VMSW=DOCKER
fi

Expand Down

0 comments on commit 4609325

Please sign in to comment.