Skip to content

azurelinux-repos: fix dist tag date extraction for tilde-only forms#16646

Merged
christopherco merged 1 commit intomicrosoft:tomls/base/mainfrom
reubeno:fix-repo-file-gen
Apr 13, 2026
Merged

azurelinux-repos: fix dist tag date extraction for tilde-only forms#16646
christopherco merged 1 commit intomicrosoft:tomls/base/mainfrom
reubeno:fix-repo-file-gen

Conversation

@reubeno
Copy link
Copy Markdown
Member

@reubeno reubeno commented Apr 13, 2026

The date extraction logic split on '.' to get the last segment, which worked for dist tags like .azl4~bootstrap.20260303 but failed for .azl4~20260412 where there is no dot before the date.

Replace the awk dot-split with grep -oE to extract the 8-digit date directly from anywhere in the dist tag.

_Verification: verified with both a stage1 and stage2 style dist tag locally via azldev; verified via CT + koji with scratch builds against both stage1 and stage2 tags, manually downloaded and inspected built RPMs.

The date extraction logic split on '.' to get the last segment, which
worked for dist tags like '.azl4~bootstrap.20260303' but failed for
'.azl4~20260412' where there is no dot before the date.

Replace the awk dot-split with grep -oE to extract the 8-digit date
directly from anywhere in the dist tag.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@reubeno reubeno marked this pull request as ready for review April 13, 2026 19:03
Copilot AI review requested due to automatic review settings April 13, 2026 19:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes dist tag date extraction in azurelinux-repos.spec so that BASE_REPO_URI computation works for both dotted and tilde-only dist tag formats.

Changes:

  • Bump Release from 4 to 5.
  • Replace dot-splitting awk logic with regex extraction of an 8-digit date from %{dist}.
  • Add changelog entry documenting the behavior change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +117 to +120
# Extract an 8-digit date stamp from %%dist.
# Handles both dotted forms (e.g. ".azl4~bootstrap.20260303") and tilde-only forms (e.g. ".azl4~20260412").
# If no 8-digit date is found, fall back to a hard-coded URI.
date_segment=$(echo '%{dist}' | grep -oE '[0-9]{8}')
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grep -oE will output all 8-digit matches, potentially producing multiple lines in date_segment (e.g., newline-separated). That would make base_repo_uri malformed and could lead to unexpected behavior when %{dist} ever contains more than one 8-digit sequence. Prefer constraining to a single match (e.g., first match via grep -m1 -oE ... or piping to head -n1) and/or stripping newlines before using it in the URL.

Suggested change
# Extract an 8-digit date stamp from %%dist.
# Handles both dotted forms (e.g. ".azl4~bootstrap.20260303") and tilde-only forms (e.g. ".azl4~20260412").
# If no 8-digit date is found, fall back to a hard-coded URI.
date_segment=$(echo '%{dist}' | grep -oE '[0-9]{8}')
# Extract the first 8-digit date stamp from %%dist.
# Handles both dotted forms (e.g. ".azl4~bootstrap.20260303") and tilde-only forms (e.g. ".azl4~20260412").
# If no 8-digit date is found, fall back to a hard-coded URI.
date_segment=$(echo '%{dist}' | grep -oE '[0-9]{8}' | head -n1)

Copilot uses AI. Check for mistakes.
@christopherco christopherco merged commit 5143c59 into microsoft:tomls/base/main Apr 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants