Skip to content

Commit

Permalink
Create files with explicit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
septatrix committed Mar 29, 2024
1 parent 1567bee commit 9d6d228
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions mkosi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3262,7 +3262,8 @@ def make_disk(

def make_oci(context: Context, root_layer: Path, dst: Path) -> None:
ca_store = dst / "blobs" / "sha256"
ca_store.mkdir(parents=True)
with umask(~0o755):
ca_store.mkdir(parents=True)

layer_diff_digest = hash_file(root_layer)
maybe_compress(
Expand Down Expand Up @@ -3307,7 +3308,8 @@ def make_oci(context: Context, root_layer: Path, dst: Path) -> None:
}
oci_config_blob = json.dumps(oci_config)
oci_config_digest = hashlib.sha256(oci_config_blob.encode()).hexdigest()
(ca_store / oci_config_digest).write_text(oci_config_blob)
with umask(~0o644):
(ca_store / oci_config_digest).write_text(oci_config_blob)

layer_suffix = context.config.compress_output.oci_media_type_suffix()
oci_manifest = {
Expand All @@ -3334,26 +3336,26 @@ def make_oci(context: Context, root_layer: Path, dst: Path) -> None:
}
oci_manifest_blob = json.dumps(oci_manifest)
oci_manifest_digest = hashlib.sha256(oci_manifest_blob.encode()).hexdigest()
(ca_store / oci_manifest_digest).write_text(oci_manifest_blob)
with umask(~0o644):
(ca_store / oci_manifest_digest).write_text(oci_manifest_blob)

with (dst / "index.json").open("w") as f:
json.dump(
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": f"sha256:{oci_manifest_digest}",
"size": (ca_store / oci_manifest_digest).stat().st_size,
}
],
},
f,
(dst / "index.json").write_text(
json.dumps(
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": f"sha256:{oci_manifest_digest}",
"size": (ca_store / oci_manifest_digest).stat().st_size,
}
],
}
)
)

with (dst / "oci-layout").open("w") as f:
json.dump({"imageLayoutVersion": "1.0.0"}, f)
(dst / "oci-layout").write_text(json.dumps({"imageLayoutVersion": "1.0.0"}))


def make_esp(context: Context, uki: Path) -> list[Partition]:
Expand Down

0 comments on commit 9d6d228

Please sign in to comment.