1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 18 #include <string> 19 #include <vector> 20 21 #include "common/libs/utils/result.h" 22 23 namespace cuttlefish { 24 25 // Taken from external/avb/libavb/avb_slot_verify.c; this define is not in the 26 // headers 27 static constexpr size_t VBMETA_MAX_SIZE = 65536ul; 28 29 bool RepackBootImage(const std::string& new_kernel_path, 30 const std::string& boot_image_path, 31 const std::string& new_boot_image_path, 32 const std::string& tmp_artifact_dir); 33 bool RepackVendorBootImage(const std::string& new_ramdisk_path, 34 const std::string& vendor_boot_image_path, 35 const std::string& new_vendor_boot_image_path, 36 const std::string& unpack_dir, 37 bool bootconfig_supported); 38 bool RepackVendorBootImageWithEmptyRamdisk( 39 const std::string& vendor_boot_image_path, 40 const std::string& new_vendor_boot_image_path, 41 const std::string& unpack_dir, bool bootconfig_supported); 42 bool UnpackBootImage(const std::string& boot_image_path, 43 const std::string& unpack_dir); 44 bool UnpackVendorBootImageIfNotUnpacked( 45 const std::string& vendor_boot_image_path, const std::string& unpack_dir); 46 void RepackGem5BootImage(const std::string& initrd_path, 47 const std::string& bootconfig_path, 48 const std::string& unpack_dir, 49 const std::string& input_ramdisk_path); 50 Result<std::string> ReadAndroidVersionFromBootImage( 51 const std::string& boot_image_path); 52 53 void UnpackRamdisk(const std::string& original_ramdisk_path, 54 const std::string& ramdisk_stage_dir); 55 void PackRamdisk(const std::string& ramdisk_stage_dir, 56 const std::string& output_ramdisk); 57 } 58