-
Notifications
You must be signed in to change notification settings - Fork 110
Update stemcell-repack-debugger #452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ubuntu-noble
Are you sure you want to change the base?
Update stemcell-repack-debugger #452
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the stemcell repack debugger script by implementing intelligent version bumping functionality and adding support for custom output paths. The version bumping now uses semantic versioning with dev suffixes (e.g., 1.0.0+dev.1) instead of timestamp-based versions, and can automatically detect and increment existing dev versions.
Key changes:
- Implements semantic dev versioning that increments on each repack of the same stemcell
- Adds support for
OUTenvironment variable to specify custom output paths - Optimizes tar file ordering to speed up version detection
- Adds support for
TMPDIRenvironment variable documentation
Comments suppressed due to low confidence (7)
scripts/stemcell-repack-debugger.sh:146
- The command substitution in the tar command could fail if filenames contain special characters or spaces. The
du -b * | sort -n | awk '{print $2}'pattern doesn't properly handle filenames with spaces. Consider using null-terminated strings:
du -b * | sort -n | awk '{print $2}' | tr '\n' '\0' | xargs -0 tar czvf ${OUT:-$stemcell_tgz}Or use an array to store filenames safely:
readarray -t files < <(du -b * | sort -n | awk '{print $2}')
tar czvf ${OUT:-$stemcell_tgz} "${files[@]}"scripts/stemcell-repack-debugger.sh:108
- The regex pattern
's/dev[.]//'is missing the bracket closing. It should be's/dev\.//'to properly escape the dot, or if you're trying to match "dev." as a prefix, use's/^dev\.//'. The current pattern matches "dev" followed by any single character in the set containing only a dot, which is effectively just a dot.
scripts/stemcell-repack-debugger.sh:117 - The backreference
\1in the replacement string may need to be escaped as\\1to work correctly within double quotes when using the-rflag. The-rflag is also not portable (BSD/macOS use-E). Consider using:
sed -r -i "s/^([[:space:]]*)version: .*/\\1version: ${new_version}/" $stemcell_dir/stemcell.MFOr for better portability:
sed -E -i "s/^([[:space:]]*)version: .*/\\1version: ${new_version}/" $stemcell_dir/stemcell.MFscripts/stemcell-repack-debugger.sh:14
- Spelling error: "als" should be "also".
scripts/stemcell-repack-debugger.sh:57 - The use of
-afor AND in the test command is deprecated. Use&&or-awith proper quoting. The preferred modern syntax would be:
if [ -n "$OUT" ] && [ -f "$OUT" ]; thenThis improves readability and avoids potential issues with the deprecated -a operator.
scripts/stemcell-repack-debugger.sh:100
- Missing quotes around variable
$DISK_NAMEcould cause issues if the variable contains spaces or special characters. Should be:
device=$(sudo kpartx -sav "$DISK_NAME" | grep '^add' | tail -n1 | cut -d' ' -f3)scripts/stemcell-repack-debugger.sh:116
- These lines have two issues:
- They appear to be leftover debugging statements that print the stemcell version before and after modification. Consider removing them or redirecting to stderr if the output is intentional for user feedback.
- The indentation is inconsistent - these lines should be indented to match line 115 since they're inside the
ifblock.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
i worked on this a while ago but never made a PR see https://github.com/cloudfoundry/bosh-linux-stemcell-builder/tree/helper-script Please note that warden stemcells are packaged differently |
|
@Alphasite replaced all yq usage now. |
While addressing cloudfoundry/bosh-agent#337 I was in the need to build stemcells for Jammy and was limited in where I build them (with limited disk space). Hence I had to add/adjust a few things to this script.