这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: auto-setting lock attribute on deb_index #63

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

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions apt/private/resolve.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,33 @@ echo ''
echo 'Writing lockfile to {workspace_relative_path}'
cp $lock {workspace_relative_path}

# Detect which file we wish the user to edit
if [ -e $BUILD_WORKSPACE_DIRECTORY/WORKSPACE ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we should also support MODULE.bazel here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, will file a follow-up

wksp_file="WORKSPACE"
elif [ -e $BUILD_WORKSPACE_DIRECTORY/WORKSPACE.bazel ]; then
wksp_file="WORKSPACE.bazel"
else
echo>&2 "Error: neither WORKSPACE nor WORKSPACE.bazel file was found"
exit 1
fi

# Detect a vendored buildozer binary in canonical location (tools/buildozer)
if [ -e $BUILD_WORKSPACE_DIRECTORY/tools/buildozer ]; then
buildozer="tools/buildozer"
else
# Assume it's on the $PATH
buildozer="buildozer"
fi

if [[ "${{2:-}}" == "--autofix" ]]; then
echo ''
buildozer 'set lock "{label}"' WORKSPACE.bazel:{name}
${{buildozer}} 'set lock \"{label}\"' ${{wksp_file}}:{name}
else
echo ''
echo 'Run the following command to add the lockfile or pass --autofix flag to do it automatically.'
echo ''
echo ' buildozer 'set lock "{label}"' WORKSPACE.bazel:{name}'
echo ''
cat <<EOF
Run the following command to add the lockfile or pass --autofix flag to do it automatically.

${{buildozer}} 'set lock \"{label}\"' ${{wksp_file}}:{name}
EOF
fi
"""

Expand Down Expand Up @@ -107,7 +125,10 @@ def _deb_resolve_impl(rctx):
rctx.file(
"copy.sh",
_COPY_SH.format(
name = rctx.name.removesuffix("_resolution"),
# TODO: don't assume the canonical -> apparent repo mapping character, as it might change
# https://bazelbuild.slack.com/archives/C014RARENH0/p1719237766005439
# https://github.com/bazelbuild/bazel/issues/22865
name = rctx.name.removesuffix("_resolution").split("~")[-1],
label = locklabel,
workspace_relative_path = (("%s/" % locklabel.package) if locklabel.package else "") + locklabel.name,
),
Expand Down
2 changes: 1 addition & 1 deletion e2e/smoke/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ load("@rules_distroless//apt:index.bzl", "deb_index")
# bazel run @bullseye//:lock
deb_index(
name = "bullseye",
lock = "//:bullseye.lock.json",
lock = "@@//:bullseye.lock.json",
manifest = "//:bullseye.yaml",
)

Expand Down
Loading