Skip to content

Commit 8fee76d

Browse files
author
Paul Dagnelie
authored
TOOL-15610 Add flag to buildpkg to cause the build to use locally-built dependencies (#251)
1 parent 7f58ac2 commit 8fee76d

2 files changed

Lines changed: 37 additions & 19 deletions

File tree

buildpkg.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function usage() {
3939
echo " -c also run package's checkstyle hook."
4040
echo " -r override default revision for package."
4141
echo " -h display this message and exit."
42+
echo " -l use locally-built dependencies instead of s3 versions."
4243
echo ""
4344
exit 2
4445
}
@@ -48,13 +49,15 @@ unset PARAM_PACKAGE_GIT_BRANCH
4849
unset PARAM_PACKAGE_REVISION
4950

5051
do_checkstyle=false
51-
while getopts ':b:cg:hr:' c; do
52+
source="s3"
53+
while getopts ':b:cg:hlr:' c; do
5254
case "$c" in
5355
g) export PARAM_PACKAGE_GIT_URL="$OPTARG" ;;
5456
b) export PARAM_PACKAGE_GIT_BRANCH="$OPTARG" ;;
5557
r) export PARAM_PACKAGE_REVISION="$OPTARG" ;;
5658
c) do_checkstyle=true ;;
5759
h) usage >&2 ;;
60+
l) source="local" ;;
5861
*) usage "illegal option -- $OPTARG" >&2 ;;
5962
esac
6063
done
@@ -86,7 +89,7 @@ logmust cd "$WORKDIR"
8689
stage fetch
8790

8891
logmust cd "$WORKDIR"
89-
stage fetch_dependencies
92+
stage fetch_dependencies $source
9093

9194
logmust cd "$WORKDIR"
9295
stage prepare

lib/common.sh

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,15 @@ function check_git_ref() {
214214
#
215215
function stage() {
216216
typeset hook=$1
217+
shift 1
217218

218219
check_env PACKAGE
219220
local stage_start=$SECONDS
220221

221222
echo ""
222223
if type -t "$hook" >/dev/null; then
223224
echo_bold "PACKAGE $PACKAGE: STAGE $hook STARTED"
224-
logmust "$hook"
225+
logmust "$hook" "$@"
225226
echo_bold "PACKAGE $PACKAGE: STAGE $hook COMPLETED in" \
226227
"$((SECONDS - stage_start)) seconds"
227228
else
@@ -699,6 +700,7 @@ function get_package_dependency_s3_url() {
699700
# is defined in the package's config.
700701
#
701702
function fetch_dependencies() {
703+
local source="$1"
702704
export DEPDIR="$WORKDIR/dependencies"
703705
logmust mkdir "$DEPDIR"
704706
logmust cd "$DEPDIR"
@@ -712,22 +714,35 @@ function fetch_dependencies() {
712714
for dep in $PACKAGE_DEPENDENCIES; do
713715
echo "Fetching artifacts for dependency '$dep' ..."
714716
get_package_prefix "$dep"
715-
s3urlvar="${_RET}_S3_URL"
716-
if [[ -n "${!s3urlvar}" ]]; then
717-
s3url="${!s3urlvar}"
718-
echo "S3 URL of package dependency '$dep' provided" \
719-
"externally"
720-
echo "$s3urlvar=$s3url"
721-
else
722-
logmust get_package_dependency_s3_url "$dep"
723-
s3url="$_RET"
724-
fi
725-
[[ "$s3url" != */ ]] && s3url="$s3url/"
726-
logmust mkdir "$dep"
727-
logmust aws s3 ls "$s3url"
728-
logmust aws s3 cp --only-show-errors --recursive "$s3url" "$dep/"
729-
echo_bold "Fetched artifacts for '$dep' from $s3url"
730-
PACKAGE_DEPENDENCIES_METADATA="${PACKAGE_DEPENDENCIES_METADATA}$dep: $s3url\\n"
717+
case "$source" in
718+
"local")
719+
logmust cp -r "$WORKDIR/../../$dep/tmp/artifacts/" \
720+
"$dep/"
721+
;;
722+
"s3")
723+
s3urlvar="${_RET}_S3_URL"
724+
if [[ -n "${!s3urlvar}" ]]; then
725+
s3url="${!s3urlvar}"
726+
echo "S3 URL of package dependency '$dep' " \
727+
"provided externally"
728+
echo "$s3urlvar=$s3url"
729+
else
730+
logmust get_package_dependency_s3_url "$dep"
731+
s3url="$_RET"
732+
fi
733+
[[ "$s3url" != */ ]] && s3url="$s3url/"
734+
logmust mkdir "$dep"
735+
logmust aws s3 ls "$s3url"
736+
logmust aws s3 cp --only-show-errors --recursive \
737+
"$s3url" "$dep/"
738+
echo_bold "Fetched artifacts for '$dep' from $s3url"
739+
PACKAGE_DEPENDENCIES_METADATA="" \
740+
"${PACKAGE_DEPENDENCIES_METADATA}$dep: $s3url\\n"
741+
;;
742+
*)
743+
die "invalid source parameter specified: '$source'"
744+
;;
745+
esac
731746
done
732747
}
733748

0 commit comments

Comments
 (0)