From 186989ad2682f1821084ce5812c815e67a502ad9 Mon Sep 17 00:00:00 2001
From: xingrz <chenxingyu92@gmail.com>
Date: Wed, 13 Nov 2019 08:01:53 +0000
Subject: [PATCH] onclite: releasetools: Add dtbo image to the output zip if
 present

Signed-off-by: Dhina17 <dhinalogu@gmail.com>
---
 BoardConfig.mk  |  3 +++
 releasetools.py | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100755 releasetools.py

diff --git a/BoardConfig.mk b/BoardConfig.mk
index 7a85463..cb87a26 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -200,6 +200,9 @@ TARGET_RIL_VARIANT := caf
 # Recovery
 TARGET_RECOVERY_FSTAB := $(DEVICE_PATH)/rootdir/fstab.qcom
 
+# Releasetools
+TARGET_RELEASETOOLS_EXTENSIONS := $(DEVICE_PATH)
+
 # SELinux
 include device/qcom/sepolicy/sepolicy.mk
 BOARD_SEPOLICY_DIRS += $(DEVICE_PATH)/sepolicy
diff --git a/releasetools.py b/releasetools.py
new file mode 100755
index 0000000..1140b7d
--- /dev/null
+++ b/releasetools.py
@@ -0,0 +1,41 @@
+# Copyright (C) 2009 The Android Open Source Project
+# Copyright (c) 2011, The Linux Foundation. All rights reserved.
+# Copyright (C) 2017-2018 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 hashlib
+import common
+import re
+
+def FullOTA_InstallEnd(info):
+  OTA_InstallEnd(info)
+  return
+
+def IncrementalOTA_InstallEnd(info):
+  OTA_InstallEnd(info)
+  return
+
+def AddImage(info, basename, dest):
+  path = "IMAGES/" + 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.AppendExtra('package_extract_file("%s", "%s");' % (basename, dest))
+
+def OTA_InstallEnd(info):
+  info.script.Print("Patching firmware images...")
+  AddImage(info, "dtbo.img", "/dev/block/bootdevice/by-name/dtbo")
+  return
-- 
GitLab