Skip to content

Commit

Permalink
Merge branch 'eero/tool-comments' into 'master'
Browse files Browse the repository at this point in the history
fix: Update comments around custom ICOS tools

 

See merge request dfinity-lab/public/ic!19986
  • Loading branch information
Bownairo committed Jun 28, 2024
2 parents 41eef14 + e93b8b8 commit ad5629c
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 18 deletions.
6 changes: 3 additions & 3 deletions ic-os/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def icos_build(
testonly = malicious,
srcs = ["partition-root-unsigned.tzst"],
outs = ["partition-root.tzst", "partition-root-hash"],
cmd = "$(location //toolchains/sysimage:verity_sign.py) -i $< -o $(location :partition-root.tzst) -r $(location partition-root-hash) -d $(location //rs/ic_os/dflate)",
cmd = "$(location //toolchains/sysimage:verity_sign.py) -i $< -o $(location :partition-root.tzst) -r $(location partition-root-hash) --dflate $(location //rs/ic_os/dflate)",
executable = False,
tools = ["//toolchains/sysimage:verity_sign.py", "//rs/ic_os/dflate"],
tags = ["manual"],
Expand All @@ -224,7 +224,7 @@ def icos_build(
testonly = malicious,
srcs = ["partition-root-test-unsigned.tzst"],
outs = ["partition-root-test.tzst", "partition-root-test-hash"],
cmd = "$(location //toolchains/sysimage:verity_sign.py) -i $< -o $(location :partition-root-test.tzst) -r $(location partition-root-test-hash) -d $(location //rs/ic_os/dflate)",
cmd = "$(location //toolchains/sysimage:verity_sign.py) -i $< -o $(location :partition-root-test.tzst) -r $(location partition-root-test-hash) --dflate $(location //rs/ic_os/dflate)",
tools = ["//toolchains/sysimage:verity_sign.py", "//rs/ic_os/dflate"],
tags = ["manual"],
)
Expand Down Expand Up @@ -784,7 +784,7 @@ EOF
name = "partition-root-sign",
srcs = ["partition-root-unsigned.tzst"],
outs = ["partition-root.tzst", "partition-root-hash"],
cmd = "$(location //toolchains/sysimage:verity_sign.py) -i $< -o $(location :partition-root.tzst) -r $(location partition-root-hash) -d $(location //rs/ic_os/dflate)",
cmd = "$(location //toolchains/sysimage:verity_sign.py) -i $< -o $(location :partition-root.tzst) -r $(location partition-root-hash) --dflate $(location //rs/ic_os/dflate)",
executable = False,
tools = ["//toolchains/sysimage:verity_sign.py", "//rs/ic_os/dflate"],
tags = ["manual"],
Expand Down
3 changes: 2 additions & 1 deletion rs/ic_os/inject_files/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct Cli {
file_contexts: Option<PathBuf>,
#[arg(long)]
prefix: Option<PathBuf>,
#[arg(short)]
#[arg(long)]
dflate: PathBuf,
extra_files: Vec<String>,
}
Expand Down Expand Up @@ -89,6 +89,7 @@ async fn main() -> Result<()> {
target.close().await?;

// TODO: Quick hack to unpack and repack file
// We use our tool, dflate, to quickly create a sparse, deterministic, tar.
// If dflate is ever misbehaving, it can be replaced with:
// tar cf <output> --sort=name --owner=root:0 --group=root:0 --mtime="UTC 1970-01-01 00:00:00" --sparse --hole-detection=raw -C <context_path> <item>
let temp_tar = temp_dir.path().join("partition.tar");
Expand Down
3 changes: 2 additions & 1 deletion toolchains/sysimage/build_disk_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def main():
nargs="*",
help="Partitions to write. These must match the CSV partition table entries.",
)
parser.add_argument("-d", "--dflate", help="Path to dflate", type=str)
parser.add_argument("--dflate", help="Path to our dflate tool", type=str)

args = parser.parse_args(sys.argv[1:])

Expand Down Expand Up @@ -187,6 +187,7 @@ def main():
if args.expanded_size:
subprocess.run(["truncate", "--size", args.expanded_size, disk_image], check=True)

# We use our tool, dflate, to quickly create a sparse, deterministic, tar.
# If dflate is ever misbehaving, it can be replaced with:
# tar cf <output> --sort=name --owner=root:0 --group=root:0 --mtime="UTC 1970-01-01 00:00:00" --sparse --hole-detection=raw -C <context_path> <item>
subprocess.run(
Expand Down
3 changes: 2 additions & 1 deletion toolchains/sysimage/build_ext4_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def make_argparser():
default=[],
help="Directories to be cleared from the tree; expects a list of full paths",
)
parser.add_argument("-d", "--dflate", help="Path to dflate tool", type=str, required=True)
parser.add_argument("--dflate", help="Path to our dflate tool", type=str, required=True)
parser.add_argument("--diroid", help="Path to our diroid tool", type=str, required=True)
return parser

Expand Down Expand Up @@ -220,6 +220,7 @@ def main():

subprocess.run(['sync'], check=True)

# We use our tool, dflate, to quickly create a sparse, deterministic, tar.
# If dflate is ever misbehaving, it can be replaced with:
# tar cf <output> --sort=name --owner=root:0 --group=root:0 --mtime="UTC 1970-01-01 00:00:00" --sparse --hole-detection=raw -C <context_path> <item>
temp_tar = os.path.join(tmpdir, "partition.tar")
Expand Down
3 changes: 2 additions & 1 deletion toolchains/sysimage/build_fat32_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def main():
nargs="*",
help="Extra files to install; expects list of sourcefile:targetfile:mode",
)
parser.add_argument("-d", "--dflate", help="Path to dflate", type=str)
parser.add_argument("--dflate", help="Path to our dflate tool", type=str)

