PSMDB-2150 Partially clean up psmdb-builder.sh#1993
Open
ktrushin wants to merge 7 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors and partially cleans up percona-packaging/scripts/psmdb_builder.sh to make failures consistent (via a shared abort helper), improve environment setup (path_affix / set_gopath), and simplify source/tool fetching and packaging steps.
Changes:
- Introduces
abort,path_affix, andset_gopathhelpers and replaces multiple ad-hocexit 1paths with consistent error handling. - Switches repository and mongo-tools fetches to shallow
git clonewith explicit branches/tags and submodule recursion. - Reworks source artifact retrieval into clearer helpers (
get_source_tarball,get_deb_sources,get_source_rpm_package) and adds a Bazel pre-run to avoid.bazelrc.bazeliskdirty-tree issues during source package builds.
Comments suppressed due to low confidence (1)
percona-packaging/scripts/psmdb_builder.sh:577
- In
build_rpm,$WORKDIRand$SRC_RPMare used unquoted. If the build directory or filename ever contains whitespace or glob characters,cd/cpcan fail or behave unexpectedly. Quoting these variables makes the script more robust.
SRC_RPM="$(get_source_rpm_package)"
cd $WORKDIR
rm -fr rpmbuild
mkdir -vp rpmbuild/{SOURCES,SPECS,BUILD,SRPMS,RPMS}
cp $SRC_RPM rpmbuild/SRPMS/
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The root privileges are only required for installing dependencies. All other operations, including generating source and binary packages, can be done by a regular user. However, the script, while conducting those operations, assumed it was run by `root`.
The patch: - prevents adding duplicates to `PATH`; - adds the Bazel installation directory to `PATH` only once rather than in multiple times; - removes the `GOBINPATH` variable that is not recognized by Go; - exports `GOROOT` only once rather multiple times; - adds `$GOROOT/bin` to `PATH` only once rather then in mulitiple times; - synchronizes setting `GOPATH` with adding `$GOPATH/bin` to `PATH`.
Reasons to remove: - it is not used in Jenkins pipelines anymore; - its functionality is covered by the _mandatory_ options `--psm_ver` and `--mongo_tools_tag` anyway; - the option was used in particular to use mongo tools tag equal to the PSMDB version but the `mongo_tools` repository doesn't have tags of such a form anymore; so that `--jenkins_mode` would not work anyway.
Avoid cloning the full Git history because we don't use it anyway. Notes: - the `MONGO_TOOLS_TAG` variable is safe to use as the value of `--branch` option because `--mongo_tools_tag` is a mandatory script option - the `BRANCH` variable is safe to use as the value of `--branch` option because it has the default value "master"
…the source archive
64ab15c to
ec1ef51
Compare
Author
|
Note. It can be easier to review the PR one commit at a time rather than the entire change at once. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.