payload_generator: Remove unused attributes
Some attributes are not used by the client. Removed all instances of
of "ignored" and option ttributes from delta generation. Removed
all instances of ImageInfo and moved target and source version
to paygen_payload.
BUG=b:163048638
TEST=FEATURES=test emerge-hatch update_engine
TEST=FEATURES=test emerge update_payload
TEST=./run_pytest lib/paygen/paygen_payload_lib_unittest.py
Change-Id: I9102d37fcf054f2cbeb79e54113925a684de1cfb
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2388163
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Tested-by: Vyshu Khota <vyshu@google.com>
Commit-Queue: Vyshu Khota <vyshu@google.com>
diff --git a/payload_consumer/delta_performer_integration_test.cc b/payload_consumer/delta_performer_integration_test.cc
index af6682a..1f7a119 100644
--- a/payload_consumer/delta_performer_integration_test.cc
+++ b/payload_consumer/delta_performer_integration_test.cc
@@ -340,26 +340,6 @@
state->image_size = utils::FileSize(state->a_img);
- // Create ImageInfo A & B
- ImageInfo old_image_info;
- ImageInfo new_image_info;
-
- if (!full_rootfs) {
- old_image_info.set_channel("src-channel");
- old_image_info.set_board("src-board");
- old_image_info.set_version("src-version");
- old_image_info.set_key("src-key");
- old_image_info.set_build_channel("src-build-channel");
- old_image_info.set_build_version("src-build-version");
- }
-
- new_image_info.set_channel("test-channel");
- new_image_info.set_board("test-board");
- new_image_info.set_version("test-version");
- new_image_info.set_key("test-key");
- new_image_info.set_build_channel("test-build-channel");
- new_image_info.set_build_version("test-build-version");
-
// Make some changes to the A image.
{
string a_mnt;
@@ -513,7 +493,6 @@
payload_config.source.partitions.front().path = state->a_img;
if (!full_kernel)
payload_config.source.partitions.back().path = state->old_kernel;
- payload_config.source.image_info = old_image_info;
EXPECT_TRUE(payload_config.source.LoadImageSize());
for (PartitionConfig& part : payload_config.source.partitions)
EXPECT_TRUE(part.OpenFilesystem());
@@ -526,7 +505,6 @@
payload_config.target.partitions.back().path = state->b_img;
payload_config.target.partitions.emplace_back(kPartitionNameKernel);
payload_config.target.partitions.back().path = state->new_kernel;
- payload_config.target.image_info = new_image_info;
EXPECT_TRUE(payload_config.target.LoadImageSize());
for (PartitionConfig& part : payload_config.target.partitions)
EXPECT_TRUE(part.OpenFilesystem());
@@ -664,22 +642,6 @@
EXPECT_FALSE(rootfs_part.old_partition_info().hash().empty());
}
EXPECT_FALSE(rootfs_part.new_partition_info().hash().empty());
-
- EXPECT_EQ(manifest.new_image_info().channel(), "test-channel");
- EXPECT_EQ(manifest.new_image_info().board(), "test-board");
- EXPECT_EQ(manifest.new_image_info().version(), "test-version");
- EXPECT_EQ(manifest.new_image_info().key(), "test-key");
- EXPECT_EQ(manifest.new_image_info().build_channel(), "test-build-channel");
- EXPECT_EQ(manifest.new_image_info().build_version(), "test-build-version");
-
- if (!full_rootfs) {
- EXPECT_EQ(manifest.old_image_info().channel(), "src-channel");
- EXPECT_EQ(manifest.old_image_info().board(), "src-board");
- EXPECT_EQ(manifest.old_image_info().version(), "src-version");
- EXPECT_EQ(manifest.old_image_info().key(), "src-key");
- EXPECT_EQ(manifest.old_image_info().build_channel(), "src-build-channel");
- EXPECT_EQ(manifest.old_image_info().build_version(), "src-build-version");
- }
}
MockPrefs prefs;
diff --git a/payload_generator/generate_delta_main.cc b/payload_generator/generate_delta_main.cc
index fe0a10b..8809e43 100644
--- a/payload_generator/generate_delta_main.cc
+++ b/payload_generator/generate_delta_main.cc
@@ -74,37 +74,6 @@
}
}
-bool ParseImageInfo(const string& channel,
- const string& board,
- const string& version,
- const string& key,
- const string& build_channel,
- const string& build_version,
- ImageInfo* image_info) {
- // All of these arguments should be present or missing.
- bool empty = channel.empty();
-
- CHECK_EQ(channel.empty(), empty);
- CHECK_EQ(board.empty(), empty);
- CHECK_EQ(version.empty(), empty);
- CHECK_EQ(key.empty(), empty);
-
- if (empty)
- return false;
-
- image_info->set_channel(channel);
- image_info->set_board(board);
- image_info->set_version(version);
- image_info->set_key(key);
-
- image_info->set_build_channel(build_channel.empty() ? channel
- : build_channel);
-
- image_info->set_build_version(build_version.empty() ? version
- : build_version);
-
- return true;
-}
void CalculateHashForSigning(const vector<int>& sizes,
const string& out_hash_file,
@@ -386,51 +355,6 @@
"The maximum timestamp of the OS allowed to apply this "
"payload.");
- DEFINE_string(old_channel,
- "",
- "The channel for the old image. 'dev-channel', 'npo-channel', "
- "etc. Ignored, except during delta generation.");
- DEFINE_string(old_board,
- "",
- "The board for the old image. 'x86-mario', 'lumpy', "
- "etc. Ignored, except during delta generation.");
- DEFINE_string(
- old_version, "", "The build version of the old image. 1.2.3, etc.");
- DEFINE_string(old_key,
- "",
- "The key used to sign the old image. 'premp', 'mp', 'mp-v3',"
- " etc");
- DEFINE_string(old_build_channel,
- "",
- "The channel for the build of the old image. 'dev-channel', "
- "etc, but will never contain special channels such as "
- "'npo-channel'. Ignored, except during delta generation.");
- DEFINE_string(old_build_version,
- "",
- "The version of the build containing the old image.");
-
- DEFINE_string(new_channel,
- "",
- "The channel for the new image. 'dev-channel', 'npo-channel', "
- "etc. Ignored, except during delta generation.");
- DEFINE_string(new_board,
- "",
- "The board for the new image. 'x86-mario', 'lumpy', "
- "etc. Ignored, except during delta generation.");
- DEFINE_string(
- new_version, "", "The build version of the new image. 1.2.3, etc.");
- DEFINE_string(new_key,
- "",
- "The key used to sign the new image. 'premp', 'mp', 'mp-v3',"
- " etc");
- DEFINE_string(new_build_channel,
- "",
- "The channel for the build of the new image. 'dev-channel', "
- "etc, but will never contain special channels such as "
- "'npo-channel'. Ignored, except during delta generation.");
- DEFINE_string(new_build_version,
- "",
- "The version of the build containing the new image.");
DEFINE_string(new_postinstall_config_file,
"",
"A config file specifying postinstall related metadata. "
@@ -600,24 +524,6 @@
CHECK(!FLAGS_out_file.empty());
- // Ignore failures. These are optional arguments.
- ParseImageInfo(FLAGS_new_channel,
- FLAGS_new_board,
- FLAGS_new_version,
- FLAGS_new_key,
- FLAGS_new_build_channel,
- FLAGS_new_build_version,
- &payload_config.target.image_info);
-
- // Ignore failures. These are optional arguments.
- ParseImageInfo(FLAGS_old_channel,
- FLAGS_old_board,
- FLAGS_old_version,
- FLAGS_old_key,
- FLAGS_old_build_channel,
- FLAGS_old_build_version,
- &payload_config.source.image_info);
-
payload_config.rootfs_partition_size = FLAGS_rootfs_partition_size;
if (payload_config.is_delta) {
diff --git a/payload_generator/payload_file.cc b/payload_generator/payload_file.cc
index b55d03c..aa9b4d3 100644
--- a/payload_generator/payload_file.cc
+++ b/payload_generator/payload_file.cc
@@ -64,13 +64,6 @@
TEST_AND_RETURN_FALSE(config.version.Validate());
major_version_ = config.version.major;
manifest_.set_minor_version(config.version.minor);
-
- if (!config.source.ImageInfoIsEmpty())
- *(manifest_.mutable_old_image_info()) = config.source.image_info;
-
- if (!config.target.ImageInfoIsEmpty())
- *(manifest_.mutable_new_image_info()) = config.target.image_info;
-
manifest_.set_block_size(config.block_size);
manifest_.set_max_timestamp(config.max_timestamp);
diff --git a/payload_generator/payload_generation_config.cc b/payload_generator/payload_generation_config.cc
index 7158796..90d9f1b 100644
--- a/payload_generator/payload_generation_config.cc
+++ b/payload_generator/payload_generation_config.cc
@@ -103,7 +103,6 @@
}
bool ImageConfig::ValidateIsEmpty() const {
- TEST_AND_RETURN_FALSE(ImageInfoIsEmpty());
return partitions.empty();
}
@@ -206,13 +205,6 @@
return true;
}
-bool ImageConfig::ImageInfoIsEmpty() const {
- return image_info.board().empty() && image_info.key().empty() &&
- image_info.channel().empty() && image_info.version().empty() &&
- image_info.build_channel().empty() &&
- image_info.build_version().empty();
-}
-
PayloadVersion::PayloadVersion(uint64_t major_version, uint32_t minor_version) {
major = major_version;
minor = minor_version;
@@ -278,9 +270,6 @@
TEST_AND_RETURN_FALSE(part.verity.IsEmpty());
}
- // If new_image_info is present, old_image_info must be present.
- TEST_AND_RETURN_FALSE(source.ImageInfoIsEmpty() ==
- target.ImageInfoIsEmpty());
} else {
// All the "source" image fields must be empty for full payloads.
TEST_AND_RETURN_FALSE(source.ValidateIsEmpty());
diff --git a/payload_generator/payload_generation_config.h b/payload_generator/payload_generation_config.h
index 32f1229..b7b2eb0 100644
--- a/payload_generator/payload_generation_config.h
+++ b/payload_generator/payload_generation_config.h
@@ -143,13 +143,6 @@
// Validate |dynamic_partition_metadata| against |partitions|.
bool ValidateDynamicPartitionMetadata() const;
- // Returns whether the |image_info| field is empty.
- bool ImageInfoIsEmpty() const;
-
- // The ImageInfo message defined in the update_metadata.proto file describes
- // the metadata of the image.
- ImageInfo image_info;
-
// The updated partitions.
std::vector<PartitionConfig> partitions;
diff --git a/payload_generator/payload_properties.cc b/payload_generator/payload_properties.cc
index bc82eb7..bcf4fbd 100644
--- a/payload_generator/payload_properties.cc
+++ b/payload_generator/payload_properties.cc
@@ -47,8 +47,6 @@
// These are needed by the Nebraska and devserver.
const char kPayloadPropertyJsonPayloadSize[] = "size";
const char kPayloadPropertyJsonIsDelta[] = "is_delta";
-const char kPayloadPropertyJsonTargetVersion[] = "target_version";
-const char kPayloadPropertyJsonSourceVersion[] = "source_version";
} // namespace
PayloadProperties::PayloadProperties(const string& payload_path)
@@ -65,10 +63,6 @@
properties.SetInteger(kPayloadPropertyJsonPayloadSize, payload_size_);
properties.SetString(kPayloadPropertyJsonPayloadHash, payload_hash_);
properties.SetBoolean(kPayloadPropertyJsonIsDelta, is_delta_);
- properties.SetString(kPayloadPropertyJsonTargetVersion, target_version_);
- if (is_delta_) {
- properties.SetString(kPayloadPropertyJsonSourceVersion, source_version_);
- }
return base::JSONWriter::Write(properties, json_str);
}
@@ -119,23 +113,11 @@
metadata_signatures_ = base::JoinString(base64_signatures, ":");
}
- is_delta_ = manifest.has_old_image_info() ||
- std::any_of(manifest.partitions().begin(),
+ is_delta_ = std::any_of(manifest.partitions().begin(),
manifest.partitions().end(),
[](const PartitionUpdate& part) {
return part.has_old_partition_info();
});
-
- if (manifest.has_new_image_info()) {
- target_version_ = manifest.new_image_info().version();
- } else {
- target_version_ = "99999.0.0";
- }
-
- // No need to set the source version if it was not a delta payload.
- if (is_delta_ && manifest.has_old_image_info()) {
- source_version_ = manifest.old_image_info().version();
- }
return true;
}
diff --git a/payload_generator/payload_properties.h b/payload_generator/payload_properties.h
index 3b34511..846b181 100644
--- a/payload_generator/payload_properties.h
+++ b/payload_generator/payload_properties.h
@@ -62,9 +62,6 @@
// Whether the payload is a delta (true) or full (false).
bool is_delta_;
- std::string target_version_;
- std::string source_version_;
-
DISALLOW_COPY_AND_ASSIGN(PayloadProperties);
};
diff --git a/payload_generator/payload_properties_unittest.cc b/payload_generator/payload_properties_unittest.cc
index db3902c..a923379 100644
--- a/payload_generator/payload_properties_unittest.cc
+++ b/payload_generator/payload_properties_unittest.cc
@@ -57,8 +57,6 @@
PayloadGenerationConfig config;
config.version.major = kBrilloMajorPayloadVersion;
config.version.minor = kSourceMinorPayloadVersion;
- config.source.image_info.set_version("123.0.0");
- config.target.image_info.set_version("456.7.8");
PayloadFile payload;
EXPECT_TRUE(payload.Init(config));
@@ -114,11 +112,9 @@
"{"
R"("is_delta":true,)"
R"("metadata_signature":"",)"
- R"("metadata_size":187,)"
- R"("sha256_hex":"Rtrj9v3xXhrAi1741HAojtGxAQEOZ7mDyhzskIF4PJc=",)"
- R"("size":233,)"
- R"("source_version":"123.0.0",)"
- R"("target_version":"456.7.8",)"
+ R"("metadata_size":165,)"
+ R"("sha256_hex":"cV7kfZBH3K0B6QJHxxykDh6b6x0WgVOmc63whPLOy7U=",)"
+ R"("size":211,)"
R"("version":2)"
"}";
string json;
@@ -130,10 +126,10 @@
// Validate the hash of file and metadata are within the output.
TEST_F(PayloadPropertiesTest, GetPropertiesAsKeyValueTestHash) {
constexpr char kKeyValueProperties[] =
- "FILE_HASH=Rtrj9v3xXhrAi1741HAojtGxAQEOZ7mDyhzskIF4PJc=\n"
- "FILE_SIZE=233\n"
- "METADATA_HASH=kiXTexy/s2aPttf4+r8KRZWYZ6FYvwhU6rJGcnnI+U0=\n"
- "METADATA_SIZE=187\n";
+ "FILE_HASH=cV7kfZBH3K0B6QJHxxykDh6b6x0WgVOmc63whPLOy7U=\n"
+ "FILE_SIZE=211\n"
+ "METADATA_HASH=aEKYyzJt2E8Gz8fzB+gmekN5mriotZCSq6R+kDfdeV4=\n"
+ "METADATA_SIZE=165\n";
string key_value;
EXPECT_TRUE(PayloadProperties{payload_file.path()}.GetPropertiesAsKeyValue(
&key_value));
diff --git a/scripts/paycheck.py b/scripts/paycheck.py
index f4ccca2..8eb0033 100755
--- a/scripts/paycheck.py
+++ b/scripts/paycheck.py
@@ -92,9 +92,6 @@
check_args.add_argument('-c', '--check', action='store_true', default=False,
help=('force payload integrity check (e.g. before '
'applying)'))
- check_args.add_argument('-D', '--describe', action='store_true',
- default=False,
- help='Print a friendly description of the payload.')
check_args.add_argument('-r', '--report', metavar='FILE',
help="dump payload report (`-' for stdout)")
check_args.add_argument('-t', '--type', dest='assert_type',
@@ -209,9 +206,6 @@
# Initialize payload.
payload.Init()
- if args.describe:
- payload.Describe()
-
# Perform payload integrity checks.
if args.check:
report_file = None
diff --git a/scripts/update_payload/payload.py b/scripts/update_payload/payload.py
index ea5ed30..61423a9 100644
--- a/scripts/update_payload/payload.py
+++ b/scripts/update_payload/payload.py
@@ -226,31 +226,6 @@
self.is_init = True
- def Describe(self):
- """Emits the payload embedded description data to standard output."""
- def _DescribeImageInfo(description, image_info):
- """Display info about the image."""
- def _DisplayIndentedValue(name, value):
- print(' {:<14} {}'.format(name+':', value))
-
- print('%s:' % description)
- _DisplayIndentedValue('Channel', image_info.channel)
- _DisplayIndentedValue('Board', image_info.board)
- _DisplayIndentedValue('Version', image_info.version)
- _DisplayIndentedValue('Key', image_info.key)
-
- if image_info.build_channel != image_info.channel:
- _DisplayIndentedValue('Build channel', image_info.build_channel)
-
- if image_info.build_version != image_info.version:
- _DisplayIndentedValue('Build version', image_info.build_version)
-
- if self.manifest.HasField('old_image_info'):
- _DescribeImageInfo('Old Image', self.manifest.old_image_info)
-
- if self.manifest.HasField('new_image_info'):
- _DescribeImageInfo('New Image', self.manifest.new_image_info)
-
def _AssertInit(self):
"""Raises an exception if the object was not initialized."""
if not self.is_init:
diff --git a/update_metadata.proto b/update_metadata.proto
index 3d136ca..2210817 100644
--- a/update_metadata.proto
+++ b/update_metadata.proto
@@ -139,16 +139,16 @@
//
// All fields will be set, if this message is present.
message ImageInfo {
- optional string board = 1;
- optional string key = 2;
- optional string channel = 3;
- optional string version = 4;
+ optional string board = 1 [deprecated = true];
+ optional string key = 2 [deprecated = true];
+ optional string channel = 3 [deprecated = true];
+ optional string version = 4 [deprecated = true];
// If these values aren't present, they should be assumed to match
// the equivalent value above. They are normally only different for
// special image types such as nplusone images.
- optional string build_channel = 5;
- optional string build_version = 6;
+ optional string build_channel = 5 [deprecated = true];
+ optional string build_version = 6 [deprecated = true];
}
message InstallOperation {
@@ -325,9 +325,9 @@
optional PartitionInfo new_rootfs_info = 9 [deprecated = true];
// old_image_info will only be present for delta images.
- optional ImageInfo old_image_info = 10;
+ optional ImageInfo old_image_info = 10 [deprecated = true];
- optional ImageInfo new_image_info = 11;
+ optional ImageInfo new_image_info = 11 [deprecated = true];
// The minor version, also referred as "delta version", of the payload.
optional uint32 minor_version = 12 [default = 0];