args = parser.parse_args(sys.argv[1:])

Expand Down Expand Up @@ -142,6 +142,7 @@ def path_transform(path, limit_prefix=limit_prefix):

install_extra_files(image_file, extra_files, path_transform)

# We use our tool, dflate, to quickly create a sparse, deterministic, tar.
# If dflate is ever misbehaving, it can be replaced with:
# tar cf <output> --sort=name --owner=root:0 --group=root:0 --mtime="UTC 1970-01-01 00:00:00" --sparse --hole-detection=raw -C <context_path> <item>
temp_tar = os.path.join(tmpdir, "partition.tar")
Expand Down
3 changes: 2 additions & 1 deletion toolchains/sysimage/build_lvm_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main():
nargs="*",
help="Partitions to write. These must match the CSV volume table entries.",
)
parser.add_argument("-d", "--dflate", help="Path to dflate", type=str)
parser.add_argument("--dflate", help="Path to our dflate tool", type=str)

args = parser.parse_args(sys.argv[1:])

Expand Down Expand Up @@ -78,6 +78,7 @@ def main():
else:
print("No partition file for '%s' found, leaving empty" % name)

# We use our tool, dflate, to quickly create a sparse, deterministic, tar.
# If dflate is ever misbehaving, it can be replaced with:
# tar cf <output> --sort=name --owner=root:0 --group=root:0 --mtime="UTC 1970-01-01 00:00:00" --sparse --hole-detection=raw -C <context_path> <item>
temp_tar = os.path.join(tmpdir, "partition.tar")
Expand Down
3 changes: 2 additions & 1 deletion toolchains/sysimage/build_upgrade_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def main():
parser.add_argument("-b", "--boot", help="The (tzst) boot filesystem image", type=str)
parser.add_argument("-r", "--root", help="The (tzst) root filesystem image", type=str)
parser.add_argument("-v", "--versionfile", help="The version file in the upgrade image", type=str)
parser.add_argument("-d", "--dflate", help="Path to dflate", type=str)
parser.add_argument("--dflate", help="Path to our dflate tool", type=str)

args = parser.parse_args(sys.argv[1:])

Expand All @@ -41,6 +41,7 @@ def main():
version_path = os.path.join(tmpdir, "VERSION.TXT")
shutil.copy(version_file, version_path, follow_symlinks=True)

# We use our tool, dflate, to quickly create a sparse, deterministic, tar.
# If dflate is ever misbehaving, it can be replaced with:
# tar cf <output> --sort=name --owner=root:0 --group=root:0 --mtime="UTC 1970-01-01 00:00:00" --sparse --hole-detection=raw -C <context_path> <item>
subprocess.run(
Expand Down
3 changes: 2 additions & 1 deletion toolchains/sysimage/build_vfat_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def main():
nargs="*",
help="Extra files to install; expects list of sourcefile:targetfile:mode",
)
parser.add_argument("-d", "--dflate", help="Path to dflate", type=str)
parser.add_argument("--dflate", help="Path to our dflate tool", type=str)

