diff --git a/base/cvd/BUILD.e2fsprogs.bazel b/base/cvd/BUILD.e2fsprogs.bazel index 8cd665c7e47..16897b68143 100644 --- a/base/cvd/BUILD.e2fsprogs.bazel +++ b/base/cvd/BUILD.e2fsprogs.bazel @@ -5,6 +5,23 @@ package( ], ) +cc_binary( + name = "blkid", + srcs = [ + "misc/blkid.c", + ], + includes = [ + "lib", + ], + deps = [ + "@//build_external/e2fsprogs:e2fsprogs_config", + "@//build_external/e2fsprogs:libext2fs_generated", + ":e2fsprogs_version", + ":libext2fs", + ":libext2_blkid", + ], +) + cc_binary( name = "e2fsdroid", srcs = [ diff --git a/base/cvd/cuttlefish/common/libs/utils/BUILD.bazel b/base/cvd/cuttlefish/common/libs/utils/BUILD.bazel index 076ff5208bf..d71927e5304 100644 --- a/base/cvd/cuttlefish/common/libs/utils/BUILD.bazel +++ b/base/cvd/cuttlefish/common/libs/utils/BUILD.bazel @@ -29,6 +29,7 @@ cc_library( copts = COPTS, strip_include_prefix = "//cuttlefish", deps = [ + "//cuttlefish/host/libs/config:known_paths", "//cuttlefish/common/libs/utils:result", "//cuttlefish/common/libs/utils:subprocess", "//libbase", diff --git a/base/cvd/cuttlefish/common/libs/utils/archive.cpp b/base/cvd/cuttlefish/common/libs/utils/archive.cpp index a0ecb5d3683..b55401568b6 100644 --- a/base/cvd/cuttlefish/common/libs/utils/archive.cpp +++ b/base/cvd/cuttlefish/common/libs/utils/archive.cpp @@ -28,6 +28,8 @@ #include "common/libs/utils/result.h" #include "common/libs/utils/subprocess.h" +#include "host/libs/config/known_paths.h" + namespace cuttlefish { namespace { @@ -57,7 +59,7 @@ Result> ExtractHelper( Result> ExtractFiles( const std::string& archive, const std::vector& to_extract, const std::string& target_directory) { - Command bsdtar_cmd = Command("/usr/bin/bsdtar") + Command bsdtar_cmd = Command(BsdtarBinary()) .AddParameter("-x") .AddParameter("-v") .AddParameter("-C") @@ -129,7 +131,7 @@ Result> ExtractArchiveContents( std::string ExtractArchiveToMemory(const std::string& archive_filepath, const std::string& archive_member) { - Command bsdtar_cmd("/usr/bin/bsdtar"); + Command bsdtar_cmd(BsdtarBinary()); bsdtar_cmd.AddParameter("-xf"); bsdtar_cmd.AddParameter(archive_filepath); bsdtar_cmd.AddParameter("-O"); @@ -146,7 +148,7 @@ std::string ExtractArchiveToMemory(const std::string& archive_filepath, } std::vector ArchiveContents(const std::string& archive) { - Command bsdtar_cmd("/usr/bin/bsdtar"); + Command bsdtar_cmd(BsdtarBinary()); bsdtar_cmd.AddParameter("-tf"); bsdtar_cmd.AddParameter(archive); std::string bsdtar_input, bsdtar_output; diff --git a/base/cvd/cuttlefish/host/libs/config/BUILD.bazel b/base/cvd/cuttlefish/host/libs/config/BUILD.bazel index ab27f894041..6bf4bbe4696 100644 --- a/base/cvd/cuttlefish/host/libs/config/BUILD.bazel +++ b/base/cvd/cuttlefish/host/libs/config/BUILD.bazel @@ -209,6 +209,7 @@ cc_library( "//cuttlefish/host/libs/config:config_utils", "//cuttlefish/host/libs/config:cuttlefish_config", "//cuttlefish/host/libs/config:esp", + "//cuttlefish/host/libs/config:known_paths", "//cuttlefish/host/libs/config:mbr", "//cuttlefish/host/libs/config:openwrt_args", "//libbase", diff --git a/base/cvd/cuttlefish/host/libs/config/data_image.cpp b/base/cvd/cuttlefish/host/libs/config/data_image.cpp index bbcec5bfc3e..a2f9ef48f6b 100644 --- a/base/cvd/cuttlefish/host/libs/config/data_image.cpp +++ b/base/cvd/cuttlefish/host/libs/config/data_image.cpp @@ -37,6 +37,7 @@ #include "cuttlefish/host/libs/config/config_utils.h" #include "cuttlefish/host/libs/config/cuttlefish_config.h" #include "cuttlefish/host/libs/config/esp.h" +#include "cuttlefish/host/libs/config/known_paths.h" #include "cuttlefish/host/libs/config/mbr.h" #include "cuttlefish/host/libs/config/openwrt_args.h" @@ -102,7 +103,7 @@ Result ResizeImage(const std::string& data_image, int data_image_mb, } std::string GetFsType(const std::string& path) { - Command command("/usr/sbin/blkid"); + Command command(BlkidBinary()); command.AddParameter(path); std::string blkid_out; @@ -179,11 +180,10 @@ Result CreateBlankImage(const std::string& image, int num_mb, } if (image_fmt == "ext4") { - CF_EXPECT(Execute({"/sbin/mkfs.ext4", image}) == 0); + CF_EXPECT(Execute({Mke2fsBinary(), image}) == 0); } else if (image_fmt == "f2fs") { - auto make_f2fs_path = HostBinaryPath("make_f2fs"); CF_EXPECT( - Execute({make_f2fs_path, "-l", "data", image, "-C", "utf8", "-O", + Execute({Makef2fsBinary(), "-l", "data", image, "-C", "utf8", "-O", "compression,extra_attr,project_quota,casefold", "-g", "android", "-b", F2FS_BLOCKSIZE, "-w", F2FS_BLOCKSIZE}) == 0); } else if (image_fmt == "sdcard") { diff --git a/base/cvd/cuttlefish/host/libs/config/known_paths.cpp b/base/cvd/cuttlefish/host/libs/config/known_paths.cpp index 367d9f10bac..a5f9c312b10 100644 --- a/base/cvd/cuttlefish/host/libs/config/known_paths.cpp +++ b/base/cvd/cuttlefish/host/libs/config/known_paths.cpp @@ -30,6 +30,10 @@ std::string AutomotiveProxyBinary() { std::string AvbToolBinary() { return HostBinaryPath("avbtool.py"); } +std::string BlkidBinary() { return HostBinaryPath("blkid"); } + +std::string BsdtarBinary() { return HostBinaryPath("bsdtar"); } + std::string CasimirBinary() { return HostBinaryPath("casimir"); } std::string CasimirControlServerBinary() { @@ -93,12 +97,16 @@ std::string KernelLogMonitorBinary() { std::string LogcatReceiverBinary() { return HostBinaryPath("logcat_receiver"); } +std::string Makef2fsBinary() { return HostBinaryPath("make_f2fs"); } + std::string McopyBinary() { return HostBinaryPath("mcopy"); } std::string MetricsBinary() { return HostBinaryPath("metrics"); } std::string MkbootimgBinary() { return HostBinaryPath("mkbootimg.py"); } +std::string Mke2fsBinary() { return HostBinaryPath("mke2fs"); } + std::string MkfsFat() { return HostBinaryPath("mkfs.fat"); } std::string MkuserimgMke2fsBinary() { diff --git a/base/cvd/cuttlefish/host/libs/config/known_paths.h b/base/cvd/cuttlefish/host/libs/config/known_paths.h index 9a145ff8c14..b28e5db45a4 100644 --- a/base/cvd/cuttlefish/host/libs/config/known_paths.h +++ b/base/cvd/cuttlefish/host/libs/config/known_paths.h @@ -22,6 +22,8 @@ namespace cuttlefish { std::string AdbConnectorBinary(); std::string AutomotiveProxyBinary(); std::string AvbToolBinary(); +std::string BlkidBinary(); +std::string BsdtarBinary(); std::string CasimirBinary(); std::string CasimirControlServerBinary(); std::string ConsoleForwarderBinary(); @@ -39,9 +41,11 @@ std::string EchoServerBinary(); std::string GnssGrpcProxyBinary(); std::string KernelLogMonitorBinary(); std::string LogcatReceiverBinary(); +std::string Makef2fsBinary(); std::string McopyBinary(); std::string MetricsBinary(); std::string MkbootimgBinary(); +std::string Mke2fsBinary(); std::string MkfsFat(); std::string MkuserimgMke2fsBinary(); std::string MmdBinary(); diff --git a/base/cvd/cuttlefish/package/BUILD.bazel b/base/cvd/cuttlefish/package/BUILD.bazel index eb148d79481..c81f3833bbe 100644 --- a/base/cvd/cuttlefish/package/BUILD.bazel +++ b/base/cvd/cuttlefish/package/BUILD.bazel @@ -10,6 +10,8 @@ package_files( "cuttlefish-common/bin/allocd_client": "//cuttlefish/host/libs/allocd:allocd_client", "cuttlefish-common/bin/assemble_cvd": "//cuttlefish/host/commands/assemble_cvd", "cuttlefish-common/bin/avbtool.py": "@avb//:avbtool.py", + "cuttlefish-common/bin/blkid": "@e2fsprogs//:blkid", + "cuttlefish-common/bin/bsdtar": "@libarchive//tar:bsdtar", "cuttlefish-common/bin/casimir_control_server": "//cuttlefish/host/commands/casimir_control_server", "cuttlefish-common/bin/cf_vhost_user_input": "//cuttlefish/host/commands/vhost_user_input:cf_vhost_user_input", "cuttlefish-common/bin/console_forwarder": "//cuttlefish/host/commands/console_forwarder", diff --git a/base/debian/control b/base/debian/control index 9c64ea4e24b..a1de15c61cb 100644 --- a/base/debian/control +++ b/base/debian/control @@ -44,7 +44,6 @@ Depends: adduser, grub-efi-ia32-bin [!arm64], iproute2, iptables, - libarchive-tools | bsdtar, libcurl4, libdrm2, libfdt1,