1*5a923131SAndroid Build Coastguard Worker#!/bin/bash 2*5a923131SAndroid Build Coastguard Worker# 3*5a923131SAndroid Build Coastguard Worker# Copyright (C) 2020 The Android Open Source Project 4*5a923131SAndroid Build Coastguard Worker# 5*5a923131SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 6*5a923131SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 7*5a923131SAndroid Build Coastguard Worker# You may obtain a copy of the License at 8*5a923131SAndroid Build Coastguard Worker# 9*5a923131SAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 10*5a923131SAndroid Build Coastguard Worker# 11*5a923131SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 12*5a923131SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 13*5a923131SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*5a923131SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 15*5a923131SAndroid Build Coastguard Worker# limitations under the License. 16*5a923131SAndroid Build Coastguard Worker# 17*5a923131SAndroid Build Coastguard Worker 18*5a923131SAndroid Build Coastguard Worker# This script generates some sample payloads from the images in 19*5a923131SAndroid Build Coastguard Worker# sample_images.tar.bz2. and packages them in the sample_payloads.tar.xz file. 20*5a923131SAndroid Build Coastguard Worker# The payloads are then used in paycheck_unittests.py. The file names 21*5a923131SAndroid Build Coastguard Worker# must match the ones used in update_payload ebuild and paycheck_unittests.py. 22*5a923131SAndroid Build Coastguard Worker 23*5a923131SAndroid Build Coastguard Workerset -e 24*5a923131SAndroid Build Coastguard Worker 25*5a923131SAndroid Build Coastguard WorkerTEMP_IMG_DIR=./sample_images 26*5a923131SAndroid Build Coastguard WorkerOLD_KERNEL="${TEMP_IMG_DIR}/disk_ext2_4k_empty.img" 27*5a923131SAndroid Build Coastguard WorkerOLD_ROOT="${TEMP_IMG_DIR}/disk_sqfs_empty.img" 28*5a923131SAndroid Build Coastguard WorkerNEW_KERNEL="${TEMP_IMG_DIR}/disk_ext2_4k.img" 29*5a923131SAndroid Build Coastguard WorkerNEW_ROOT="${TEMP_IMG_DIR}/disk_sqfs_default.img" 30*5a923131SAndroid Build Coastguard Worker 31*5a923131SAndroid Build Coastguard Worker 32*5a923131SAndroid Build Coastguard Workermkdir -p "${TEMP_IMG_DIR}" 33*5a923131SAndroid Build Coastguard Workertar -xvf sample_images.tar.bz2 -C "${TEMP_IMG_DIR}" 34*5a923131SAndroid Build Coastguard Worker 35*5a923131SAndroid Build Coastguard Workerecho "Generating full payload" 36*5a923131SAndroid Build Coastguard Workerdelta_generator --out_file=full_payload.bin \ 37*5a923131SAndroid Build Coastguard Worker --partition_names=kernel:root \ 38*5a923131SAndroid Build Coastguard Worker --new_partitions="${NEW_KERNEL}":"${NEW_ROOT}" 39*5a923131SAndroid Build Coastguard Worker 40*5a923131SAndroid Build Coastguard Workerecho "Generating delta payload" 41*5a923131SAndroid Build Coastguard Workerdelta_generator --out_file=delta_payload.bin \ 42*5a923131SAndroid Build Coastguard Worker --partition_names=kernel:root \ 43*5a923131SAndroid Build Coastguard Worker --new_partitions="${NEW_KERNEL}":"${NEW_ROOT}" \ 44*5a923131SAndroid Build Coastguard Worker --old_partitions="${OLD_KERNEL}":"${OLD_ROOT}" --minor_version=6 45*5a923131SAndroid Build Coastguard Worker 46*5a923131SAndroid Build Coastguard Workerecho "Creating sample_payloads.tar" 47*5a923131SAndroid Build Coastguard Workertar -cJf sample_payloads.tar.xz {delta,full}_payload.bin 48*5a923131SAndroid Build Coastguard Worker 49*5a923131SAndroid Build Coastguard Workerrm -rf "${TEMP_IMG_DIR}" {delta,full}_payload.bin 50*5a923131SAndroid Build Coastguard Worker 51*5a923131SAndroid Build Coastguard Workerecho "Done" 52