azurelinux-repos: fix dist tag date extraction for tilde-only forms#16646
Conversation
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>
There was a problem hiding this comment.
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
Releasefrom4to5. - Replace dot-splitting
awklogic 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.
| # 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}') |
There was a problem hiding this comment.
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.
| # 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) |
The date extraction logic split on '.' to get the last segment, which worked for dist tags like
.azl4~bootstrap.20260303but failed for.azl4~20260412where there is no dot before the date.Replace the
awkdot-split withgrep -oEto 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.