From 3881d9e6bc345e5bf603b4d0f86898aadb1103b6 Mon Sep 17 00:00:00 2001 From: Guillaume Castagnino Date: Thu, 17 Jun 2021 17:59:25 +0200 Subject: [PATCH] mutualize header --- Makefile | 10 ++++-- common/addon_head | 27 ++++++++++++++++ dist-font/Makefile | 2 ++ dist-font/cm-data/99-font.sh.addon | 31 ++----------------- dist-google-more/Makefile | 2 ++ .../99-perso-google-clean-more.sh.addon | 28 ++--------------- dist-google/Makefile | 2 ++ .../cm-data/99-perso-google-clean.sh.addon | 28 ++--------------- dist-std/Makefile | 2 ++ dist-std/cm-data/99-perso.sh.addon | 31 ++----------------- 10 files changed, 50 insertions(+), 113 deletions(-) create mode 100644 common/addon_head create mode 100644 dist-font/Makefile create mode 100644 dist-google-more/Makefile create mode 100644 dist-google/Makefile create mode 100644 dist-std/Makefile diff --git a/Makefile b/Makefile index 75d134a..df0ebee 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ clean: $(ZIPS_DIRS:dist-%=clean-%) # clean targets $(ZIPS_DIRS:dist-%=clean-%): - rm -f $(@:clean-%=cm-custom-%.zip) $(@:clean-%=cm-custom-%-signed.zip) + rm -rf $(@:clean-%=build-%) $(@:clean-%=cm-custom-%.zip) $(@:clean-%=cm-custom-%-signed.zip) # signature targets $(ZIPS_DIRS:dist-%=cm-custom-%-signed.zip): cm-custom-%-signed.zip : cm-custom-%.zip @@ -24,6 +24,10 @@ $(ZIPS_DIRS:dist-%=cm-custom-%-signed.zip): cm-custom-%-signed.zip : cm-custom-% # build target $(ZIPS_DIRS:dist-%=cm-custom-%.zip): cm-custom-%.zip : $(FILES_COMMON) $$(shell find dist-$$* -type f) zip $@ $(FILES_COMMON) - cd dist-$* && \ - zip ../$@ $$(find . -type f) + rm -rf build-$* + cp -a dist-$* build-$* + cd build-$* && \ + make && \ + zip ../$@ $$(find . -type f ! -name Makefile) + rm -rf build-$* diff --git a/common/addon_head b/common/addon_head new file mode 100644 index 0000000..abb9d5d --- /dev/null +++ b/common/addon_head @@ -0,0 +1,27 @@ +#!/sbin/sh +# +# ADDOND_VERSION=3 +# + +# we partially use the script at install, if so, $SYSTEM, $PRODUCT, $SYSTEM_EXT are defined +if [ -z $SYSTEM ]; then + . /tmp/backuptool.functions + # build missing $PRODUCT and $SYSTEM_EXT from $S. Keep them inside system, real path is computed after using the get_output_path function + # see https://github.com/LineageOS/android_vendor_lineage/commit/c63fa8441bb5ad1fc4fb68155a5e5166aa25cac0#diff-9cf467ef8562a8e65ef885b33fe3f29cee408bb251fb05aed28661f08bfe0c64 + SYS=$S + PRODUCT="$S/product" + SYSTEM_EXT="$S/system_ext" +else + # install in recovery, script assume $S and $SYS defined + S=$SYSTEM + SYS=$SYSTEM + # PRODUCT AND SYSTEM_EXT defined from recovery + + get_output_path() { + # In recovery we mounted all partitions in the right place, so we can rely on symlinks + echo "$1" + } +fi + +# path is needed when running from recovery (at install) +export PATH="${PATH}:$S/bin:$S/xbin" diff --git a/dist-font/Makefile b/dist-font/Makefile new file mode 100644 index 0000000..04aaa3c --- /dev/null +++ b/dist-font/Makefile @@ -0,0 +1,2 @@ +all: + sed -e '/__HEADER__/ {' -e 'r ../common/addon_head' -e 'd' -e '}' -i cm-data/*.addon diff --git a/dist-font/cm-data/99-font.sh.addon b/dist-font/cm-data/99-font.sh.addon index cdd555f..be1b24c 100755 --- a/dist-font/cm-data/99-font.sh.addon +++ b/dist-font/cm-data/99-font.sh.addon @@ -1,32 +1,4 @@ -#!/sbin/sh -# -# ADDOND_VERSION=3 -# -# /system/addon.d/99-font.sh -# - -# we partially use the script at install, if so, $SYSTEM, $PRODUCT, $SYSTEM_EXT are defined -if [ -z $SYSTEM ]; then - . /tmp/backuptool.functions - # build missing $PRODUCT and $SYSTEM_EXT from $S. Keep them inside system, real path is computed after using the get_output_path function - # see https://github.com/LineageOS/android_vendor_lineage/commit/c63fa8441bb5ad1fc4fb68155a5e5166aa25cac0#diff-9cf467ef8562a8e65ef885b33fe3f29cee408bb251fb05aed28661f08bfe0c64 - SYS=$S - PRODUCT="$S/product" - SYSTEM_EXT="$S/system_ext" -else - # install in recovery, script assume $S and $SYS defined - S=$SYSTEM - SYS=$SYSTEM - # PRODUCT AND SYSTEM_EXT defined from recovery - - get_output_path() { - # In recovery we mounted all partitions in the right place, so we can rely on symlinks - echo "$1" - } -fi - -# path is needed when running from recovery (at install) -export PATH="${PATH}:$S/bin:$S/xbin" +__HEADER__ list_files() { cat <