fixed errors when running appliance packager on macOS #492
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🗣 Description
This pull request modifies both the tar and date commands to conditionally adapt their behavior depending on the underlying operating system.
1. tar Command: The script checks whether it’s running on macOS or Linux using the uname command. For macOS, the tar command is executed without the --owner and --group flags due to compatibility issues with bsdtar. For Linux, the tar command includes the --numeric-owner, --owner=0, and --group=0 flags to set file ownership to root. This ensures compatibility across both platforms.
2. date Command: The date command was adjusted to handle platform-specific differences. On Linux, it uses the standard date format, while on macOS, adjustments are made to accommodate slight differences in how the date command handles formatting.
This update ensures that both commands work seamlessly on macOS and Linux systems, resolving issues with incompatible options.
💭 Motivation and context
These changes are required to address platform-specific differences in the tar and date commands. macOS uses bsdtar, which does not support the --owner and --group flags, while Linux requires them for setting file ownership. Similarly, the date command on macOS differs slightly from its Linux counterpart. By implementing these adjustments, the script will now function correctly on both operating systems without errors.
🧪 Testing
The changes were tested by running the script on macOS. On macOS, the script ran without the --owner and --group options in tar, and the date command executed with the correct format.
✅ Pre-approval checklist
ToDo: • Add relevant type of type-of-change labels