args = parser.parse_args(sys.argv[1:])

Expand Down Expand Up @@ -138,6 +138,7 @@ def path_transform(path, limit_prefix=limit_prefix):

install_extra_files(image_file, extra_files, path_transform)

# We use our tool, dflate, to quickly create a sparse, deterministic, tar.
# If dflate is ever misbehaving, it can be replaced with:
# tar cf <output> --sort=name --owner=root:0 --group=root:0 --mtime="UTC 1970-01-01 00:00:00" --sparse --hole-detection=raw -C <context_path> <item>
temp_tar = os.path.join(tmpdir, "partition.tar")
Expand Down
14 changes: 7 additions & 7 deletions toolchains/sysimage/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _vfat_image_impl(ctx):
ctx.attr.partition_size,
"-p",
ctx.attr.subdir,
"-d",
"--dflate",
dflate.path,
]

Expand Down Expand Up @@ -226,7 +226,7 @@ def _fat32_image_impl(ctx):
ctx.attr.partition_size,
"-p",
ctx.attr.subdir,
"-d",
"--dflate",
dflate.path,
]

Expand Down Expand Up @@ -297,7 +297,7 @@ def _ext4_image_impl(ctx):
ctx.attr.subdir,
"--diroid",
diroid.path,
"-d",
"--dflate",
dflate.path,
]
if len(ctx.files.file_contexts) > 0:
Expand Down Expand Up @@ -362,7 +362,7 @@ def _inject_files_impl(ctx):
ctx.files.base[0].path,
"--output",
out.path,
"-d",
"--dflate",
dflate.path,
]

Expand Down Expand Up @@ -429,7 +429,7 @@ def _disk_image_impl(ctx):
for p in partitions:
partition_files.append(p.path)

args = ["-p", in_layout.path, "-o", out.path, "-d", dflate.path]
args = ["-p", in_layout.path, "-o", out.path, "--dflate", dflate.path]

if expanded_size:
args += ["-s", expanded_size]
Expand Down Expand Up @@ -483,7 +483,7 @@ def _lvm_image_impl(ctx):
for p in partitions:
partition_files.append(p.path)

args = ["-v", in_layout.path, "-n", vg_name, "-u", vg_uuid, "-p", pv_uuid, "-o", out.path, "-d", dflate.path]
args = ["-v", in_layout.path, "-n", vg_name, "-u", vg_uuid, "-p", pv_uuid, "-o", out.path, "--dflate", dflate.path]

args += partition_files

Expand Down Expand Up @@ -533,7 +533,7 @@ def _upgrade_image_impl(ctx):
ctx.actions.run_shell(
inputs = [in_boot_partition, in_root_partition, in_version_file],
outputs = [out],
command = "python3 %s -b %s -r %s -v %s -o %s -d %s" % (
command = "python3 %s -b %s -r %s -v %s -o %s --dflate %s" % (
tool_file.path,
in_boot_partition.path,
in_root_partition.path,
Expand Down
3 changes: 2 additions & 1 deletion toolchains/sysimage/verity_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def main():
type=int,
default=10 * 1024 * 1024 * 1024 - 128 * 1024 * 1024,
)
parser.add_argument("-d", "--dflate", help="Path to dflate", type=str)
parser.add_argument("--dflate", help="Path to our dflate tool", type=str)

args = parser.parse_args(sys.argv[1:])

Expand Down Expand Up @@ -88,6 +88,7 @@ def main():
with open(args.root_hash, "w") as f:
f.write(root_hash + "\n")

# We use our tool, dflate, to quickly create a sparse, deterministic, tar.
# If dflate is ever misbehaving, it can be replaced with:
# tar cf <output> --sort=name --owner=root:0 --group=root:0 --mtime="UTC 1970-01-01 00:00:00" --sparse --hole-detection=raw -C <context_path> <item>
temp_tar = os.path.join(tmpdir, "partition.tar")
Expand Down

0 comments on commit ad5629c

Please sign in to comment.