Skip to content

Commit

Permalink
Properly quote variables in bashs cripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Dec 19, 2024
1 parent bab827b commit a6fdcbc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ci/add-apt-keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function do_add_key
keyfilename=$(basename -s .key "$key_url")
fi
echo -e "\tDownloading APT key from '$key_url' to '$keyfilename'"
if ! curl -sSL --retry ${NET_RETRY_COUNT:-5} "$key_url" | sudo gpg --dearmor -o "/etc/apt/trusted.gpg.d/${keyfilename}"; then
if ! curl -sSL --retry "${NET_RETRY_COUNT:-5}" "$key_url" | sudo gpg --dearmor -o "/etc/apt/trusted.gpg.d/${keyfilename}"; then
echo "Failed downloading $keyfilename"
return 1
fi
Expand Down
2 changes: 1 addition & 1 deletion ci/add-apt-repositories.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set -eu
function do_add_repository {
name=$1
echo -e "\tAdding repository $name"
for i in $(seq ${NET_RETRY_COUNT:-3}); do
for i in $(seq "${NET_RETRY_COUNT:-3}"); do
if [[ $i -ne 1 ]]; then
sleep 10
echo -e "\tRetrying"
Expand Down
2 changes: 1 addition & 1 deletion ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

set -ex

: ${B2_TARGETS:="libs/$SELF/test"}
: "${B2_TARGETS:="libs/$SELF/test"}"

. "$(dirname "${BASH_SOURCE[0]}")"/enforce.sh

Expand Down
18 changes: 9 additions & 9 deletions ci/codecov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

set -ex

. $(dirname "${BASH_SOURCE[0]}")/enforce.sh
. "$(dirname "${BASH_SOURCE[0]}")"/enforce.sh

coverage_action=$1

Expand Down Expand Up @@ -55,7 +55,7 @@ elif [[ "$coverage_action" == "collect" ]] || [[ "$coverage_action" == "upload"
fi

# install the latest lcov we know works
: ${LCOV_VERSION:=v1.15}
: "${LCOV_VERSION:=v1.15}"

if [[ "$LCOV_VERSION" =~ ^v[2-9] ]]; then
sudo apt-get install -y libcapture-tiny-perl libdatetime-perl || true
Expand All @@ -65,33 +65,33 @@ elif [[ "$coverage_action" == "collect" ]] || [[ "$coverage_action" == "upload"

rm -rf /tmp/lcov
cd /tmp
git clone --depth 1 -b ${LCOV_VERSION} https://github.com/linux-test-project/lcov.git
git clone --depth 1 -b "${LCOV_VERSION}" https://github.com/linux-test-project/lcov.git
export PATH=/tmp/lcov/bin:$PATH
command -v lcov
lcov --version

# switch back to the original source code directory
cd $BOOST_CI_SRC_FOLDER
cd "$BOOST_CI_SRC_FOLDER"
: "${LCOV_BRANCH_COVERAGE:=1}" # Set default

# coverage files are in ../../b2 from this location
lcov ${LCOV_OPTIONS} --rc lcov_branch_coverage=${LCOV_BRANCH_COVERAGE} --gcov-tool=$GCOV --directory "$BOOST_ROOT" --capture --output-file all.info
lcov ${LCOV_OPTIONS} --rc lcov_branch_coverage="${LCOV_BRANCH_COVERAGE}" --gcov-tool="$GCOV" --directory "$BOOST_ROOT" --capture --output-file all.info
# dump a summary on the console
lcov --rc lcov_branch_coverage=${LCOV_BRANCH_COVERAGE} --list all.info
lcov --rc lcov_branch_coverage="${LCOV_BRANCH_COVERAGE}" --list all.info

# all.info contains all the coverage info for all projects - limit to ours
# first we extract the interesting headers for our project then we use that list to extract the right things
for f in `for f in include/boost/*; do echo $f; done | cut -f2- -d/`; do echo "*/$f*"; done > /tmp/interesting
for f in $(for h in include/boost/*; do echo "$h"; done | cut -f2- -d/); do echo "*/$f*"; done > /tmp/interesting
echo headers that matter:
cat /tmp/interesting
xargs --verbose -L 999999 -a /tmp/interesting lcov ${LCOV_OPTIONS} --rc lcov_branch_coverage=${LCOV_BRANCH_COVERAGE} --extract all.info "*/libs/$SELF/*" --output-file coverage.info
xargs --verbose -L 999999 -a /tmp/interesting lcov ${LCOV_OPTIONS} --rc lcov_branch_coverage="${LCOV_BRANCH_COVERAGE}" --extract all.info "*/libs/$SELF/*" --output-file coverage.info

# dump a summary on the console - helps us identify problems in pathing
# note this has test file coverage in it - if you do not want to count test
# files against your coverage numbers then use a .codecov.yml file which
# must be checked into the default branch (it is not read or used from a
# pull request)
lcov --rc lcov_branch_coverage=${LCOV_BRANCH_COVERAGE} --list coverage.info
lcov --rc lcov_branch_coverage="${LCOV_BRANCH_COVERAGE}" --list coverage.info

if [[ "$coverage_action" == "upload" ]] && [[ "$BOOST_CI_CODECOV_IO_UPLOAD" != "skip" ]]; then
#
Expand Down
2 changes: 1 addition & 1 deletion ci/coverity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if [[ "${1:-}" != "--skipdownload" ]]; then
curl -L -d "token=$COVERITY_SCAN_TOKEN&project=$BOOST_REPO" -X POST https://scan.coverity.com/download/cxx/linux64 -o coverity_tool.tgz
tar xzf coverity_tool.tgz
fi
COVBIN=$(echo $(pwd)/cov-analysis*/bin)
COVBIN=$(echo "$(pwd)"/cov-analysis*/bin)
export PATH=$COVBIN:$PATH
popd

Expand Down
7 changes: 6 additions & 1 deletion ci/drone/linux-cxx-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set -e
function add_repository {
name="$1"
echo -e "\tAdding repository $name"
for i in {1..3}; do sudo -E apt-add-repository -y "$name" && return 0 || sleep 10; done
for _i in {1..3}; do
if sudo -E apt-add-repository -y "$name"; then
return 0;
fi
sleep 10
done
return 1 # Failed
}

Expand Down

0 comments on commit a6fdcbc

Please sign in to comment.