Refactor shell execute functions.
This change adds a new shell.ExecBuilder type. This type uses the builder pattern and is used to execute sub-processes. This makes it easier to add new features to API without experiencing an exponential explosion in API size, like what can happen with the flat functions.
The shell.ExecBuilder type adds the ability to set the working directory and the sub-process's environment variables. This is needed for upcoming features in the Image Customizer tool.
All the existing shell package flat function have been rewritten to use the shell.ExecBuilder type. Though, some of the functions were removed in favor of using shell.ExecBuilder directly.
In addition, sub-process executions that capture stdout/stderr, can now also log the stdout/stderr lines. The behavior of shell.Execute has been changed to log stdout to TRACE and stderr to WARN.
Also, the shell.ExecBuilder API now makes it possible to set the log level that the stdout and stderr lines are logged to without duplicating the lines in TRACE.
Merge Checklist
All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)
- [x] The toolchain has been rebuilt successfully (or no changes were made to it)
- [x] The toolchain/worker package manifests are up-to-date
- [x] Any updated packages successfully build (or no packages were changed)
- [x] Packages depending on static components modified in this PR (Golang,
*-staticsubpackages, etc.) have had theirReleasetag incremented. - [x] Package tests (%check section) have been verified with RUN_CHECK=y for existing SPEC files, or added to new SPEC files
- [x] All package sources are available
- [x] cgmanifest files are up-to-date and sorted (
./cgmanifest.json,./toolkit/scripts/toolchain/cgmanifest.json,.github/workflows/cgmanifest.json) - [x] LICENSE-MAP files are up-to-date (
./SPECS/LICENSES-AND-NOTICES/data/licenses.json,./SPECS/LICENSES-AND-NOTICES/LICENSES-MAP.md,./SPECS/LICENSES-AND-NOTICES/LICENSE-EXCEPTIONS.PHOTON) - [x] All source files have up-to-date hashes in the
*.signatures.jsonfiles - [x]
sudo make go-tidy-allandsudo make go-test-coveragepass - [x] Documentation has been updated to match any changes to the build system
- [x] If you are adding/removing a .spec file that has multiple-versions supported, please add @microsoft/cbl-mariner-multi-package-reviewers team as reviewer (Eg. golang has 2 versions 1.18, 1.21+)
- [ ] Ready to merge
Does this affect the toolchain?
NO
Test Methodology
- Manually ran image customizer tool.