//
// Copyright (C) 2010 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto2";
package chromeos_update_engine;
message Extent {
  optional uint64 start_block = 1;
  optional uint64 num_blocks = 2;
}
message Signatures {
  message Signature {
    optional uint32 version = 1 [deprecated = true];
    optional bytes data = 2;

    optional fixed32 unpadded_signature_size = 3;
  }
  repeated Signature signatures = 1;
}
message PartitionInfo {
  optional uint64 size = 1;
  optional bytes hash = 2;
}
message InstallOperation {
  enum Type {
    REPLACE = 0;     
    REPLACE_BZ = 1;  
    MOVE = 2 [deprecated = true];    
    BSDIFF = 3 [deprecated = true]; 
    SOURCE_COPY = 4;  
    SOURCE_BSDIFF = 5; 
    REPLACE_XZ = 8; 
    ZERO = 6; 
    DISCARD = 7; 
    BROTLI_BSDIFF = 10;
    PUFFDIFF = 9;
    ZUCCHINI = 11;
    LZ4DIFF_BSDIFF = 12;
    LZ4DIFF_PUFFDIFF = 13;
    ZSTD = 14;
  }
  required Type type = 1;
  optional uint64 data_offset = 2;
  optional uint64 data_length = 3;
  repeated Extent src_extents = 4;
  optional uint64 src_length = 5;
  repeated Extent dst_extents = 6;
  optional uint64 dst_length = 7;
  optional bytes data_sha256_hash = 8;
  optional bytes src_sha256_hash = 9;
}
message CowMergeOperation {
  enum Type {
    COW_COPY = 0;    
    COW_XOR = 1;      
    COW_REPLACE = 2;
  }
  optional Type type = 1;
  optional Extent src_extent = 2;
  optional Extent dst_extent = 3;
  optional uint32 src_offset = 4;
}
message PartitionUpdate {
  required string partition_name = 1;
  optional bool run_postinstall = 2;
  optional string postinstall_path = 3;
  optional string filesystem_type = 4;
  repeated Signatures.Signature new_partition_signature = 5;
  optional PartitionInfo old_partition_info = 6;
  optional PartitionInfo new_partition_info = 7;
  repeated InstallOperation operations = 8;
  optional bool postinstall_optional = 9;
  optional Extent hash_tree_data_extent = 10;
  optional Extent hash_tree_extent = 11;
  optional string hash_tree_algorithm = 12;
  optional bytes hash_tree_salt = 13;
  optional Extent fec_data_extent = 14;
  optional Extent fec_extent = 15;
  optional uint32 fec_roots = 16 [default = 2];
  optional string version = 17;
  repeated CowMergeOperation merge_operations = 18;
  optional uint64 estimate_cow_size = 19;
  optional uint64 estimate_op_count_max = 20;
}
message DynamicPartitionGroup {

  required string name = 1;
  optional uint64 size = 2;
  repeated string partition_names = 3;
}
message VABCFeatureSet {
  optional bool threaded = 1;
  optional bool batch_writes = 2;
}
message DynamicPartitionMetadata {
  repeated DynamicPartitionGroup groups = 1;
  optional bool snapshot_enabled = 2;
  optional bool vabc_enabled = 3;
  optional string vabc_compression_param = 4;
  optional uint32 cow_version = 5;
  optional VABCFeatureSet vabc_feature_set = 6;
  optional uint64 compression_factor = 7;
}
message ApexInfo {
  optional string package_name = 1;
  optional int64 version = 2;
  optional bool is_compressed = 3;
  optional int64 decompressed_size = 4;
}
message ApexMetadata {
  repeated ApexInfo apex_info = 1;
}
message DeltaArchiveManifest {
  reserved 1, 2;
  optional uint32 block_size = 3 [default = 4096];
  optional uint64 signatures_offset = 4;
  optional uint64 signatures_size = 5;
  reserved 6,7,8,9,10,11;
  optional uint32 minor_version = 12 [default = 0];
  repeated PartitionUpdate partitions = 13;
  optional int64 max_timestamp = 14;
  optional DynamicPartitionMetadata dynamic_partition_metadata = 15;
  optional bool partial_update = 16;
  repeated ApexInfo apex_info = 17;
  optional string security_patch_level = 18;
}
