Skip to content

Commit

Permalink
DLPX-85904 Remove hardcoded git branch from appliance-build (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
palash-gandhi authored Jun 22, 2023
1 parent 519f5d3 commit 48a7358
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 73 deletions.
13 changes: 0 additions & 13 deletions branch.config

This file was deleted.

4 changes: 1 addition & 3 deletions scripts/aptly-repo-from-debs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ done
# Download the delphix upgrade verification debian package, stored in the
# combined-packages bundle.
#
AWS_S3_URI_COMBINED_PACKAGES=$(resolve_s3_uri \
"$AWS_S3_URI_COMBINED_PACKAGES" \
"linux-pkg/${UPSTREAM_BRANCH}/combine-packages/post-push/latest")
AWS_S3_URI_COMBINED_PACKAGES=$(resolve_s3_uri "$AWS_S3_URI_COMBINED_PACKAGES")

WORK_DIRECTORY=$(mktemp -d -p "$TOP/upgrade" tmp.pkgs.XXXXXXXXXX)

Expand Down
28 changes: 1 addition & 27 deletions scripts/build-ancillary-repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,6 @@ function build_ancillary_repository() {
EOF
}

#
# Set UPSTREAM_BRANCH. This will determine which version of the linux package
# mirror is used.
#
if [[ -z "$UPSTREAM_PRODUCT_BRANCH" ]]; then
echo "UPSTREAM_PRODUCT_BRANCH is not set."
if ! source "$TOP/branch.config" 2>/dev/null; then
echo "No branch.config file found in repo root."
exit 1
fi

if [[ -z "$UPSTREAM_BRANCH" ]]; then
echo "UPSTREAM_BRANCH parameter was not sourced from branch.config." \
"Ensure branch.config is properly formatted with e.g." \
"UPSTREAM_BRANCH=\"<upstream-product-branch>\""
exit 1
fi
echo "Defaulting to branch $UPSTREAM_BRANCH set in branch.config."
else
UPSTREAM_BRANCH="$UPSTREAM_PRODUCT_BRANCH"
fi
echo "Running with UPSTREAM_BRANCH set to ${UPSTREAM_BRANCH}"

#
# The packages produced by Delphix are stored in Amazon S3.
# Thus, in order to populate the ancillary repository with these
Expand All @@ -95,10 +72,7 @@ echo "Running with UPSTREAM_BRANCH set to ${UPSTREAM_BRANCH}"
# packages from there, otherwise determine the latest combined-packages URI
# automatically.
#

AWS_S3_URI_COMBINED_PACKAGES=$(resolve_s3_uri \
"$AWS_S3_URI_COMBINED_PACKAGES" \
"linux-pkg/${UPSTREAM_BRANCH}/combine-packages/post-push/latest")
AWS_S3_URI_COMBINED_PACKAGES=$(resolve_s3_uri "$AWS_S3_URI_COMBINED_PACKAGES")

mkdir -p "$TOP/build"
WORK_DIRECTORY=$(mktemp -d -p "$TOP/build" tmp.pkgs.XXXXXXXXXX)
Expand Down
40 changes: 33 additions & 7 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,25 @@ function die() {

function resolve_s3_uri() {
local pkg_uri="$1"
local latest_subprefix="$2"

local bucket="snapshot-de-images"
local jenkinsid="jenkins-ops"
local resolved_uri

if [[ -n "$pkg_uri" ]]; then
resolved_uri="$pkg_uri"
elif [[ -n "$latest_subprefix" ]]; then
else
#
# Set UPSTREAM_BRANCH. This will determine which version of the linux package
# mirror is used.
#
UPSTREAM_BRANCH=$(get_upstream_or_fail_if_unset) || exit 1
echo "Running with UPSTREAM_BRANCH set to ${UPSTREAM_BRANCH}"
local latest_subprefix="linux-pkg/${UPSTREAM_BRANCH}/combine-packages/post-push/latest"
local bucket="snapshot-de-images"
local jenkinsid="jenkins-ops"
aws s3 cp --quiet \
"s3://$bucket/builds/$jenkinsid/$latest_subprefix" .
resolved_uri="s3://$bucket/$(cat latest)"
rm -f latest
else
echo "Invalid arguments provided to resolve_s3_uri()" 2>&1
exit 1
fi

if aws s3 ls "$resolved_uri" &>/dev/null; then
Expand Down Expand Up @@ -135,3 +138,26 @@ function extract_debs_into_dir() {
find "$source_dir" -name '*.deb' -exec mv {} "$target_dir" \;
find "$source_dir" -name '*.ddeb' -exec mv {} "$target_dir" \;
}

function get_upstream_or_fail_if_unset() {
if [[ -z "$UPSTREAM_PRODUCT_BRANCH" ]]; then
local upstream_branch
upstream_branch="$(git rev-parse --abbrev-ref --symbolic-full-name "@{u}" | cut -d'/' -f2-)"
if [[ -z $upstream_branch ]]; then
echo "ERROR: The currently checked out branch" >&2
echo " does not have an upstream branch configured. Set the" >&2
echo " upstream branch you plan to push to:" >&2
echo "" >&2
echo " git branch --set-upstream-to=<upstream>" >&2
echo "" >&2
echo " Then run this script again. '<upstream>' can be " >&2
echo " something like '6.0/stage'" >&2
return 1
else
echo "$upstream_branch"
return 0
fi
else
echo "$UPSTREAM_PRODUCT_BRANCH"
fi
}
39 changes: 16 additions & 23 deletions scripts/run-live-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# limitations under the License.
#

. "${BASH_SOURCE%/*}/common.sh"

TOP=$(git rev-parse --show-toplevel 2>/dev/null)

if [[ -z "$TOP" ]]; then
Expand Down Expand Up @@ -138,33 +140,17 @@ while ! curl --output /dev/null --silent --head --fail \
sleep 1
done

#
# Set UPSTREAM_BRANCH. This will determine which version of the linux package
# mirror is used.
#
if [[ -z "$UPSTREAM_PRODUCT_BRANCH" ]]; then
echo "UPSTREAM_PRODUCT_BRANCH is not set."
if ! source "$TOP/branch.config" 2>/dev/null; then
echo "No branch.config file found in repo root."
exit 1
fi

if [[ -z "$UPSTREAM_BRANCH" ]]; then
echo "UPSTREAM_BRANCH parameter was not sourced from branch.config." \
"Ensure branch.config is properly formatted with e.g." \
"UPSTREAM_BRANCH=\"<upstream-product-branch>\""
exit 1
fi
echo "Defaulting to branch $UPSTREAM_BRANCH set in branch.config."
else
UPSTREAM_BRANCH="$UPSTREAM_PRODUCT_BRANCH"
fi
echo "Running with UPSTREAM_BRANCH set to ${UPSTREAM_BRANCH}"

pkg_mirror_secondary=''
if [[ -n "$DELPHIX_PACKAGE_MIRROR_SECONDARY" ]]; then
pkg_mirror_secondary="$DELPHIX_PACKAGE_MIRROR_SECONDARY"
else
#
# Set UPSTREAM_BRANCH. This will determine which version of the linux package
# mirror is used.
#
UPSTREAM_BRANCH=$(get_upstream_or_fail_if_unset) || exit 1
echo "Running with UPSTREAM_BRANCH set to ${UPSTREAM_BRANCH}"

#
# If no secondary package mirror is provided, then pull in the latest
# mirror dataset for the build. If no latest dataset is found, then fail.
Expand All @@ -188,6 +174,13 @@ pkg_mirror_main=''
if [[ -n "$DELPHIX_PACKAGE_MIRROR_MAIN" ]]; then
pkg_mirror_main="$DELPHIX_PACKAGE_MIRROR_MAIN"
else
#
# Set UPSTREAM_BRANCH. This will determine which version of the linux package
# mirror is used.
#
UPSTREAM_BRANCH=$(get_upstream_or_fail_if_unset) || exit 1
echo "Running with UPSTREAM_BRANCH set to ${UPSTREAM_BRANCH}"

#
# If no main package mirror is provided, then pull in the latest mirror
# dataset for the build. If no latest dataset is found, then fail.
Expand Down

0 comments on commit 48a7358

Please sign in to comment.