Skip to content
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

Store the container annotation in the "containers" directory #1626

Merged
merged 1 commit into from
Oct 14, 2024
Merged
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
8 changes: 8 additions & 0 deletions osc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ def __init__(self, filename, apiurl, buildtype='spec', localpkgs=None, binarytyp
else:
self.preinstallimage = None

self.containerannotation = root.findtext("containerannotation")

def has_dep(self, name):
for i in self.deps:
if i.name == name:
Expand Down Expand Up @@ -1320,6 +1322,12 @@ def __str__(self):
print("Using prefered package: " + path + "/" + filename)
os.unlink(tffn)

if bi.containerannotation:
if not os.path.exists("containers"):
os.makedirs("containers")
Comment on lines +1326 to +1327
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace with os.makedirs("containers", exist_ok=True).
Your code is longer and is prone to race conditions.

with open("containers/annotation", "wb") as f:
f.write(bi.containerannotation.encode())
Comment on lines +1328 to +1329
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't be better to avoid encoding to bytes?

            with open("containers/annotation", "w", encoding="utf-8") as f:
                f.write(bi.containerannotation)


if prefer_pkgs:
localpkgdir = "repos/_local/"
os.mkdir(localpkgdir)
Expand Down
Loading