From e4b9523e9bf1c4951e2548ae065f2eaed07cfd18 Mon Sep 17 00:00:00 2001 From: Prakash Surya Date: Tue, 26 May 2026 22:41:40 +0000 Subject: [PATCH 1/2] TOOL-30021 Bootstrap upstreams/ from UPSTREAM_GIT_URL when missing fetch_repo_from_git previously failed hard if a package's upstreams/$DEFAULT_GIT_BRANCH branch did not yet exist on origin, blocking the very first upstream-sync run for any newly onboarded upstream-tracked package. The package-onboarding flow expected this branch to be pre-seeded manually before automation could run, but the branch protection (push restricted to delphix-devops-bot) makes that manual step inaccessible to the spec authors typically onboarding the package. Detect the missing-branch case and bootstrap upstream-HEAD directly from UPSTREAM_GIT_URL/UPSTREAM_GIT_BRANCH, marking $WORKDIR/upstream-updated so sync-with-upstream.sh pushes upstream-HEAD back to origin -- git push creates the upstreams/ branch on origin in the process. Requires both UPSTREAM_GIT_URL and UPSTREAM_GIT_BRANCH to be set; falls back to the previous die with a clearer message otherwise. To make the bootstrap fallback possible, git_fetch_helper no longer dies internally on failure -- the four existing logmust callers still fail-hard via logmust's own error handling, while the new fallback caller can branch on the exit code. Follow-up to delphix/cd-aidlc spec 0003 Phase 2, surfaced by the first run of check-updates against the new sdb upstream-tracking recipe. Co-Authored-By: Claude Opus 4.7 --- lib/common.sh | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index 7daffe68..e88a9bcd 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -788,7 +788,12 @@ function git_fetch_helper() { label='[token passed]' fi echo "Running: $label git fetch $orig_url $*" - git fetch "$git_url" "$@" || die "git fetch failed" + # + # Don't die here; logmust callers still fail-hard via logmust's own + # error handling, while non-logmust callers (e.g. fetch_repo_from_git's + # upstream-branch bootstrap fallback) can react to the failure. + # + git fetch "$git_url" "$@" } # @@ -827,8 +832,30 @@ function fetch_repo_from_git() { if [[ "$DO_UPDATE_PACKAGE" == "true" ]]; then logmust git_fetch_helper "$PACKAGE_GIT_URL" --no-tags \ "+$PACKAGE_GIT_BRANCH:repo-HEAD" - logmust git_fetch_helper "$PACKAGE_GIT_URL" --no-tags \ - "+upstreams/$DEFAULT_GIT_BRANCH:upstream-HEAD" + # + # Try to fetch the upstream-tracking branch from the package's + # own repository. If it doesn't exist yet -- first time the + # package is being synced -- bootstrap upstream-HEAD directly + # from the third-party upstream specified by UPSTREAM_GIT_URL / + # UPSTREAM_GIT_BRANCH, and mark upstream-updated so + # sync-with-upstream.sh pushes upstream-HEAD back to origin, + # creating the upstreams/ branch in the process. + # + if git_fetch_helper "$PACKAGE_GIT_URL" --no-tags \ + "+upstreams/$DEFAULT_GIT_BRANCH:upstream-HEAD"; then + : + elif [[ -n "$UPSTREAM_GIT_URL" && -n "$UPSTREAM_GIT_BRANCH" ]]; then + echo "NOTE: upstreams/$DEFAULT_GIT_BRANCH does not exist" \ + "on $PACKAGE_GIT_URL; bootstrapping upstream-HEAD" \ + "from $UPSTREAM_GIT_URL ($UPSTREAM_GIT_BRANCH)." + logmust git_fetch_helper "$UPSTREAM_GIT_URL" --no-tags \ + "+$UPSTREAM_GIT_BRANCH:upstream-HEAD" + logmust touch "$WORKDIR/upstream-updated" + else + die "Failed to fetch upstreams/$DEFAULT_GIT_BRANCH from" \ + "$PACKAGE_GIT_URL and UPSTREAM_GIT_URL/" \ + "UPSTREAM_GIT_BRANCH are not set to bootstrap from." + fi logmust git show-ref repo-HEAD logmust git show-ref upstream-HEAD else From 9bb44b720ca0839f3218fc313a470e764e407470 Mon Sep 17 00:00:00 2001 From: Prakash Surya Date: Tue, 26 May 2026 22:43:06 +0000 Subject: [PATCH 2/2] TOOL-30021 Enable upstream tracking for sdb against sdimitro/sdb develop Wire packages/sdb/config.sh up to the upstream-tracking automation introduced by the prior commit, completing Phase 2 of delphix/cd-aidlc spec 0003 (Adopt sdimitro/sdb as upstream; repackage via dh-virtualenv). The build() override derives PACKAGE_VERSION from setuptools_scm so the .deb's metadata version follows upstream sdb tags automatically; pyproject.toml's local_scheme="no-local-version" keeps the value debian-version-safe (no embedded "-"), letting linux-pkg's set_changelog append the standard "-1delphix." revision suffix without further massaging. Phase 1 (delphix/sdb#360, merged 2026-05-06) landed the bootstrap merge from sdimitro/develop plus the dh-virtualenv overlay, including python3-setuptools-scm in Build-Depends so the build() override here works with no companion delphix/sdb change. Co-Authored-By: Claude Opus 4.7 --- packages/sdb/config.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/sdb/config.sh b/packages/sdb/config.sh index b6430637..3b36fed4 100644 --- a/packages/sdb/config.sh +++ b/packages/sdb/config.sh @@ -18,10 +18,27 @@ # shellcheck disable=SC2034 DEFAULT_PACKAGE_GIT_URL="https://github.com/delphix/sdb.git" +UPSTREAM_GIT_URL="https://github.com/sdimitro/sdb.git" +UPSTREAM_GIT_BRANCH="develop" + function prepare() { logmust install_build_deps_from_control_file } function build() { + local scm_version + scm_version=$(cd "$WORKDIR/repo" && python3 -m setuptools_scm 2>/dev/null) || + die "setuptools_scm version derivation failed" + # + # pyproject.toml sets local_scheme="no-local-version", so the value + # is debian-version-safe. Pass it through as-is; linux-pkg's + # set_changelog appends "-1delphix." since PACKAGE_VERSION has + # no "-", producing e.g. "0.6.0-1delphix.". + # + export PACKAGE_VERSION="${scm_version}" logmust dpkg_buildpackage_default } + +function update_upstream() { + logmust update_upstream_from_git +}