From f894afcb1e09c34fb041805d15fe1d39ce3abd0f Mon Sep 17 00:00:00 2001 From: Tquet Date: Mon, 11 May 2015 01:43:41 -0700 Subject: [PATCH 01/10] Python 2.7: ZIP_64 zipfile patch Python 2.7's zipfile implementation wrongly thinks that zip64 is required for files larger than 2GiB. We can work around this by adjusting their limit. Note that `zipfile.writestr()` will not work for strings larger than 2GiB. The Python interpreter sometimes rejects strings that large (though it isn't clear to me exactly what circumstances cause this). --- tools/releasetools/common.py | 40 +++++++++++++++++++++ tools/releasetools/img_from_target_files.py | 6 ++++ 2 files changed, 46 insertions(+) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 55fdb2bdc0..ecc7ae8c08 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -851,6 +851,46 @@ def ReadFile(self): return result +def ZipWrite(zip_file, filename, arcname=None, perms=0o644, + compress_type=None): + import datetime + + # http://b/18015246 + # Python 2.7's zipfile implementation wrongly thinks that zip64 is required + # for files larger than 2GiB. We can work around this by adjusting their + # limit. Note that `zipfile.writestr()` will not work for strings larger than + # 2GiB. The Python interpreter sometimes rejects strings that large (though + # it isn't clear to me exactly what circumstances cause this). + # `zipfile.write()` must be used directly to work around this. + # + # This mess can be avoided if we port to python3. + saved_zip64_limit = zipfile.ZIP64_LIMIT + zipfile.ZIP64_LIMIT = (1 << 32) - 1 + + if compress_type is None: + compress_type = zip_file.compression + if arcname is None: + arcname = filename + + saved_stat = os.stat(filename) + + try: + # `zipfile.write()` doesn't allow us to pass ZipInfo, so just modify the + # file to be zipped and reset it when we're done. + os.chmod(filename, perms) + + # Use a fixed timestamp so the output is repeatable. + epoch = datetime.datetime.fromtimestamp(0) + timestamp = (datetime.datetime(2009, 1, 1) - epoch).total_seconds() + os.utime(filename, (timestamp, timestamp)) + + zip_file.write(filename, arcname=arcname, compress_type=compress_type) + finally: + os.chmod(filename, saved_stat.st_mode) + os.utime(filename, (saved_stat.st_atime, saved_stat.st_mtime)) + zipfile.ZIP64_LIMIT = saved_zip64_limit + + def ZipWriteStr(zip, filename, data, perms=0644, compression=None): # use a fixed timestamp so the output is repeatable. zinfo = zipfile.ZipInfo(filename=filename, diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py index 4c41cd6f0e..dfe27b2d3e 100755 --- a/tools/releasetools/img_from_target_files.py +++ b/tools/releasetools/img_from_target_files.py @@ -165,7 +165,13 @@ def banner(s): finally: print "cleaning up..." + # http://b/18015246 + # See common.py for context. zipfile also refers to ZIP64_LIMIT during + # close() when it writes out the central directory. + saved_zip64_limit = zipfile.ZIP64_LIMIT + zipfile.ZIP64_LIMIT = (1 << 32) - 1 output_zip.close() + zipfile.ZIP64_LIMIT = saved_zip64_limit shutil.rmtree(OPTIONS.input_tmp) print "done." From b88c4d5e60f4e222f3a3d1c5c27280c27414a266 Mon Sep 17 00:00:00 2001 From: Tquet Date: Mon, 11 May 2015 01:47:33 -0700 Subject: [PATCH 02/10] Timestamp: Build.prop fallback find the build.prop file and get the timestamp from there instead. --- tools/releasetools/build_image.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index 29ccd62396..4d5ccbe042 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -244,6 +244,22 @@ def BuildImage(in_dir, prop_dict, out_file, build_command.extend(["-j", prop_dict["journal_size"]]) if "timestamp" in prop_dict: build_command.extend(["-T", str(prop_dict["timestamp"])]) + else: + #Timestamp not provided in property_dict. + #Lets try to find the build.prop file and get the timestamp from there + #instead + path = in_dir + "/build.prop" + if os.path.exists(path): + with open(path) as f: + lines = f.readlines() + for line in lines: + line = line.strip() + if line.startswith("ro.build.date.utc"): + name, value = line.split("=", 1) + print "read ro.build.date.utc from build.prop as ", value + build_command.extend(["-T", value]) + else: + print "unable to open build.prop file..Image will be built using system time" if fs_config is not None: build_command.extend(["-C", fs_config]) if block_list is not None: From 14bedc16c7952039fc18d1ef5f08fa45cf564317 Mon Sep 17 00:00:00 2001 From: Tquet Date: Mon, 11 May 2015 01:56:40 -0700 Subject: [PATCH 03/10] Patch: add Cortex-A53 Kang'd from CAF --- core/combo/arch/arm64/armv8-a.mk | 5 +++++ core/config.mk | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/core/combo/arch/arm64/armv8-a.mk b/core/combo/arch/arm64/armv8-a.mk index edc0497eeb..d94f35baa5 100644 --- a/core/combo/arch/arm64/armv8-a.mk +++ b/core/combo/arch/arm64/armv8-a.mk @@ -1 +1,6 @@ arch_variant_cflags := + +ifeq ($(TARGET_CPU_CORTEX_A53),true) +arch_variant_ldflags := -Wl,--fix-cortex-a53-843419 \ + -Wl,--fix-cortex-a53-835769 +endif diff --git a/core/config.mk b/core/config.mk index 9f9c343409..7134994c53 100644 --- a/core/config.mk +++ b/core/config.mk @@ -561,6 +561,10 @@ DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_CPU_VARIANT) DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default ifneq (,$(filter $(DEX2OAT_TARGET_CPU_VARIANT),cortex-a7 cortex-a15 krait denver generic cortex-a53)) DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := div + ifneq (,$(filter $(DEX2OAT_TARGET_CPU_VARIANT),cortex-a53)) + DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES += needfix_835769 + DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := $(subst $(space),$(comma),$(strip $(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES))) + endif endif ifdef TARGET_2ND_ARCH @@ -569,6 +573,10 @@ $(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_2ND_CPU_VARI $(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default ifneq (,$(filter $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT),cortex-a7 cortex-a15 krait denver cortex-a53)) $(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := div + ifneq (,$(filter $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT),cortex-a53)) + DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES += needfix_835769 + DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := $(subst $(space),$(comma),$(strip $(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES))) + endif endif endif From 9024227589beb99fb1a325a3c55a9add33b52655 Mon Sep 17 00:00:00 2001 From: Tquet Date: Mon, 11 May 2015 02:01:35 -0700 Subject: [PATCH 04/10] Feature: Kill system.new.dat ROMs build like CAF/traditional firmware with the typical folder structure you'd see in 4.4 and lower. I know this could be considered explosive to suggest lol --- core/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/core/Makefile b/core/Makefile index 35c0f9e647..c2bc93600a 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1679,7 +1679,6 @@ $(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS) @echo -e ${CL_YLW}"Package OTA:"${CL_RST}" $@" $(hide) MKBOOTIMG=$(MKBOOTIMG) \ $(OTA_FROM_TARGET_SCRIPT) -v \ - --block \ -p $(HOST_OUT) \ -k $(KEY_CERT_PAIR) \ --backup=$(backuptool) \ From 35f34b807f72494dc8daebec4a8b1ca0a7f74a3f Mon Sep 17 00:00:00 2001 From: Tquet Date: Mon, 11 May 2015 02:09:57 -0700 Subject: [PATCH 05/10] Debug: Insecure Build / Deodexed PureNexus/android_build/commit/f5b27d84aff314b601f30cd353bc626fd72121d7 --- core/main.mk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/main.mk b/core/main.mk index cea8327bc2..11cd0801fb 100644 --- a/core/main.mk +++ b/core/main.mk @@ -324,10 +324,11 @@ endif user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT)) enable_target_debugging := true +WITH_DEXPREOPT := false tags_to_install := ifneq (,$(user_variant)) # Target is secure in user builds. - ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1 + ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0 ifeq ($(user_variant),userdebug) # Pick up some extra useful tools @@ -337,7 +338,7 @@ ifneq (,$(user_variant)) ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500 else # Disable debugging in plain user builds. - enable_target_debugging := + enable_target_debugging := true endif # Turn on Dalvik preoptimization for libdvm.so user builds, but only if not @@ -347,7 +348,7 @@ ifneq (,$(user_variant)) ifeq ($(DALVIK_VM_LIB),libdvm.so) ifeq ($(user_variant),user) ifeq ($(HOST_OS),linux) - WITH_DEXPREOPT := true + WITH_DEXPREOPT := false endif endif endif @@ -379,6 +380,7 @@ endif # !enable_target_debugging ifeq ($(TARGET_BUILD_VARIANT),eng) tags_to_install := debug eng +WITH_DEXPREOPT := false ifneq ($(filter ro.setupwizard.mode=ENABLED, $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))),) # Don't require the setup wizard on eng builds ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\ From 8e2782b53c88a2f74be67d292cd3dd940e33e84d Mon Sep 17 00:00:00 2001 From: Tquet Date: Mon, 11 May 2015 02:10:53 -0700 Subject: [PATCH 06/10] Revert "Feature: Kill system.new.dat" This reverts commit 9024227589beb99fb1a325a3c55a9add33b52655. --- core/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Makefile b/core/Makefile index c2bc93600a..35c0f9e647 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1679,6 +1679,7 @@ $(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS) @echo -e ${CL_YLW}"Package OTA:"${CL_RST}" $@" $(hide) MKBOOTIMG=$(MKBOOTIMG) \ $(OTA_FROM_TARGET_SCRIPT) -v \ + --block \ -p $(HOST_OUT) \ -k $(KEY_CERT_PAIR) \ --backup=$(backuptool) \ From e97cb4f905e8105e116c0e6786e2055092f39c9e Mon Sep 17 00:00:00 2001 From: Tquet Date: Mon, 11 May 2015 02:14:46 -0700 Subject: [PATCH 07/10] Patch: OLD_OTA To use the ROM format found in 4.4 and below (no system.new.dat) add the following to BoardConfig: TARGET_USES_BLOCK_BASED_OTA := false --- core/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/Makefile b/core/Makefile index 35c0f9e647..7d099ce4fe 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1673,13 +1673,16 @@ ifneq ($(TARGET_UNIFIED_DEVICE),) endif endif + $(INTERNAL_OTA_PACKAGE_TARGET): block_ota := --block +endif + $(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS) @echo "$(OTA_FROM_TARGET_SCRIPT)" > $(PRODUCT_OUT)/ota_script_path @echo "$(override_device)" > $(PRODUCT_OUT)/ota_override_device @echo -e ${CL_YLW}"Package OTA:"${CL_RST}" $@" $(hide) MKBOOTIMG=$(MKBOOTIMG) \ $(OTA_FROM_TARGET_SCRIPT) -v \ - --block \ + $(block_ota) \ -p $(HOST_OUT) \ -k $(KEY_CERT_PAIR) \ --backup=$(backuptool) \ From ee6a352d9c8bf7c6d91332c3f9edc1b7f1aafeb2 Mon Sep 17 00:00:00 2001 From: Tquet Date: Mon, 11 May 2015 02:24:54 -0700 Subject: [PATCH 08/10] Patch: OLD_OTA II / make cleaner make clean: Clean only current working-device make cleaner: Clean everything in /out folder --- core/Makefile | 1 + core/main.mk | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/Makefile b/core/Makefile index 7d099ce4fe..6f06b53c96 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1673,6 +1673,7 @@ ifneq ($(TARGET_UNIFIED_DEVICE),) endif endif +ifneq ($(OLD_OTA),false) $(INTERNAL_OTA_PACKAGE_TARGET): block_ota := --block endif diff --git a/core/main.mk b/core/main.mk index 11cd0801fb..978c9e5a13 100644 --- a/core/main.mk +++ b/core/main.mk @@ -84,6 +84,9 @@ dont_bother_goals := clean clobber dataclean installclean \ ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),) dont_bother := true endif +ifeq ($(MAKECMDGOALS),cleaner) +dont_bother := true +endif # Targets that provide quick help on the build system. include $(BUILD_SYSTEM)/help.mk @@ -1056,14 +1059,19 @@ endif # samplecode in $(MAKECMDGOALS) .PHONY: findbugs findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET) -.PHONY: clean -clean: +.PHONY: cleaner +cleaner: @rm -rf $(OUT_DIR)/* @echo -e ${CL_GRN}"Entire build directory removed."${CL_RST} .PHONY: clobber clobber: clean +.PHONY: clean +clean: + @rm -rf $(OUT_DIR)/target/product/*/ + @echo -e ${CL_GRN}"Working device build directory removed."${CL_RST} + # The rules for dataclean and installclean are defined in cleanbuild.mk. #xxx scrape this from ALL_MODULE_NAME_TAGS From 52d35ca8cca286c3c41b75849fc0a7f6631e8cf1 Mon Sep 17 00:00:00 2001 From: Tquet Date: Mon, 11 May 2015 02:30:05 -0700 Subject: [PATCH 09/10] Spring Cleaning: Discontinued by Google But I have left browser intact for obvious reasons :< --- target/product/core.mk | 5 ----- target/product/full_base.mk | 3 --- target/product/generic_no_telephony.mk | 2 -- target/product/sdk_base.mk | 8 -------- 4 files changed, 18 deletions(-) diff --git a/target/product/core.mk b/target/product/core.mk index e7a8d3d7fa..5338178acf 100644 --- a/target/product/core.mk +++ b/target/product/core.mk @@ -24,7 +24,6 @@ PRODUCT_PACKAGES += \ BasicDreams \ Browser \ Calculator \ - Calendar \ CalendarProvider \ CaptivePortalLogin \ CertInstaller \ @@ -32,8 +31,6 @@ PRODUCT_PACKAGES += \ DeskClock \ DocumentsUI \ DownloadProviderUi \ - Email \ - Exchange2 \ ExternalStorageProvider \ FusedLocation \ InputDevices \ @@ -41,12 +38,10 @@ PRODUCT_PACKAGES += \ Keyguard \ LatinIME \ ManagedProvisioning \ - PicoTts \ PacProcessor \ libpac \ PrintSpooler \ ProxyHandler \ - QuickSearchBox \ Settings \ SharedStorageBackup \ Telecom \ diff --git a/target/product/full_base.mk b/target/product/full_base.mk index 2ba2ced211..3364b1aef0 100644 --- a/target/product/full_base.mk +++ b/target/product/full_base.mk @@ -36,9 +36,6 @@ PRODUCT_AAPT_CONFIG := normal # Get some sounds $(call inherit-product-if-exists, frameworks/base/data/sounds/AllAudio.mk) -# Get the TTS language packs -$(call inherit-product-if-exists, external/svox/pico/lang/all_pico_languages.mk) - # Get a list of languages. $(call inherit-product, $(SRC_TARGET_DIR)/product/locales_full.mk) diff --git a/target/product/generic_no_telephony.mk b/target/product/generic_no_telephony.mk index e60e63c1fa..16c2b3be42 100644 --- a/target/product/generic_no_telephony.mk +++ b/target/product/generic_no_telephony.mk @@ -21,8 +21,6 @@ PRODUCT_PACKAGES := \ Bluetooth \ Camera2 \ Gallery2 \ - Email \ - Exchange2 \ MusicFX \ OneTimeInitializer \ Provision \ diff --git a/target/product/sdk_base.mk b/target/product/sdk_base.mk index 451c0b71a3..9a725a9380 100644 --- a/target/product/sdk_base.mk +++ b/target/product/sdk_base.mk @@ -87,14 +87,6 @@ $(call inherit-product-if-exists, frameworks/base/data/keyboards/keyboards.mk) $(call inherit-product-if-exists, frameworks/webview/chromium/chromium.mk) $(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk) -# include available languages for TTS in the system image --include external/svox/pico/lang/PicoLangDeDeInSystem.mk --include external/svox/pico/lang/PicoLangEnGBInSystem.mk --include external/svox/pico/lang/PicoLangEnUsInSystem.mk --include external/svox/pico/lang/PicoLangEsEsInSystem.mk --include external/svox/pico/lang/PicoLangFrFrInSystem.mk --include external/svox/pico/lang/PicoLangItItInSystem.mk - # locale. en_US is both first and in alphabetical order to # ensure this is the default locale. PRODUCT_LOCALES := \ From 56275610978df713d191e14ed7cdc272eeb79ed8 Mon Sep 17 00:00:00 2001 From: Tquet Date: Mon, 11 May 2015 02:37:37 -0700 Subject: [PATCH 10/10] Patch: OLD_OTA III Build ENV will build traditional looking firmware before using the new '.dat' compression engine. To use this, add the following to your boardconfig OLD_OTA := true --- core/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Makefile b/core/Makefile index 6f06b53c96..1286de813f 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1673,7 +1673,7 @@ ifneq ($(TARGET_UNIFIED_DEVICE),) endif endif -ifneq ($(OLD_OTA),false) +ifneq ($(OLD_OTA),true) $(INTERNAL_OTA_PACKAGE_TARGET): block_ota := --block endif