tulip: Flash dummy super image if needed

* Needed because stock does not use dynamic partitions so
  there's no existing metadata that could be used

Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
This commit is contained in:
Tim Zimmermann
2021-07-26 21:13:30 +05:30
committed by GhostMaster69-dev
parent fa06407c1e
commit e48a4ca074
4 changed files with 73 additions and 0 deletions

View File

@@ -127,4 +127,18 @@ $(CNE_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
ALL_DEFAULT_INSTALLED_MODULES += $(CNE_SYMLINKS)
include $(call all-makefiles-under,$(LOCAL_PATH))
LPFLASH := $(HOST_OUT_EXECUTABLES)/lpflash$(HOST_EXECUTABLE_SUFFIX)
INSTALLED_SUPERIMAGE_DUMMY_TARGET := $(PRODUCT_OUT)/super_dummy.img
$(INSTALLED_SUPERIMAGE_DUMMY_TARGET): $(PRODUCT_OUT)/super_empty.img $(LPFLASH)
$(call pretty,"Target dummy super image: $@")
$(hide) touch $@
$(hide) $(LPFLASH) $@ $(PRODUCT_OUT)/super_empty.img
.PHONY: super_dummyimage
super_dummyimage: $(INSTALLED_SUPERIMAGE_DUMMY_TARGET)
INSTALLED_RADIOIMAGE_TARGET += $(INSTALLED_SUPERIMAGE_DUMMY_TARGET)
endif

View File

@@ -175,6 +175,9 @@ BOARD_VENDOR_SEPOLICY_DIRS += $(DEVICE_PATH)/sepolicy/vendor
PRODUCT_PRIVATE_SEPOLICY_DIRS += $(DEVICE_PATH)/sepolicy/private
PRODUCT_PUBLIC_SEPOLICY_DIRS += $(DEVICE_PATH)/sepolicy/public
# Releasetools
TARGET_RELEASETOOLS_EXTENSIONS := $(DEVICE_PATH)
# Security patch level
VENDOR_SECURITY_PATCH := $(PLATFORM_SECURITY_PATCH)

View File

@@ -0,0 +1,20 @@
#!/system/bin/sh
#
# Copyright (C) 2021 The PixelExperience Project
#
# SPDX-License-Identifier: Apache-2.0
#
SUPER="/dev/block/by-name/system"
mkdir /tmp/super-mnt
mount $SUPER /tmp/super-mnt 2>/dev/null
if [ "$?" = "0" ]; then
echo "Detected stock /system in super partition, flashing super_dummy.img!"
umount /tmp/super-mnt
dd if=/tmp/super_dummy.img of=$SUPER
fi
rmdir /tmp/super-mnt

36
releasetools.py Normal file
View File

@@ -0,0 +1,36 @@
# Copyright (C) 2009 The Android Open Source Project
# Copyright (c) 2011, The Linux Foundation. All rights reserved.
# Copyright (C) 2017-2020 The LineageOS 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.
import common
import re
def FullOTA_InstallBegin(info):
AddImage(info, "RADIO", "super_dummy.img", "/tmp/super_dummy.img");
flash_script = open("device/xiaomi/tulip/partitions/flash_super_dummy.sh", 'r').read()
common.ZipWriteStr(info.output_zip, "install/bin/flash_super_dummy.sh", flash_script);
info.script.AppendExtra('package_extract_file("install/bin/flash_super_dummy.sh", "/tmp/flash_super_dummy.sh");')
info.script.AppendExtra('run_program("/sbin/sh", "/tmp/flash_super_dummy.sh");')
return
def AddImage(info, dir, basename, dest):
path = dir + "/" + basename
if path not in info.input_zip.namelist():
return
data = info.input_zip.read(path)
common.ZipWriteStr(info.output_zip, basename, data)
info.script.Print("Patching {} image unconditionally...".format(dest.split('/')[-1]))
info.script.AppendExtra('package_extract_file("%s", "%s");' % (basename, dest))