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 #include "host/libs/avb/avb.h"
23 
24 namespace cuttlefish {
25 
26 Result<void> RepackBootImage(const Avb& avb,
27                              const std::string& new_kernel_path,
28                              const std::string& boot_image_path,
29                              const std::string& new_boot_image_path,
30                              const std::string& tmp_artifact_dir);
31 bool RepackVendorBootImage(const std::string& new_ramdisk_path,
32                            const std::string& vendor_boot_image_path,
33                            const std::string& new_vendor_boot_image_path,
34                            const std::string& unpack_dir,
35                            bool bootconfig_supported);
36 bool RepackVendorBootImageWithEmptyRamdisk(
37     const std::string& vendor_boot_image_path,
38     const std::string& new_vendor_boot_image_path,
39     const std::string& unpack_dir, bool bootconfig_supported);
40 bool UnpackBootImage(const std::string& boot_image_path,
41                      const std::string& unpack_dir);
42 bool UnpackVendorBootImageIfNotUnpacked(
43     const std::string& vendor_boot_image_path, const std::string& unpack_dir);
44 void RepackGem5BootImage(const std::string& initrd_path,
45                          const std::string& bootconfig_path,
46                          const std::string& unpack_dir,
47                          const std::string& input_ramdisk_path);
48 Result<std::string> ReadAndroidVersionFromBootImage(
49     const std::string& boot_image_path);
50 
51 void UnpackRamdisk(const std::string& original_ramdisk_path,
52                    const std::string& ramdisk_stage_dir);
53 void PackRamdisk(const std::string& ramdisk_stage_dir,
54                  const std::string& output_ramdisk);
55 }
56