Skip to content

Commit

Permalink
Bug 1328205 - Improve argument handling in scripts, r=ttaubert
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : a99011f4940c234d56c0a628d5240c87b2c671e0
  • Loading branch information
martinthomson committed Jan 5, 2017
1 parent 9ab47c4 commit d457d62
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 167 deletions.
9 changes: 2 additions & 7 deletions automation/taskcluster/scripts/build.sh
@@ -1,14 +1,9 @@
#!/usr/bin/env bash

source $(dirname $0)/tools.sh

if [[ $(id -u) -eq 0 ]]; then
# Drop privileges by re-running this script.
exec su worker $0
fi
source $(dirname "$0")/tools.sh

# Clone NSPR if needed.
hg_clone https://hg.mozilla.org/projects/nspr nspr default
hg_clone https://hg.mozilla.org/projects/nspr ./nspr default

# Build.
make -C nss nss_build_all
Expand Down
11 changes: 3 additions & 8 deletions automation/taskcluster/scripts/build_gyp.sh
@@ -1,17 +1,12 @@
#!/usr/bin/env bash

source $(dirname $0)/tools.sh

if [[ $(id -u) -eq 0 ]]; then
# Drop privileges by re-running this script.
exec su worker -c "$0 $*"
fi
source $(dirname "$0")/tools.sh

# Clone NSPR if needed.
hg_clone https://hg.mozilla.org/projects/nspr nspr default
hg_clone https://hg.mozilla.org/projects/nspr ./nspr default

# Build.
nss/build.sh ${*--g -v}
nss/build.sh -g -v "$@"

# Package.
mkdir artifacts
Expand Down
7 changes: 1 addition & 6 deletions automation/taskcluster/scripts/extend_task_graph.sh
@@ -1,11 +1,6 @@
#!/usr/bin/env bash

set -v -e -x

if [ $(id -u) = 0 ]; then
# Drop privileges by re-running this script.
exec su worker $0
fi
source $(dirname "$0")/tools.sh

mkdir -p /home/worker/artifacts

Expand Down
11 changes: 4 additions & 7 deletions automation/taskcluster/scripts/fuzz.sh
@@ -1,11 +1,6 @@
#!/usr/bin/env bash

source $(dirname $0)/tools.sh

if [ $(id -u) = 0 ]; then
# Drop privileges by re-running this script.
exec su worker -c "$0 $*"
fi
source $(dirname "$0")/tools.sh

# Fetch artifact if needed.
fetch_dist
Expand All @@ -17,4 +12,6 @@ fetch_dist
objdir=$(cat dist/latest)

# Run nssfuzz.
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:dist/$objdir/lib dist/$objdir/bin/nssfuzz-$*
type="$1"
shift
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:dist/$objdir/lib dist/$objdir/bin/nssfuzz-"$type" "$@"
12 changes: 1 addition & 11 deletions automation/taskcluster/scripts/gen_certs.sh
@@ -1,16 +1,6 @@
#!/usr/bin/env bash

set -v -e -x

source $(dirname $0)/tools.sh

if [ $(id -u) = 0 ]; then
# Stupid Docker.
echo "127.0.0.1 localhost.localdomain" >> /etc/hosts

# Drop privileges by re-running this script.
exec su worker $0
fi
source $(dirname "$0")/tools.sh

# Fetch artifact if needed.
fetch_dist
Expand Down
7 changes: 1 addition & 6 deletions automation/taskcluster/scripts/run_clang_format.sh
@@ -1,11 +1,6 @@
#!/usr/bin/env bash

set -v -e -x

if [ $(id -u) -eq 0 ]; then
# Drop privileges by re-running this script.
exec su worker $0 "$@"
fi
source $(dirname "$0")/tools.sh

# Apply clang-format on the provided folder and verify that this doesn't change any file.
# If any file differs after formatting, the script eventually exits with 1.
Expand Down
9 changes: 2 additions & 7 deletions automation/taskcluster/scripts/run_scan_build.sh
@@ -1,15 +1,10 @@
#!/usr/bin/env bash

source $(dirname $0)/tools.sh

if [ $(id -u) = 0 ]; then
# Drop privileges by re-running this script.
exec su worker $0 $@
fi
source $(dirname "$0")/tools.sh

# Clone NSPR if needed.
if [ ! -d "nspr" ]; then
hg_clone https://hg.mozilla.org/projects/nspr nspr default
hg_clone https://hg.mozilla.org/projects/nspr ./nspr default
fi

# Build.
Expand Down
10 changes: 1 addition & 9 deletions automation/taskcluster/scripts/run_tests.sh
@@ -1,14 +1,6 @@
#!/usr/bin/env bash

source $(dirname $0)/tools.sh

if [ $(id -u) = 0 ]; then
# Stupid Docker.
echo "127.0.0.1 localhost.localdomain" >> /etc/hosts

# Drop privileges by re-running this script.
exec su worker $0
fi
source $(dirname "$0")/tools.sh

# Fetch artifact if needed.
fetch_dist
Expand Down
6 changes: 6 additions & 0 deletions automation/taskcluster/scripts/tools.sh
Expand Up @@ -2,6 +2,12 @@

set -v -e -x

if [[ $(id -u) -eq 0 ]]; then
# Drop privileges by re-running this script.
# Note: this mangles arguments, better to avoid running scripts as root.
exec su worker -c "$0 $*"
fi

# Usage: hg_clone repo dir [revision=@]
hg_clone() {
repo=$1
Expand Down

0 comments on commit d457d62

Please sign in to comment.