Merge "Use sensible default locations for Java"
diff --git a/core/LINUX_KERNEL_COPYING b/core/LINUX_KERNEL_COPYING
new file mode 100644
index 0000000..ca442d3
--- /dev/null
+++ b/core/LINUX_KERNEL_COPYING
@@ -0,0 +1,356 @@
+
+ NOTE! This copyright does *not* cover user programs that use kernel
+ services by normal system calls - this is merely considered normal use
+ of the kernel, and does *not* fall under the heading of "derived work".
+ Also note that the GPL below is copyrighted by the Free Software
+ Foundation, but the instance of code that it refers to (the Linux
+ kernel) is copyrighted by me and others who actually wrote it.
+
+ Also note that the only valid version of the GPL as far as the kernel
+ is concerned is _this_ particular version of the license (ie v2, not
+ v2.2 or v3.x or whatever), unless explicitly otherwise stated.
+
+ Linus Torvalds
+
+----------------------------------------
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/core/Makefile b/core/Makefile
index db568d0..c930708 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -177,6 +177,12 @@
BUILDINFO_SH := build/tools/buildinfo.sh
+# TARGET_BUILD_FLAVOR and ro.build.flavor are used only by the test harness to distinguish builds.
+TARGET_BUILD_FLAVOR := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)
+ifdef SANITIZE_TARGET
+TARGET_BUILD_FLAVOR := $(TARGET_BUILD_FLAVOR)_asan
+endif
+
ifdef TARGET_SYSTEM_PROP
system_prop_file := $(TARGET_SYSTEM_PROP)
else
@@ -194,7 +200,7 @@
echo "import /oem/oem.prop $(prop)" >> $@;)
endif
$(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
- TARGET_BUILD_FLAVOR="$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)" \
+ TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \
TARGET_DEVICE="$(TARGET_DEVICE)" \
PRODUCT_NAME="$(TARGET_PRODUCT)" \
PRODUCT_BRAND="$(PRODUCT_BRAND)" \
@@ -314,7 +320,12 @@
@echo Package stats: $@
@mkdir -p $(dir $@)
$(hide) rm -f $@
+ifeq ($(PACKAGES_TO_STAT),)
+# Create empty package stats file if target builds no jar(s) or apk(s).
+ $(hide) touch $@
+else
$(hide) build/tools/dump-package-stats $^ > $@
+endif
.PHONY: package-stats
package-stats: $(PACKAGE_STATS_FILE)
@@ -528,14 +539,14 @@
$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER)
$(call pretty,"Target boot image: $@")
$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned
- $(VBOOT_SIGNER) $(FUTILITY) $@.unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $@.keyblock $@
+ $(VBOOT_SIGNER) $(FUTILITY) $@.unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $@.keyblock $@
$(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
.PHONY: bootimage-nodeps
bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER)
@echo "make $@: ignoring dependencies"
$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned
- $(VBOOT_SIGNER) $(FUTILITY) $(INSTALLED_BOOTIMAGE_TARGET).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(INSTALLED_BOOTIMAGE_TARGET).keyblock $(INSTALLED_BOOTIMAGE_TARGET)
+ $(VBOOT_SIGNER) $(FUTILITY) $(INSTALLED_BOOTIMAGE_TARGET).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(INSTALLED_BOOTIMAGE_TARGET).keyblock $(INSTALLED_BOOTIMAGE_TARGET)
$(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
else # PRODUCT_SUPPORTS_VBOOT != true
@@ -653,7 +664,7 @@
# make the target NOTICE files depend on this particular file too, which will
# then be in the right directory for the find in combine-notice-files to work.
$(kernel_notice_file): \
- prebuilts/qemu-kernel/arm/LINUX_KERNEL_COPYING \
+ $(BUILD_SYSTEM)/LINUX_KERNEL_COPYING \
| $(ACP)
@echo Copying: $@
$(hide) mkdir -p $(dir $@)
@@ -668,10 +679,11 @@
# before the rules that use that variable to build the image.
ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
-$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
+$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) | $(ZIPTIME)
$(hide) rm -f $@
$(hide) mkdir -p $(dir $@)
- $(hide) zip -qj $@ $<
+ $(hide) zip -qjX $@ $<
+ $(remove-timestamps-from-package)
.PHONY: otacerts
otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
@@ -762,6 +774,7 @@
$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)" >> $(1))
$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(FUTILITY)" >> $(1))
$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
@@ -911,7 +924,7 @@
$(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)),\
$(BOOT_SIGNER) /recovery $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1))
$(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
- $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(1).keyblock $(1))
+ $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1))
$(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))
@echo ----- Made recovery image: $(1) --------
endef
@@ -928,9 +941,10 @@
$(call build-recoveryimage-target, $@)
ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
-$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
+$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
$(hide) mkdir -p $(dir $@)
- $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@
+ $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
+ $(remove-timestamps-from-package)
endif
.PHONY: recoveryimage-nodeps
@@ -1121,19 +1135,19 @@
$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES)
$(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
$(hide) rm -f $@
- $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
+ $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
$(TARGET_COPY_OUT_SYSTEM) \
$(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
$(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
- $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
+ $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
$(TARGET_COPY_OUT_VENDOR)
endif
ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
- $(hide) cd $(OUT_DIR) && zip -qry $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
+ $(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
endif
ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
- $(hide) zip -qry $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
+ $(hide) zip -qryX $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
endif
.PHONY: platform
@@ -1402,9 +1416,9 @@
$(hide) $(ACP) -p system/extras/verity/build_verity_metadata.py $(zip_root)/system/extras/verity/
$(hide) $(ACP) -r -d -p build/tools/releasetools/* $(zip_root)/releasetools
$(hide) rm -rf $@ $(zip_root)/releasetools/*.pyc
- $(hide) (cd $(zip_root) && zip -qry $(abspath $@) *)
- $(hide) zip -qry $(abspath $@) build/target/product/security/
- $(hide) find device vendor -name \*.pk8 -o -name \*.x509.pem -o -name oem.prop | xargs zip -qry $(abspath $@)>/dev/null || true
+ $(hide) (cd $(zip_root) && zip -qryX $(abspath $@) *)
+ $(hide) zip -qryX $(abspath $@) build/target/product/security/
+ $(hide) find device vendor -name \*.pk8 -o -name \*.x509.pem -o -name oem.prop | xargs zip -qryX $(abspath $@)>/dev/null || true
.PHONY: otatools-package
otatools-package: $(BUILT_OTATOOLS_PACKAGE)
@@ -1445,7 +1459,6 @@
# We can't build static executables when SANITIZE_TARGET=address
ifeq ($(strip $(SANITIZE_TARGET)),)
built_ota_tools += \
- $(call intermediates-dir-for,EXECUTABLES,check_prereq,,,$(TARGET_PREFER_32_BIT))/check_prereq \
$(call intermediates-dir-for,EXECUTABLES,applypatch_static,,,$(TARGET_PREFER_32_BIT))/applypatch_static \
$(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater
endif
@@ -1485,6 +1498,7 @@
@echo "Package target files: $@"
$(hide) rm -rf $@ $(zip_root)
$(hide) mkdir -p $(dir $@) $(zip_root)
+ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
@# Components of the recovery image
$(hide) mkdir -p $(zip_root)/RECOVERY
$(hide) $(call package_files-copy-root, \
@@ -1505,6 +1519,7 @@
ifdef BOARD_KERNEL_PAGESIZE
$(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
endif
+endif
@# Components of the boot image
$(hide) mkdir -p $(zip_root)/BOOT
ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
@@ -1567,6 +1582,9 @@
ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
$(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
endif
+ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
+ $(hide) echo "no_recovery=true" >> $(zip_root)/META/misc_info.txt
+endif
ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
$(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
endif
@@ -1611,6 +1629,11 @@
$(hide) for part in $(AB_OTA_PARTITIONS); do \
echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
done
+ $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
+ echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
+ done
+ @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
+ $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $(zip_root)/META/misc_info.txt
ifdef OSRELEASED_DIRECTORY
$(hide) $(ACP) $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
$(hide) $(ACP) $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
@@ -1621,7 +1644,7 @@
$(hide) $(ACP) -r $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
endif
@# Zip everything up, preserving symlinks
- $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
+ $(hide) (cd $(zip_root) && zip -qryX ../$(notdir $@) .)
@# Run fs_config on all the system, vendor, boot ramdisk,
@# and recovery ramdisk files in the zip, and save the output
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/filesystem_config.txt
@@ -1631,8 +1654,10 @@
else
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt
endif
+ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt
- $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
+endif
+ $(hide) (cd $(zip_root) && zip -qX ../$(notdir $@) META/*filesystem_config.txt)
$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
./build/tools/releasetools/add_img_to_target_files -v -p $(HOST_OUT) $@
@@ -1712,7 +1737,7 @@
@echo "Package symbols: $@"
$(hide) rm -rf $@
$(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED)
- $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
+ $(hide) zip -qrX $@ $(TARGET_OUT_UNSTRIPPED)
# -----------------------------------------------------------------
# A zip of the Android Apps. Not keeping full path so that we don't
@@ -1729,8 +1754,13 @@
@echo "Package apps: $@"
$(hide) rm -rf $@
$(hide) mkdir -p $(dir $@)
- $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*/*.apk $(TARGET_OUT_APPS_PRIVILEGED)/*/*.apk
-
+ $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
+ if [ -z "$$apps_to_zip" ]; then \
+ echo "No apps to zip up. Generating empty apps archive." ; \
+ a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
+ else \
+ zip -qjX $@ $$apps_to_zip; \
+ fi
#------------------------------------------------------------------
# A zip of emma code coverage meta files. Generated for fully emma
@@ -1742,7 +1772,7 @@
$(EMMA_META_ZIP) :
@echo "Collecting Emma coverage meta files."
$(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "coverage.em" | \
- zip -@ -q $@
+ zip -@ -qX $@
endif # EMMA_INSTRUMENT=true
@@ -1758,7 +1788,7 @@
$(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary`; \
if [ -n "$$dict_files" ]; then \
unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
- zip -q $@ $$dict_files $$unobfuscated_jars; \
+ zip -qX $@ $$dict_files $$unobfuscated_jars; \
else \
touch $(dir $@)/zipdummy; \
(cd $(dir $@) && zip -q $(notdir $@) zipdummy); \
@@ -1789,7 +1819,7 @@
$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
@echo "Package: $@"
- $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
+ $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
endif
# -----------------------------------------------------------------
@@ -1924,7 +1954,7 @@
HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
chmod -R ug+rwX $(PRIVATE_DIR) && \
- cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
+ cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
@@ -1959,11 +1989,15 @@
include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
-include $(sort $(wildcard device/*/build/tasks/*.mk))
+-include $(sort $(wildcard product/*/build/tasks/*.mk))
# Also the project-specific tasks
-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
+-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
endif
+include $(BUILD_SYSTEM)/product-graph.mk
+
# -----------------------------------------------------------------
# Create SDK repository packages. Must be done after tasks/* since
# we need the addon rules defined.
diff --git a/core/base_rules.mk b/core/base_rules.mk
index a0a3582..42dfc1b 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -221,6 +221,33 @@
LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
###########################################################
+## Create .toc files from shared objects to reduce unnecessary rebuild
+# .toc files have the list of external dynamic symbols without their addresses.
+# For ninja build, .toc files will be updated only when the content of .toc
+# files are changed. As .KATI_RESTAT is specified to .toc files, dependent
+# binaries of a .toc file will be rebuilt only when the content of
+# the .toc file is changed.
+###########################################################
+ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
+LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE).toc
+$(LOCAL_BUILT_MODULE).toc: $(LOCAL_BUILT_MODULE)
+ifeq ($(BUILDING_WITH_NINJA),true)
+ $(call $(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)transform-shared-lib-to-toc,$<,$@.tmp)
+ $(hide) if cmp -s $@.tmp $@ ; then \
+ rm $@.tmp ; \
+ else \
+ mv $@.tmp $@ ; \
+ fi
+else
+ @# make doesn't support restat. We always update .toc files so the dependents will always be updated too.
+ $(call $(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)transform-shared-lib-to-toc,$<,$@)
+endif
+
+# Kati adds restat=1 to ninja. GNU make does nothing for this.
+.KATI_RESTAT: $(LOCAL_BUILT_MODULE).toc
+endif
+
+###########################################################
## logtags: Add .logtags files to global list
###########################################################
diff --git a/core/binary.mk b/core/binary.mk
index e9b2265..028950a 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -730,8 +730,9 @@
$(transform-aidl-to-cpp)
-include $(addsuffix .P,$(basename $(aidl_gen_cpp)))
-# Add generated headers to include path.
+# Add generated headers to include paths.
my_c_includes += $(aidl_gen_include_root)
+my_export_c_include_dirs += $(aidl_gen_include_root)
# Pick up the generated C++ files later for transformation to .o files.
my_generated_sources += $(aidl_gen_cpp)
@@ -1175,6 +1176,7 @@
$(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
$(addsuffix $(so_suffix), \
$(my_shared_libraries)))
+built_shared_library_tocs := $(addsuffix .toc, $(built_shared_libraries))
# Add the NDK libraries to the built module dependency
my_system_shared_libraries_fullpath := \
@@ -1188,6 +1190,8 @@
$(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
$(addsuffix $(so_suffix), \
$(installed_shared_library_module_names)))
+built_shared_library_tocs := $(addsuffix .toc, $(built_shared_libraries))
+my_system_shared_libraries_fullpath :=
endif
built_static_libraries := \
@@ -1282,7 +1286,8 @@
###########################################################
# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
all_libraries := \
- $(built_shared_libraries) \
+ $(built_shared_library_tocs) \
+ $(my_system_shared_libraries_fullpath) \
$(built_static_libraries) \
$(built_whole_libraries)
@@ -1297,7 +1302,10 @@
export_includes := $(intermediates)/export_includes
$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs)
# Make sure .pb.h are already generated before any dependent source files get compiled.
-$(export_includes) : $(LOCAL_MODULE_MAKEFILE_DEP) $(proto_generated_headers) $(dbus_generated_headers)
+# Similarly, the generated DBus headers need to exist before we export their location.
+# People are not going to consume the aidl generated cpp file, but the cpp file is
+# generated after the headers, so this is a convenient way to ensure the headers exist.
+$(export_includes) : $(LOCAL_MODULE_MAKEFILE_DEP) $(proto_generated_headers) $(dbus_generated_headers) $(aidl_gen_cpp)
@echo Export includes file: $< -- $@
$(hide) mkdir -p $(dir $@) && rm -f $@
ifdef my_export_c_include_dirs
diff --git a/core/clang/TARGET_arm64.mk b/core/clang/TARGET_arm64.mk
index 5120a6d..532ca77 100644
--- a/core/clang/TARGET_arm64.mk
+++ b/core/clang/TARGET_arm64.mk
@@ -66,6 +66,6 @@
TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-aarch64-android.a
# Address sanitizer clang config
-ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan-arm64-android
+ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan-aarch64-android
ADDRESS_SANITIZER_RPATH := /data/vendor/lib64:/$(TARGET_COPY_OUT_VENDOR)/lib64:/data/lib64
ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan64
diff --git a/core/clang/config.mk b/core/clang/config.mk
index 0c5e963..756bf49 100644
--- a/core/clang/config.mk
+++ b/core/clang/config.mk
@@ -1,8 +1,8 @@
## Clang configurations.
-LLVM_PREBUILTS_VERSION := 3.6
-FORCE_BUILD_SANITIZER_SHARED_OBJECTS := true
-LLVM_PREBUILTS_PATH := prebuilts/clang/host/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin
+LLVM_PREBUILTS_VERSION ?= 3.8
+LLVM_PREBUILTS_BASE ?= prebuilts/clang/host
+LLVM_PREBUILTS_PATH := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin
LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib/clang/$(LLVM_PREBUILTS_VERSION)/lib/linux/
CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
diff --git a/core/combo/HOST_CROSS_windows-x86.mk b/core/combo/HOST_CROSS_windows-x86.mk
index c5a713c..1ac1059 100644
--- a/core/combo/HOST_CROSS_windows-x86.mk
+++ b/core/combo/HOST_CROSS_windows-x86.mk
@@ -32,14 +32,21 @@
$(combo_var_prefix)GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
# Use C99-compliant printf functions (%zd).
$(combo_var_prefix)GLOBAL_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
-# Admit to using >= Win2K.
-$(combo_var_prefix)GLOBAL_CFLAGS += -D_WIN32_WINNT=0x0500
+# Admit to using >= Win2K. Both are needed because of <_mingw.h>.
+$(combo_var_prefix)GLOBAL_CFLAGS += -D_WIN32_WINNT=0x0500 -DWINVER=0x0500
# Get 64-bit off_t and related functions.
$(combo_var_prefix)GLOBAL_CFLAGS += -D_FILE_OFFSET_BITS=64
$(combo_var_prefix)CC := $(TOOLS_PREFIX)gcc
$(combo_var_prefix)CXX := $(TOOLS_PREFIX)g++
$(combo_var_prefix)AR := $(TOOLS_PREFIX)ar
+$(combo_var_prefix)NM := $(TOOLS_PREFIX)nm
+$(combo_var_prefix)OBJDUMP := $(TOOLS_PREFIX)objdump
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OBJDUMP) -x $(1) | grep "^Name" | cut -f3 -d" " > $(2)
+$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)NM) -g -f p $(1) | cut -f1-2 -d" " >> $(2)
+endef
$(combo_var_prefix)GLOBAL_LDFLAGS += \
--enable-stdcall-fixup
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index 85c883c..fc56e52 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -36,6 +36,10 @@
$(combo_2nd_arch_prefix)HOST_CC := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-gcc
$(combo_2nd_arch_prefix)HOST_CXX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-g++
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_macho,$(1),$(2))
+endef
+
# gcc location for clang; to be updated when clang is updated
# HOST_TOOLCHAIN_ROOT is a Darwin-specific define
$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)
diff --git a/core/combo/HOST_darwin-x86_64.mk b/core/combo/HOST_darwin-x86_64.mk
index 93a1b3e..251455f 100644
--- a/core/combo/HOST_darwin-x86_64.mk
+++ b/core/combo/HOST_darwin-x86_64.mk
@@ -36,6 +36,10 @@
HOST_CC := $(HOST_TOOLCHAIN_PREFIX)-gcc
HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)-g++
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_macho,$(1),$(2))
+endef
+
# gcc location for clang; to be updated when clang is updated
# HOST_TOOLCHAIN_ROOT is a Darwin-specific define
HOST_TOOLCHAIN_FOR_CLANG := $(HOST_TOOLCHAIN_ROOT)
diff --git a/core/combo/HOST_linux-x86.mk b/core/combo/HOST_linux-x86.mk
index 4caf607..b5efc71 100644
--- a/core/combo/HOST_linux-x86.mk
+++ b/core/combo/HOST_linux-x86.mk
@@ -23,6 +23,12 @@
$(combo_2nd_arch_prefix)HOST_CC := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)gcc
$(combo_2nd_arch_prefix)HOST_CXX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)g++
$(combo_2nd_arch_prefix)HOST_AR := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)ar
+$(combo_2nd_arch_prefix)HOST_READELF := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)readelf
+$(combo_2nd_arch_prefix)HOST_NM := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)nm
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_elf,$(1),$(2))
+endef
# gcc location for clang; to be updated when clang is updated
$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
diff --git a/core/combo/HOST_linux-x86_64.mk b/core/combo/HOST_linux-x86_64.mk
index 3708137..9a77324 100644
--- a/core/combo/HOST_linux-x86_64.mk
+++ b/core/combo/HOST_linux-x86_64.mk
@@ -23,6 +23,12 @@
HOST_CC := $(HOST_TOOLCHAIN_PREFIX)gcc
HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)g++
HOST_AR := $(HOST_TOOLCHAIN_PREFIX)ar
+HOST_READELF := $(HOST_TOOLCHAIN_PREFIX)readelf
+HOST_NM := $(HOST_TOOLCHAIN_PREFIX)nm
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_elf,$(1),$(2))
+endef
# gcc location for clang; to be updated when clang is updated
HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index 5f0f1d2..485e48c 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -63,6 +63,11 @@
$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld
$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf
$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip
+$(combo_2nd_arch_prefix)TARGET_NM := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)nm
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_elf,$(1),$(2))
+endef
$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk
index b213ea7..1eb3240 100644
--- a/core/combo/TARGET_linux-arm64.mk
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -63,6 +63,11 @@
TARGET_LD := $(TARGET_TOOLS_PREFIX)ld
TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf
TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip
+TARGET_NM := $(TARGET_TOOLS_PREFIX)nm
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_elf,$(1),$(2))
+endef
TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk
index 8e117eb..be05302 100644
--- a/core/combo/TARGET_linux-mips.mk
+++ b/core/combo/TARGET_linux-mips.mk
@@ -63,6 +63,11 @@
$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld
$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf
$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip
+$(combo_2nd_arch_prefix)TARGET_NM := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)nm
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_elf,$(1),$(2))
+endef
$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk
index 565083a..9704b6b 100644
--- a/core/combo/TARGET_linux-mips64.mk
+++ b/core/combo/TARGET_linux-mips64.mk
@@ -63,6 +63,11 @@
TARGET_LD := $(TARGET_TOOLS_PREFIX)ld
TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf
TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip
+TARGET_NM := $(TARGET_TOOLS_PREFIX)nm
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_elf,$(1),$(2))
+endef
TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 5fff641..c4cb0f8 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -56,6 +56,11 @@
$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld
$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf
$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip
+$(combo_2nd_arch_prefix)TARGET_NM := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)nm
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_elf,$(1),$(2))
+endef
ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),)
$(combo_2nd_arch_prefix)TARGET_LIBGCC := \
diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk
index cacfae1..b7ec50b 100644
--- a/core/combo/TARGET_linux-x86_64.mk
+++ b/core/combo/TARGET_linux-x86_64.mk
@@ -56,6 +56,11 @@
TARGET_LD := $(TARGET_TOOLS_PREFIX)ld
TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf
TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip
+TARGET_NM := $(TARGET_TOOLS_PREFIX)nm
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_elf,$(1),$(2))
+endef
ifneq ($(wildcard $(TARGET_CC)),)
TARGET_LIBGCC := \
diff --git a/core/config.mk b/core/config.mk
index ba2e7d5..49810ee 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -113,6 +113,16 @@
SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS))
hide := $(if $(SHOW_COMMANDS),,@)
+################################################################
+# Tools needed in product configuration makefiles.
+################################################################
+NORMALIZE_PATH := build/tools/normalize_path.py
+
+# $(1): the paths to be normalized
+define normalize-paths
+$(if $(1),$(shell $(NORMALIZE_PATH) $(1)))
+endef
+
# ###############################################################
# Set common values
# ###############################################################
@@ -271,6 +281,18 @@
endif
TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
+# Commands to generate .toc file common to ELF .so files.
+define _gen_toc_command_for_elf
+$(hide) ($($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) -d $(1) | grep SONAME || echo "No SONAME for $1") > $(2)
+$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)NM) -gD -f p $(1) | cut -f1-2 -d" " >> $(2)
+endef
+
+# Commands to generate .toc file from Darwin dynamic library.
+define _gen_toc_command_for_macho
+$(hide) otool -l $(1) | grep LC_ID_DYLIB -A 5 > $(2)
+$(hide) nm -gP $(1) | cut -f1-2 -d" " | grep -v U$$ >> $(2)
+endef
+
combo_target := HOST_
combo_2nd_arch_prefix :=
include $(BUILD_SYSTEM)/combo/select.mk
@@ -514,6 +536,9 @@
# dx is java behind a shell script; no .exe necessary.
DX := $(HOST_OUT_EXECUTABLES)/dx
ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX)
+ifndef TARGET_BUILD_APPS
+ZIPTIME := $(HOST_OUT_EXECUTABLES)/ziptime$(HOST_EXECUTABLE_SUFFIX)
+endif
# relocation packer
RELOCATION_PACKER := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/relocation_packer/relocation_packer
@@ -529,11 +554,13 @@
COLUMN:= column
+# We may not have the right JAVA_HOME/PATH set up yet when this is run from envsetup.sh.
+ifneq ($(CALLED_FROM_SETUP),true)
HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
ifneq ($(HOST_JDK_TOOLS_JAR),)
ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
-$(error Error: could not find jdk tools.jar, please check if your JDK was installed correctly)
+$(error Error: could not find jdk tools.jar at $(HOST_JDK_TOOLS_JAR), please check if your JDK was installed correctly)
endif
endif
@@ -542,6 +569,7 @@
ifneq ($(filter 64-Bit, $(shell java -version 2>&1)),)
HOST_JDK_IS_64BIT_VERSION := true
endif
+endif # CALLED_FROM_SETUP not true
# It's called md5 on Mac OS and md5sum on Linux
ifeq ($(HOST_OS),darwin)
@@ -550,8 +578,6 @@
MD5SUM:=md5sum
endif
-NORMALIZE_PATH := build/tools/normalize_path.py
-
APICHECK_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX)
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
index 7189338..df52e72 100644
--- a/core/config_sanitizers.mk
+++ b/core/config_sanitizers.mk
@@ -84,7 +84,7 @@
endif
ifneq ($(my_sanitize),)
- fsanitize_arg := $(subst $(space),$(comma),$(my_sanitize)),
+ fsanitize_arg := $(subst $(space),$(comma),$(my_sanitize))
my_cflags += -fsanitize=$(fsanitize_arg)
ifdef LOCAL_IS_HOST_MODULE
@@ -92,8 +92,10 @@
my_ldflags += -fsanitize=$(fsanitize_arg)
my_ldlibs += -lrt -ldl
else
- my_cflags += -fsanitize-undefined-trap-on-error
- my_cflags += -ftrap-function=abort
+ ifeq ($(filter address,$(my_sanitize)),)
+ my_cflags += -fsanitize-trap=all
+ my_cflags += -ftrap-function=abort
+ endif
my_shared_libraries += libdl
endif
endif
diff --git a/core/definitions.mk b/core/definitions.mk
index ecc7253..0089865 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1516,7 +1516,6 @@
$(transform-o-to-shared-lib-inner)
endef
-
###########################################################
## Commands for filtering a target executable or library
###########################################################
@@ -2094,13 +2093,13 @@
$(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\
$(call _add-jni-shared-libs-to-package-per-abi,$(abi),\
$(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES)))))
-$(hide) (cd $(dir $@) && zip -qr $(JNI_COMPRESS_FLAGS) $(notdir $@) lib)
+$(hide) (cd $(dir $@) && zip -qrX $(JNI_COMPRESS_FLAGS) $(notdir $@) lib)
$(hide) rm -rf $(dir $@)lib
endef
#TODO: update the manifest to point to the dex file
define add-dex-to-package
-$(hide) zip -qj $@ $(dir $(PRIVATE_DEX_FILE))classes*.dex
+$(hide) find $(dir $(PRIVATE_DEX_FILE)) -maxdepth 1 -name "classes*.dex" | sort | xargs zip -qjX $@
endef
# Add java resources added by the current module.
@@ -2116,7 +2115,7 @@
#
define add-carried-jack-resources
$(hide) if [ -d $(PRIVATE_JACK_INTERMEDIATES_DIR) ] ; then \
- find $(PRIVATE_JACK_INTERMEDIATES_DIR) -type f \
+ find $(PRIVATE_JACK_INTERMEDIATES_DIR) -type f | sort \
| sed -e "s?^$(PRIVATE_JACK_INTERMEDIATES_DIR)/? -C \"$(PRIVATE_JACK_INTERMEDIATES_DIR)\" \"?" -e "s/$$/\"/" \
> $(dir $@)jack_res_jar_flags; \
if [ -s $(dir $@)jack_res_jar_flags ] ; then \
@@ -2147,6 +2146,14 @@
$(hide) mv $@.aligned $@
endef
+# Remove dynamic timestamps from packages
+#
+ifndef TARGET_BUILD_APPS
+define remove-timestamps-from-package
+$(hide) $(ZIPTIME) $@
+endef
+endif
+
# Uncompress shared libraries embedded in an apk.
#
define uncompress-shared-libs
@@ -2154,7 +2161,7 @@
rm -rf $(dir $@)uncompressedlibs && mkdir $(dir $@)uncompressedlibs; \
unzip $@ $(PRIVATE_EMBEDDED_JNI_LIBS) -d $(dir $@)uncompressedlibs && \
zip -d $@ 'lib/*.so' && \
- ( cd $(dir $@)uncompressedlibs && zip -D -r -0 ../$(notdir $@) lib ) && \
+ ( cd $(dir $@)uncompressedlibs && find lib -type f | sort | zip -D -X -0 ../$(notdir $@) -@ ) && \
rm -rf $(dir $@)uncompressedlibs; \
fi
endef
@@ -2547,6 +2554,7 @@
# Include any vendor specific definitions.mk file
-include $(TOPDIR)vendor/*/build/core/definitions.mk
-include $(TOPDIR)device/*/build/core/definitions.mk
+-include $(TOPDIR)product/*/build/core/definitions.mk
# broken:
# $(foreach file,$^,$(if $(findstring,.a,$(suffix $file)),-l$(file),$(file)))
diff --git a/core/distdir.mk b/core/distdir.mk
index 24beddc..51ec46e 100644
--- a/core/distdir.mk
+++ b/core/distdir.mk
@@ -22,6 +22,11 @@
dist_goal := $(strip $(filter dist,$(MAKECMDGOALS)))
MAKECMDGOALS := $(strip $(filter-out dist,$(MAKECMDGOALS)))
+ifeq (,$(strip $(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))))
+# The commandline was something like "make dist" or "make dist showcommands".
+# Add a dependency on a real target.
+dist: $(DEFAULT_GOAL)
+endif
ifdef dist_goal
diff --git a/core/droiddoc.mk b/core/droiddoc.mk
index cc2a915..1e9de1c 100644
--- a/core/droiddoc.mk
+++ b/core/droiddoc.mk
@@ -171,7 +171,7 @@
javadoc \
-encoding UTF-8 \
\@$(PRIVATE_SRC_LIST_FILE) \
- -J-Xmx1280m \
+ -J-Xmx1600m \
-XDignore.symbol.file \
$(PRIVATE_PROFILING_OPTIONS) \
-quiet \
@@ -241,7 +241,7 @@
@echo Package docs: $@
@rm -f $@
@mkdir -p $(dir $@)
- $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_DOCS_DIR) && zip -rq $$F * )
+ $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_DOCS_DIR) && zip -rqX $$F * )
$(LOCAL_MODULE)-docs.zip : $(out_zip)
diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk
index 5b11724..d6f6cc9 100644
--- a/core/dynamic_binary.mk
+++ b/core/dynamic_binary.mk
@@ -44,7 +44,10 @@
relocation_packer_input := $(linked_module)
relocation_packer_output := $(intermediates)/PACKED/$(my_built_module_stem)
-my_pack_module_relocations := $(LOCAL_PACK_MODULE_RELOCATIONS)
+my_pack_module_relocations := false
+ifneq ($(DISABLE_RELOCATION_PACKER),true)
+ my_pack_module_relocations := $(LOCAL_PACK_MODULE_RELOCATIONS)
+endif
ifeq ($(my_pack_module_relocations),)
my_pack_module_relocations := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PACK_MODULE_RELOCATIONS)
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 199c6b7..050d445 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -141,8 +141,8 @@
board_config_mk := \
$(strip $(sort $(wildcard \
$(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \
- $(shell test -d device && find device -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
- $(shell test -d vendor && find vendor -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
+ $(shell test -d device && find -L device -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
+ $(shell test -d vendor && find -L vendor -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
)))
ifeq ($(board_config_mk),)
$(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
diff --git a/core/find-jdk-tools-jar.sh b/core/find-jdk-tools-jar.sh
index 0224829..ac0b3b6 100755
--- a/core/find-jdk-tools-jar.sh
+++ b/core/find-jdk-tools-jar.sh
@@ -16,5 +16,5 @@
LSLINE=$(ls -l "$JAVAC")
JAVAC=$(echo -n "$LSLINE" | sed -e "s/.* -> //")
done
- echo $JAVAC | sed -e "s:\(.*\)/bin/javac.*:\\1/lib/tools.jar:"
+ echo $JAVAC | sed -e 's:\(.*\)/javac$:\1/../lib/tools.jar:'
fi
diff --git a/core/goma.mk b/core/goma.mk
index ddd7d80..01a1d81 100644
--- a/core/goma.mk
+++ b/core/goma.mk
@@ -56,7 +56,11 @@
# gomacc can start goma client's daemon process automatically, but
# it is safer and faster to start up it beforehand. We run this as a
# background process so this won't slow down the build.
- $(shell $(goma_ctl) ensure_start &> /dev/null &)
+ # We use "ensure_start" command when the compiler_proxy is already
+ # running and uses GOMA_HERMETIC=error flag. The compiler_proxy will
+ # restart otherwise.
+ # TODO(hamaji): Remove this condition after http://b/25676777 is fixed.
+ $(shell ( if ( curl http://localhost:$$($(GOMA_CC) port)/flagz | grep GOMA_HERMETIC=error ); then cmd=ensure_start; else cmd=restart; fi; GOMA_HERMETIC=error $(goma_ctl) $${cmd} ) &> /dev/null &)
goma_ctl :=
goma_dir :=
diff --git a/core/java_library.mk b/core/java_library.mk
index 5a2d19b..dc6186f 100644
--- a/core/java_library.mk
+++ b/core/java_library.mk
@@ -81,7 +81,7 @@
$(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex)
$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
$(common_javalib.jar): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
-$(common_javalib.jar) : $(built_dex) $(java_resource_sources)
+$(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME)
@echo "target Jar: $(PRIVATE_MODULE) ($@)"
ifdef LOCAL_JACK_ENABLED
$(create-empty-package)
@@ -92,6 +92,7 @@
ifdef LOCAL_JACK_ENABLED
$(add-carried-jack-resources)
endif
+ $(remove-timestamps-from-package)
ifdef LOCAL_DEX_PREOPT
ifneq ($(dexpreopt_boot_jar_module),) # boot jar
diff --git a/core/main.mk b/core/main.mk
index 15b3c27..2bd3163 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -80,7 +80,8 @@
vendorimage-nodeps \
ramdisk-nodeps \
bootimage-nodeps \
- recoveryimage-nodeps
+ recoveryimage-nodeps \
+ product-graph dump-products
ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
dont_bother := true
@@ -315,8 +316,8 @@
#
# -----------------------------------------------------------------
# Jack version configuration
-include $(TOPDIR)prebuilts/sdk/tools/jack_versions.mk
-include $(TOPDIR)prebuilts/sdk/tools/jack_for_module.mk
+-include $(TOPDIR)prebuilts/sdk/tools/jack_versions.mk
+-include $(TOPDIR)prebuilts/sdk/tools/jack_for_module.mk
# -----------------------------------------------------------------
###
@@ -332,7 +333,7 @@
# Add build properties for ART. These define system properties used by installd
# to pass flags to dex2oat.
-ADDITIONAL_BUILD_PROPERTIES += persist.sys.dalvik.vm.lib.2=libart
+ADDITIONAL_BUILD_PROPERTIES += persist.sys.dalvik.vm.lib.2=libart.so
ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).variant=$(DEX2OAT_TARGET_CPU_VARIANT)
ifneq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
@@ -425,7 +426,7 @@
sdk_repo_goal := $(strip $(filter sdk_repo,$(MAKECMDGOALS)))
MAKECMDGOALS := $(strip $(filter-out sdk_repo,$(MAKECMDGOALS)))
-ifneq ($(words $(filter-out $(INTERNAL_MODIFIER_TARGETS) checkbuild emulator_tests target-files-package,$(MAKECMDGOALS))),1)
+ifneq ($(words $(sort $(filter-out $(INTERNAL_MODIFIER_TARGETS) checkbuild emulator_tests target-files-package,$(MAKECMDGOALS)))),1)
$(error The 'sdk' target may not be specified with any other targets)
endif
diff --git a/core/ninja.mk b/core/ninja.mk
index 81298e5..862ed80 100644
--- a/core/ninja.mk
+++ b/core/ninja.mk
@@ -1,12 +1,18 @@
KATI ?= $(HOST_OUT_EXECUTABLES)/ckati
MAKEPARALLEL ?= $(HOST_OUT_EXECUTABLES)/makeparallel
+NINJA ?= prebuilts/ninja/$(HOST_PREBUILT_TAG)/ninja
KATI_OUTPUT_PATTERNS := $(OUT_DIR)/build%.ninja $(OUT_DIR)/ninja%.sh
-NINJA_GOALS := fastincremental generateonly droid showcommands
-# A list of goals which affect parsing of make.
+
+# Modifier goals we don't need to pass to Ninja.
+NINJA_EXCLUDE_GOALS := showcommands all dist
+.PHONY : $(NINJA_EXCLUDE_GOALS)
+
+# A list of goals which affect parsing of makefiles and we need to pass to Kati.
PARSE_TIME_MAKE_GOALS := \
$(PARSE_TIME_MAKE_GOALS) \
$(dont_bother_goals) \
+ all \
APP-% \
DUMP_% \
ECLIPSE-% \
@@ -52,17 +58,21 @@
-include vendor/google/build/ninja_config.mk
-ANDROID_TARGETS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(NINJA_GOALS),$(ORIGINAL_MAKECMDGOALS))
-EXTRA_TARGETS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(NINJA_GOALS),$(filter-out $(ORIGINAL_MAKECMDGOALS),$(MAKECMDGOALS)))
-KATI_TARGETS := $(filter $(PARSE_TIME_MAKE_GOALS),$(ANDROID_TARGETS))
+# Any Android goals that need to be built.
+ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(KATI) $(MAKEPARALLEL),\
+ $(sort $(ORIGINAL_MAKECMDGOALS) $(MAKECMDGOALS)))
+# Goals we need to pass to Ninja.
+NINJA_GOALS := $(filter-out $(NINJA_EXCLUDE_GOALS), $(ANDROID_GOALS))
+# Goals we need to pass to Kati.
+KATI_GOALS := $(filter $(PARSE_TIME_MAKE_GOALS), $(ANDROID_GOALS))
define replace_space_and_slash
$(subst /,_,$(subst $(space),_,$(sort $1)))
endef
KATI_NINJA_SUFFIX := -$(TARGET_PRODUCT)
-ifneq ($(KATI_TARGETS),)
-KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-$(call replace_space_and_slash,$(KATI_TARGETS))
+ifneq ($(KATI_GOALS),)
+KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-$(call replace_space_and_slash,$(KATI_GOALS))
endif
ifneq ($(ONE_SHOT_MAKEFILE),)
KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-mmm-$(call replace_space_and_slash,$(ONE_SHOT_MAKEFILE))
@@ -72,17 +82,15 @@
endif
my_checksum_suffix :=
-ifneq ($(KATI_NINJA_SUFFIX),)
my_ninja_suffix_too_long := $(filter 1, $(shell v='$(KATI_NINJA_SUFFIX)' && echo $$(($${$(pound)v} > 64))))
ifneq ($(my_ninja_suffix_too_long),)
# Replace the suffix with a checksum if it gets too long.
my_checksum_suffix := $(KATI_NINJA_SUFFIX)
KATI_NINJA_SUFFIX := -$(word 1, $(shell echo $(my_checksum_suffix) | $(MD5SUM)))
endif
-endif
KATI_BUILD_NINJA := $(OUT_DIR)/build$(KATI_NINJA_SUFFIX).ninja
-KATI_NINJA_SH := $(OUT_DIR)/ninja$(KATI_NINJA_SUFFIX).sh
+KATI_ENV_SH := $(OUT_DIR)/env$(KATI_NINJA_SUFFIX).sh
# Write out a file mapping checksum to the real suffix.
ifneq ($(my_checksum_suffix),)
@@ -91,16 +99,12 @@
echo $(my_checksum_suffix) > $(my_ninja_suffix_file))
endif
-KATI_OUTPUTS := $(KATI_BUILD_NINJA) $(KATI_NINJA_SH)
-
ifeq (,$(NINJA_STATUS))
NINJA_STATUS := [%p %s/%t]$(space)
endif
ifneq (,$(filter showcommands,$(ORIGINAL_MAKECMDGOALS)))
NINJA_ARGS += "-v"
-PHONY: showcommands
-showcommands: droid
endif
ifdef USE_GOMA
@@ -114,29 +118,21 @@
NINJA_MAKEPARALLEL := $(MAKEPARALLEL) --ninja
endif
-ifeq (,$(filter generateonly,$(ORIGINAL_MAKECMDGOALS)))
-fastincremental droid $(ANDROID_TARGETS) $(EXTRA_TARGETS): ninja.intermediate
+$(sort $(DEFAULT_GOAL) $(ANDROID_GOALS)) : ninja_wrapper
@#empty
-.INTERMEDIATE: ninja.intermediate
-ninja.intermediate: $(KATI_OUTPUTS) $(MAKEPARALLEL)
+.PHONY: ninja_wrapper
+ninja_wrapper: $(KATI_BUILD_NINJA) $(MAKEPARALLEL)
@echo Starting build with ninja
- +$(hide) PATH=prebuilts/ninja/$(HOST_PREBUILT_TAG)/:$$PATH NINJA_STATUS="$(NINJA_STATUS)" $(NINJA_MAKEPARALLEL) $(KATI_NINJA_SH) $(filter-out dist,$(ANDROID_TARGETS)) -C $(TOP) $(NINJA_ARGS)
-else
-generateonly droid $(ANDROID_TARGETS) $(EXTRA_TARGETS): $(KATI_OUTPUTS)
- @#empty
+ +$(hide) export NINJA_STATUS="$(NINJA_STATUS)" && source $(KATI_ENV_SH) && $(NINJA_MAKEPARALLEL) $(NINJA) $(NINJA_GOALS) -C $(TOP) -f $(KATI_BUILD_NINJA) $(NINJA_ARGS)
+
+KATI_FIND_EMULATOR := --use_find_emulator
+ifeq ($(KATI_EMULATE_FIND),false)
+ KATI_FIND_EMULATOR :=
endif
-
-ifeq (,$(filter fastincremental,$(ORIGINAL_MAKECMDGOALS)))
-KATI_FORCE := FORCE
-endif
-
-$(KATI_OUTPUTS): kati.intermediate $(KATI_FORCE)
-
-.INTERMEDIATE: kati.intermediate
-kati.intermediate: $(KATI) $(MAKEPARALLEL)
+$(KATI_BUILD_NINJA): $(KATI) $(MAKEPARALLEL) FORCE
@echo Running kati to generate build$(KATI_NINJA_SUFFIX).ninja...
- +$(hide) $(KATI_MAKEPARALLEL) $(KATI) --ninja --ninja_dir=$(OUT_DIR) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_dirty=$(OUT_DIR)/% --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo --use_find_emulator -f build/core/main.mk $(KATI_TARGETS) --gen_all_targets BUILDING_WITH_NINJA=true
+ +$(hide) $(KATI_MAKEPARALLEL) $(KATI) --ninja --ninja_dir=$(OUT_DIR) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_dirty=$(OUT_DIR)/% --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo $(KATI_FIND_EMULATOR) -f build/core/main.mk $(KATI_GOALS) --gen_all_targets BUILDING_WITH_NINJA=true
KATI_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CFLAGS) $(CLANG_HOST_GLOBAL_CPPFLAGS)
KATI_LD := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_LDFLAGS)
diff --git a/core/package_internal.mk b/core/package_internal.mk
index a2cbe31..cb77e76 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -176,7 +176,7 @@
ifeq (true,$(EMMA_INSTRUMENT))
ifndef LOCAL_EMMA_INSTRUMENT
# No emma for test apks.
-ifeq (,$(filer tests,$(LOCAL_MODULE_TAGS))$(LOCAL_INSTRUMENTATION_FOR))
+ifeq (,$(LOCAL_INSTRUMENTATION_FOR))
LOCAL_EMMA_INSTRUMENT := true
endif # No test apk
endif # LOCAL_EMMA_INSTRUMENT is not set
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 505bd45..da76eb9 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -48,6 +48,10 @@
# Do not pack relocations by default
LOCAL_PACK_MODULE_RELOCATIONS := false
endif
+
+ ifeq ($(DISABLE_RELOCATION_PACKER),true)
+ LOCAL_PACK_MODULE_RELOCATIONS := false
+ endif
endif
ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
@@ -271,8 +275,13 @@
$(built_module) : $(my_prebuilt_src_file)
$(transform-prebuilt-to-target-strip-comments)
else
+ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
$(built_module) : $(my_prebuilt_src_file) | $(ACP)
$(transform-prebuilt-to-target)
+else
+$(built_module) : $(my_prebuilt_src_file)
+ $(copy-file-to-target-with-cp)
+endif
endif
endif # LOCAL_MODULE_CLASS != APPS
diff --git a/core/tasks/product-graph.mk b/core/product-graph.mk
similarity index 98%
rename from core/tasks/product-graph.mk
rename to core/product-graph.mk
index db2cf71..36e9037 100644
--- a/core/tasks/product-graph.mk
+++ b/core/product-graph.mk
@@ -34,7 +34,7 @@
endef
-this_makefile := build/core/tasks/product-graph.mk
+this_makefile := build/core/product-graph.mk
products_svg := $(OUT_DIR)/products.svg
products_pdf := $(OUT_DIR)/products.pdf
diff --git a/core/product.mk b/core/product.mk
index f242e82..4d35704 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -28,8 +28,9 @@
# $(call ) isn't necessary.
#
define _find-android-products-files
-$(sort $(shell test -d device && find device -maxdepth 6 -name AndroidProducts.mk)) \
- $(sort $(shell test -d vendor && find vendor -maxdepth 6 -name AndroidProducts.mk)) \
+$(sort $(shell test -d device && find -L device -maxdepth 6 -name AndroidProducts.mk)) \
+ $(sort $(shell test -d vendor && find -L vendor -maxdepth 6 -name AndroidProducts.mk)) \
+ $(sort $(shell test -d product && find -L product -maxdepth 6 -name AndroidProducts.mk)) \
$(SRC_TARGET_DIR)/product/AndroidProducts.mk
endef
@@ -105,6 +106,7 @@
PRODUCT_SYSTEM_PROPERTY_BLACKLIST \
PRODUCT_SYSTEM_SERVER_JARS \
PRODUCT_VBOOT_SIGNING_KEY \
+ PRODUCT_VBOOT_SIGNING_SUBKEY \
PRODUCT_VERITY_SIGNING_KEY \
PRODUCT_SYSTEM_VERITY_PARTITION \
PRODUCT_VENDOR_VERITY_PARTITION \
@@ -133,11 +135,14 @@
# 3. Records that we've visited this node, in ALL_PRODUCTS
#
define inherit-product
+ $(if $(findstring ../,$(1)),\
+ $(eval np := $(call normalize-paths,$(1))),\
+ $(eval np := $(strip $(1))))\
$(foreach v,$(_product_var_list), \
- $(eval $(v) := $($(v)) $(INHERIT_TAG)$(strip $(1)))) \
+ $(eval $(v) := $($(v)) $(INHERIT_TAG)$(np))) \
$(eval inherit_var := \
PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \
- $(eval $(inherit_var) := $(sort $($(inherit_var)) $(strip $(1)))) \
+ $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \
$(eval inherit_var:=) \
$(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack))))
endef
diff --git a/core/product_config.mk b/core/product_config.mk
index 5240ae7..ad3b518 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -213,7 +213,19 @@
current_product_makefile := $(strip $(current_product_makefile))
all_product_makefiles := $(strip $(all_product_makefiles))
-ifneq (,$(filter product-graph dump-products, $(MAKECMDGOALS)))
+load_all_product_makefiles :=
+ifneq (,$(filter product-graph, $(MAKECMDGOALS)))
+ifeq ($(ANDROID_PRODUCT_GRAPH),--all)
+load_all_product_makefiles := true
+endif
+endif
+ifneq (,$(filter dump-products,$(MAKECMDGOALS)))
+ifeq ($(ANDROID_DUMP_PRODUCTS),all)
+load_all_product_makefiles := true
+endif
+endif
+
+ifeq ($(load_all_product_makefiles),true)
# Import all product makefiles.
$(call import-products, $(all_product_makefiles))
else
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
index 56a7f6f..6288ce8 100644
--- a/core/tasks/cts.mk
+++ b/core/tasks/cts.mk
@@ -387,9 +387,8 @@
$(INTERNAL_CTS_TARGET): TMP_DIR := $(cts_dir)/temp
$(INTERNAL_CTS_TARGET): $(cts_dir)/all_cts_files_stamp $(DEFAULT_TEST_PLAN)
$(hide) echo "Package CTS: $@"
- $(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME)
+ $(hide) cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME)
.PHONY: cts
cts: $(INTERNAL_CTS_TARGET) adb
$(call dist-for-goals,cts,$(INTERNAL_CTS_TARGET))
-
diff --git a/core/tasks/sdk-addon.mk b/core/tasks/sdk-addon.mk
index 5ac9b7d..362b229 100644
--- a/core/tasks/sdk-addon.mk
+++ b/core/tasks/sdk-addon.mk
@@ -111,13 +111,13 @@
$(ACP) -r $$d $(PRIVATE_STAGING_DIR)/docs ;\
done
$(hide) mkdir -p $(dir $@)
- $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rq $$F $(notdir $(PRIVATE_STAGING_DIR)) )
+ $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rqX $$F $(notdir $(PRIVATE_STAGING_DIR)) )
$(full_target_img): PRIVATE_STAGING_DIR := $(call append-path,$(staging),$(addon_dir_img))/images/$(TARGET_CPU_ABI)
$(full_target_img): $(full_target) $(addon_img_source_prop)
@echo Packaging SDK Addon System-Image: $@
$(hide) mkdir -p $(dir $@)
- $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rq $$F $(notdir $(PRIVATE_STAGING_DIR)) )
+ $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rqX $$F $(notdir $(PRIVATE_STAGING_DIR)) )
.PHONY: sdk_addon
diff --git a/core/tasks/tools/package-modules.mk b/core/tasks/tools/package-modules.mk
index a70e644..24a7608 100644
--- a/core/tasks/tools/package-modules.mk
+++ b/core/tasks/tools/package-modules.mk
@@ -59,4 +59,4 @@
$(call copy-tests-in-batch,$(wordlist 1201,9999,$(PRIVATE_COPY_PAIRS)))
$(hide) $(foreach f, $(PRIVATE_PICKUP_FILES),\
cp -RfL $(f) $(dir $@);)
- $(hide) cd $(dir $@) && zip -rq $(notdir $@) *
+ $(hide) cd $(dir $@) && zip -rqX $(notdir $@) *
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 9674154..dcc1e18 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -43,7 +43,7 @@
# which is the version that we reveal to the end user.
# Update this value when the platform version changes (rather
# than overriding it somewhere else). Can be an arbitrary string.
- PLATFORM_VERSION := 6.0.60
+ PLATFORM_VERSION := 6.0
endif
ifeq "" "$(PLATFORM_SDK_VERSION)"
@@ -104,7 +104,7 @@
# Can be an arbitrary string, but must be a single word.
#
# If there is no $PLATFORM_SECURITY_PATCH set, keep it empty.
- PLATFORM_SECURITY_PATCH := 2015-09-01
+ PLATFORM_SECURITY_PATCH := 2015-10-01
endif
ifeq "" "$(PLATFORM_BASE_OS)"
diff --git a/envsetup.sh b/envsetup.sh
index e569024..f266f1a 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -1369,14 +1369,20 @@
return
fi
T=$(gettop)
- if [[ ! -f $T/filelist ]]; then
+ if [ ! "$OUT_DIR" = "" ]; then
+ mkdir -p $OUT_DIR
+ FILELIST=$OUT_DIR/filelist
+ else
+ FILELIST=$T/filelist
+ fi
+ if [[ ! -f $FILELIST ]]; then
echo -n "Creating index..."
- (\cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > filelist)
+ (\cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > $FILELIST)
echo " Done"
echo ""
fi
local lines
- lines=($(\grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
+ lines=($(\grep "$1" $FILELIST | sed -e 's/\/[^/]*$//' | sort | uniq))
if [[ ${#lines[@]} = 0 ]]; then
echo "Not found"
return
@@ -1521,7 +1527,8 @@
echo ""
echo "ALL DATA ON THE DEVICE WILL BE IRREVOCABLY ERASED."
echo ""
- read -p "Are you sure you want to do this (yes/no)? "
+ echo -n "Are you sure you want to do this (yes/no)? "
+ read
if [[ "${REPLY}" != "yes" ]] ; then
echo "Not taking any action. Exiting." >&2
return 1
@@ -1542,7 +1549,8 @@
# Execute the contents of any vendorsetup.sh files we can find.
for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \
- `test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort`
+ `test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \
+ `test -d product && find -L product -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort`
do
echo "including $f"
. $f
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index 4e5504e..b1cefca 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -81,3 +81,5 @@
# include an expanded selection of fonts for the SDK.
EXTENDED_FONT_FOOTPRINT := true
endif
+
+USE_CLANG_PLATFORM_BUILD := true
diff --git a/target/board/generic/sepolicy/goldfish_setup.te b/target/board/generic/sepolicy/goldfish_setup.te
index 85d5c8c..b472d2a 100644
--- a/target/board/generic/sepolicy/goldfish_setup.te
+++ b/target/board/generic/sepolicy/goldfish_setup.te
@@ -1,5 +1,5 @@
# goldfish-setup service: runs init.goldfish.sh script
-type goldfish_setup, domain;
+type goldfish_setup, domain, domain_deprecated;
type goldfish_setup_exec, exec_type, file_type;
init_daemon_domain(goldfish_setup)
diff --git a/target/board/generic/sepolicy/property_contexts b/target/board/generic/sepolicy/property_contexts
index f4653c0..152f0c8 100644
--- a/target/board/generic/sepolicy/property_contexts
+++ b/target/board/generic/sepolicy/property_contexts
@@ -1,3 +1,5 @@
qemu. u:object_r:qemu_prop:s0
+emu. u:object_r:qemu_prop:s0
+emulator. u:object_r:qemu_prop:s0
radio.noril u:object_r:radio_noril_prop:s0
opengles. u:object_r:opengles_prop:s0
diff --git a/target/board/generic/sepolicy/qemu_props.te b/target/board/generic/sepolicy/qemu_props.te
index 60a09a5..6768ce7 100644
--- a/target/board/generic/sepolicy/qemu_props.te
+++ b/target/board/generic/sepolicy/qemu_props.te
@@ -1,5 +1,5 @@
# qemu-props service: Sets system properties on boot.
-type qemu_props, domain;
+type qemu_props, domain, domain_deprecated;
type qemu_props_exec, exec_type, file_type;
init_daemon_domain(qemu_props)
diff --git a/target/board/generic/sepolicy/qemud.te b/target/board/generic/sepolicy/qemud.te
index eee21c4..797cf5c 100644
--- a/target/board/generic/sepolicy/qemud.te
+++ b/target/board/generic/sepolicy/qemud.te
@@ -1,5 +1,5 @@
# qemu support daemon
-type qemud, domain;
+type qemud, domain, domain_deprecated;
type qemud_exec, exec_type, file_type;
init_daemon_domain(qemud)
diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk
index b757da1..40dd184 100644
--- a/target/board/generic_arm64/BoardConfig.mk
+++ b/target/board/generic_arm64/BoardConfig.mk
@@ -84,3 +84,5 @@
TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
+
+USE_CLANG_PLATFORM_BUILD := true
diff --git a/target/product/aosp_arm.mk b/target/product/aosp_arm.mk
index 86b715c..781cae6 100644
--- a/target/product/aosp_arm.mk
+++ b/target/product/aosp_arm.mk
@@ -13,6 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-$(call inherit-product, $(SRC_TARGET_DIR)/product/full.mk)
+include $(SRC_TARGET_DIR)/product/full.mk
PRODUCT_NAME := aosp_arm
diff --git a/target/product/aosp_mips.mk b/target/product/aosp_mips.mk
index ceeb433..a76b93a 100644
--- a/target/product/aosp_mips.mk
+++ b/target/product/aosp_mips.mk
@@ -13,6 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-$(call inherit-product, $(SRC_TARGET_DIR)/product/full_mips.mk)
+include $(SRC_TARGET_DIR)/product/full_mips.mk
PRODUCT_NAME := aosp_mips
diff --git a/target/product/aosp_x86.mk b/target/product/aosp_x86.mk
index 3e9b018..cba43c4 100644
--- a/target/product/aosp_x86.mk
+++ b/target/product/aosp_x86.mk
@@ -13,6 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-$(call inherit-product, $(SRC_TARGET_DIR)/product/full_x86.mk)
+include $(SRC_TARGET_DIR)/product/full_x86.mk
PRODUCT_NAME := aosp_x86
diff --git a/target/product/base.mk b/target/product/base.mk
index 1699156..4c49e86 100644
--- a/target/product/base.mk
+++ b/target/product/base.mk
@@ -111,6 +111,7 @@
run-as \
schedtest \
sdcard \
+ secdiscard \
services \
settings \
sgdisk \
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
index aac931d..0f92a1c 100644
--- a/target/product/embedded.mk
+++ b/target/product/embedded.mk
@@ -89,5 +89,6 @@
PRODUCT_COPY_FILES += \
system/core/rootdir/init.usb.rc:root/init.usb.rc \
+ system/core/rootdir/init.usb.configfs.rc:root/init.usb.configfs.rc \
system/core/rootdir/ueventd.rc:root/ueventd.rc \
system/core/rootdir/etc/hosts:system/etc/hosts
diff --git a/target/product/emulator.mk b/target/product/emulator.mk
index 72b8340..acc7a98 100644
--- a/target/product/emulator.mk
+++ b/target/product/emulator.mk
@@ -51,6 +51,7 @@
sensors.ranchu
PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml \
device/generic/goldfish/fstab.goldfish:root/fstab.goldfish \
device/generic/goldfish/init.goldfish.rc:root/init.goldfish.rc \
device/generic/goldfish/init.goldfish.sh:system/etc/init.goldfish.sh \
diff --git a/target/product/vboot.mk b/target/product/vboot.mk
index e4b1144..48a4883 100644
--- a/target/product/vboot.mk
+++ b/target/product/vboot.mk
@@ -22,3 +22,4 @@
# We expect this file to exist with the suffixes ".vbprivk" and ".vbpupk".
# TODO: find a proper location for this
PRODUCT_VBOOT_SIGNING_KEY := external/vboot_reference/tests/devkeys/kernel_data_key
+PRODUCT_VBOOT_SIGNING_SUBKEY := external/vboot_reference/tests/devkeys/kernel_subkey
diff --git a/tools/check_prereq/check_prereq.c b/tools/check_prereq/check_prereq.c
deleted file mode 100644
index d7b8918..0000000
--- a/tools/check_prereq/check_prereq.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source 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.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/system_properties.h>
-#include <cutils/properties.h>
-
-// Compare the timestamp of the new build (passed on the command line)
-// against the current value of ro.build.date.utc. Exit successfully
-// if the new build is newer than the current build (or if the
-// timestamps are the same).
-int main(int argc, char** argv) {
- if (argc != 2) {
- usage:
- fprintf(stderr, "usage: %s <timestamp>\n", argv[0]);
- return 2;
- }
-
- char value[PROPERTY_VALUE_MAX];
- char* default_value = "0";
-
- property_get("ro.build.date.utc", value, default_value);
-
- long current = strtol(value, NULL, 10);
- char* end;
- long install = strtol(argv[1], &end, 10);
-
- printf("current build time: [%ld] new build time: [%ld]\n",
- current, install);
-
- return (*end == 0 && current > 0 && install >= current) ? 0 : 1;
-}
diff --git a/tools/droiddoc/templates-sac/assets/css/default.css b/tools/droiddoc/templates-sac/assets/css/default.css
index 0ee8bc2..c349c89 100644
--- a/tools/droiddoc/templates-sac/assets/css/default.css
+++ b/tools/droiddoc/templates-sac/assets/css/default.css
@@ -1511,7 +1511,7 @@
.devices a.selected {
color: #F80;
}
-.accessories a.selected {
+.security a.selected {
color: #9C0;
}
.compatibility a.selected {
diff --git a/tools/droiddoc/templates-sac/assets/js/docs.js b/tools/droiddoc/templates-sac/assets/js/docs.js
index d3a9223..0c93780 100644
--- a/tools/droiddoc/templates-sac/assets/js/docs.js
+++ b/tools/droiddoc/templates-sac/assets/js/docs.js
@@ -1871,9 +1871,9 @@
devicesSearcher.setUserDefinedLabel("Devices");
devicesSearcher.setSiteRestriction("http://source.android.com/devices/");
- accessoriesSearcher = new google.search.WebSearch();
- accessoriesSearcher.setUserDefinedLabel("Accessories");
- accessoriesSearcher.setSiteRestriction("http://source.android.com/accessories/");
+ securitySearcher = new google.search.WebSearch();
+ securitySearcher.setUserDefinedLabel("Security");
+ securitySearcher.setSiteRestriction("http://source.android.com/security/");
compatibilitySearcher = new google.search.WebSearch();
compatibilitySearcher.setUserDefinedLabel("Compatibility");
@@ -1883,7 +1883,7 @@
searchControl.addSearcher(sacSiteSearcher, searchOptions);
searchControl.addSearcher(sourceSearcher, searchOptions);
searchControl.addSearcher(devicesSearcher, searchOptions);
- searchControl.addSearcher(accessoriesSearcher, searchOptions);
+ searchControl.addSearcher(securitySearcher, searchOptions);
searchControl.addSearcher(compatibilitySearcher, searchOptions);
diff --git a/tools/droiddoc/templates-sac/components/masthead.cs b/tools/droiddoc/templates-sac/components/masthead.cs
index a8618c0..ee2582f 100644
--- a/tools/droiddoc/templates-sac/components/masthead.cs
+++ b/tools/droiddoc/templates-sac/components/masthead.cs
@@ -255,7 +255,7 @@
<a href="<?cs var:toroot ?>index.html">
<img src="<?cs var:toroot ?>assets/images/sac_logo.png"
srcset="<?cs var:toroot ?>assets/images/sac_logo@2x.png 2x"
- width="123" height="25" alt="Android Developers" />
+ width="123" height="25" alt="Android Open Source Project" />
</a>
</div>
<ul class="nav-x col-9">
@@ -266,9 +266,9 @@
<li class="devices"><a href="<?cs var:toroot ?>devices/index.html" <?cs
if:devices ?>class="selected"<?cs /if ?>
>Devices</a></li>
- <li class="accessories"><a href="<?cs var:toroot ?>accessories/index.html" <?cs
- if:accessories ?>class="selected"<?cs /if ?>
- >Accessories</a></li>
+ <li class="security"><a href="<?cs var:toroot ?>security/index.html" <?cs
+ if:security ?>class="selected"<?cs /if ?>
+ >Security</a></li>
<li class="compatibility last"><a href="<?cs var:toroot ?>compatibility/index.html" <?cs
if:compatibility ?>class="selected"<?cs /if ?>
>Compatibility</a></li>
diff --git a/tools/droiddoc/templates-sac/customizations.cs b/tools/droiddoc/templates-sac/customizations.cs
index e489b63..1120e70 100644
--- a/tools/droiddoc/templates-sac/customizations.cs
+++ b/tools/droiddoc/templates-sac/customizations.cs
@@ -382,8 +382,8 @@
<?cs call:compatibility_nav() ?>
<?cs elif:source ?>
<?cs call:source_nav() ?>
- <?cs elif:accessories ?>
- <?cs call:accessories_nav() ?>
+ <?cs elif:security ?>
+ <?cs call:security_nav() ?>
<?cs elif:reference ?>
<?cs call:default_left_nav() ?>
<?cs /if ?>
@@ -450,14 +450,14 @@
<?cs /def ?>
<?cs
-def:accessories_nav() ?>
+def:security_nav() ?>
<div class="wrap clearfix" id="body-content">
<div class="col-4" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
<div id="devdoc-nav" class="scroll-pane">
<a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
<?cs
- include:"../../../../docs/source.android.com/src/accessories/accessories_toc.cs" ?>
+ include:"../../../../docs/source.android.com/src/security/security_toc.cs" ?>
</div>
</div> <!-- end side-nav -->
diff --git a/tools/droiddoc/templates-sdk/sdkpage.cs b/tools/droiddoc/templates-sdk/sdkpage.cs
index 013de59..3a3a9a3 100644
--- a/tools/droiddoc/templates-sdk/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk/sdkpage.cs
@@ -342,7 +342,7 @@
<tr>
<td rowspan="3">Windows</td>
<td>
- <a onclick="return onDownload(this)" id="win-bundle"
+ <a onclick="return onDownload(this,false,true)" id="win-bundle"
href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.win_bundle_exe_download ?>"
><?cs var:studio.win_bundle_exe_download ?></a><br>(Recommended)
</td>
@@ -353,7 +353,7 @@
<tr>
<!-- blank TD from Windows rowspan -->
<td>
- <a onclick="return onDownload(this)"
+ <a onclick="return onDownload(this,false,true)"
href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.win_notools_exe_download ?>"
><?cs var:studio.win_notools_exe_download ?></a><br>(No SDK tools included)
</td>
@@ -364,7 +364,7 @@
<tr>
<!-- blank TD from Windows rowspan -->
<td>
- <a onclick="return onDownload(this)"
+ <a onclick="return onDownload(this,false,true)"
href="https://dl.google.com/dl/android/studio/ide-zips/<?cs var:studio.version ?>/<?cs var:studio.win_bundle_download ?>"
><?cs var:studio.win_bundle_download ?></a>
</td>
@@ -375,7 +375,7 @@
<tr>
<td><nobr>Mac OS X</nobr></td>
<td>
- <a onclick="return onDownload(this)" id="mac-bundle"
+ <a onclick="return onDownload(this,false,true)" id="mac-bundle"
href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.mac_bundle_download ?>"
><?cs var:studio.mac_bundle_download ?></a>
</td>
@@ -386,7 +386,7 @@
<tr>
<td>Linux</td>
<td>
- <a onclick="return onDownload(this)" id="linux-bundle"
+ <a onclick="return onDownload(this,false,true)" id="linux-bundle"
href="https://dl.google.com/dl/android/studio/ide-zips/<?cs var:studio.version ?>/<?cs var:studio.linux_bundle_download ?>"
><?cs var:studio.linux_bundle_download ?></a>
</td>
@@ -450,7 +450,11 @@
}
$("#downloadForRealz").attr('bundle', bundle);
- $("a#downloadForRealz").attr("name", $(link).attr('href'));
+ if (bundle && !button) {
+ $("a#downloadForRealz").attr("name", "#" + $(link).attr('id'));
+ } else {
+ $("a#downloadForRealz").attr("name", $(link).attr('href'));
+ }
$("#tos").show();
$("#landing").hide();
diff --git a/tools/generate-notice-files.py b/tools/generate-notice-files.py
index 4571b70..5b13bf5 100755
--- a/tools/generate-notice-files.py
+++ b/tools/generate-notice-files.py
@@ -99,7 +99,7 @@
# most browsers, but href's to table row ids do)
id_table = {}
id_count = 0
- for value in file_hash.values():
+ for value in file_hash:
for filename in value:
id_table[filename] = id_count
id_count += 1
@@ -116,7 +116,7 @@
print >> output_file, "<ul>"
# Flatten the list of lists into a single list of filenames
- sorted_filenames = sorted(itertools.chain.from_iterable(file_hash.values()))
+ sorted_filenames = sorted(itertools.chain.from_iterable(file_hash))
# Print out a nice table of contents
for filename in sorted_filenames:
@@ -127,11 +127,11 @@
print >> output_file, "</div><!-- table of contents -->"
# Output the individual notice file lists
print >>output_file, '<table cellpadding="0" cellspacing="0" border="0">'
- for value in file_hash.values():
+ for value in file_hash:
print >> output_file, '<tr id="id%d"><td class="same-license">' % id_table.get(value[0])
print >> output_file, '<div class="label">Notices for file(s):</div>'
print >> output_file, '<div class="file-list">'
- for filename in sorted(value):
+ for filename in value:
print >> output_file, "%s <br/>" % (SRC_DIR_STRIP_RE.sub(r"\1", filename))
print >> output_file, "</div><!-- file-list -->"
print >> output_file
@@ -154,10 +154,10 @@
SRC_DIR_STRIP_RE = re.compile(input_dir + "(/.*).txt")
output_file = open(output_filename, "wb")
print >> output_file, file_title
- for value in file_hash.values():
+ for value in file_hash:
print >> output_file, "============================================================"
print >> output_file, "Notices for file(s):"
- for filename in sorted(value):
+ for filename in value:
print >> output_file, SRC_DIR_STRIP_RE.sub(r"\1", filename)
print >> output_file, "------------------------------------------------------------"
print >> output_file, open(value[0]).read()
@@ -178,11 +178,12 @@
file_md5sum = md5sum(filename)
files_with_same_hash[file_md5sum].append(filename)
+ filesets = [sorted(files_with_same_hash[md5]) for md5 in sorted(files_with_same_hash.keys())]
print "Combining NOTICE files into HTML"
- combine_notice_files_html(files_with_same_hash, input_dir, html_output_file)
+ combine_notice_files_html(filesets, input_dir, html_output_file)
print "Combining NOTICE files into text"
- combine_notice_files_text(files_with_same_hash, input_dir, txt_output_file, file_title)
+ combine_notice_files_text(filesets, input_dir, txt_output_file, file_title)
if __name__ == "__main__":
main(args)
diff --git a/tools/normalize_path.py b/tools/normalize_path.py
index 1b3d42e..6c4d548 100755
--- a/tools/normalize_path.py
+++ b/tools/normalize_path.py
@@ -14,11 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""
-Normalize and output paths read from stdin.
+Normalize and output paths from arguments, or stdin if no arguments provided.
"""
import os.path
import sys
+if len(sys.argv) > 1:
+ for p in sys.argv[1:]:
+ print os.path.normpath(p)
+ sys.exit(0)
+
for line in sys.stdin:
print os.path.normpath(line.strip())
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 6bdb9d1..7cb9072 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -42,6 +42,9 @@
OPTIONS.add_missing = False
OPTIONS.rebuild_recovery = False
+OPTIONS.replace_verity_public_key = False
+OPTIONS.replace_verity_private_key = False
+OPTIONS.verity_signer_path = None
def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None):
"""Turn the contents of SYSTEM into a system image and store it in
@@ -271,6 +274,8 @@
output_zip = zipfile.ZipFile(filename, "a",
compression=zipfile.ZIP_DEFLATED)
+ has_recovery = (OPTIONS.info_dict.get("no_recovery") != "true")
+
def banner(s):
print "\n\n++++ " + s + " ++++\n\n"
@@ -288,19 +293,21 @@
if boot_image:
boot_image.AddToZip(output_zip)
- banner("recovery")
recovery_image = None
- prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img")
- if os.path.exists(prebuilt_path):
- print "recovery.img already exists in IMAGES/, no need to rebuild..."
- if OPTIONS.rebuild_recovery:
+ if has_recovery:
+ banner("recovery")
+ prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img")
+ if os.path.exists(prebuilt_path):
+ print "recovery.img already exists in IMAGES/, no need to rebuild..."
+ if OPTIONS.rebuild_recovery:
+ recovery_image = common.GetBootableImage(
+ "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp,
+ "RECOVERY")
+ else:
recovery_image = common.GetBootableImage(
"IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
- else:
- recovery_image = common.GetBootableImage(
- "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
- if recovery_image:
- recovery_image.AddToZip(output_zip)
+ if recovery_image:
+ recovery_image.AddToZip(output_zip)
banner("system")
AddSystem(output_zip, recovery_img=recovery_image, boot_img=boot_image)
@@ -312,21 +319,47 @@
banner("cache")
AddCache(output_zip)
+ # For devices using A/B update, copy over images from RADIO/ to IMAGES/ and
+ # make sure we have all the needed images ready under IMAGES/.
+ ab_partitions = os.path.join(OPTIONS.input_tmp, "META", "ab_partitions.txt")
+ if os.path.exists(ab_partitions):
+ with open(ab_partitions, 'r') as f:
+ lines = f.readlines()
+ for line in lines:
+ img_name = line.strip() + ".img"
+ img_radio_path = os.path.join(OPTIONS.input_tmp, "RADIO", img_name)
+ if os.path.exists(img_radio_path):
+ common.ZipWrite(output_zip, img_radio_path,
+ os.path.join("IMAGES", img_name))
+
+ # Zip spec says: All slashes MUST be forward slashes.
+ img_path = 'IMAGES/' + img_name
+ assert img_path in output_zip.namelist(), "cannot find " + img_name
+
common.ZipClose(output_zip)
def main(argv):
- def option_handler(o, _):
+ def option_handler(o, a):
if o in ("-a", "--add_missing"):
OPTIONS.add_missing = True
elif o in ("-r", "--rebuild_recovery",):
OPTIONS.rebuild_recovery = True
+ elif o == "--replace_verity_private_key":
+ OPTIONS.replace_verity_private_key = (True, a)
+ elif o == "--replace_verity_public_key":
+ OPTIONS.replace_verity_public_key = (True, a)
+ elif o == "--verity_signer_path":
+ OPTIONS.verity_signer_path = a
else:
return False
return True
args = common.ParseOptions(
argv, __doc__, extra_opts="ar",
- extra_long_opts=["add_missing", "rebuild_recovery"],
+ extra_long_opts=["add_missing", "rebuild_recovery",
+ "replace_verity_public_key=",
+ "replace_verity_private_key=",
+ "verity_signer_path="],
extra_option_handler=option_handler)
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index cad654a..2c8bbc6 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -211,8 +211,11 @@
makeint("boot_size")
makeint("fstab_version")
- d["fstab"] = LoadRecoveryFSTab(read_helper, d["fstab_version"],
- d.get("system_root_image", False))
+ if d.get("no_recovery", False) == "true":
+ d["fstab"] = None
+ else:
+ d["fstab"] = LoadRecoveryFSTab(read_helper, d["fstab_version"],
+ d.get("system_root_image", False))
d["build.prop"] = LoadBuildProp(read_helper)
return d
@@ -444,7 +447,9 @@
img_keyblock = tempfile.NamedTemporaryFile()
cmd = [info_dict["vboot_signer_cmd"], info_dict["futility"],
img_unsigned.name, info_dict["vboot_key"] + ".vbpubk",
- info_dict["vboot_key"] + ".vbprivk", img_keyblock.name,
+ info_dict["vboot_key"] + ".vbprivk",
+ info_dict["vboot_subkey"] + ".vbprivk",
+ img_keyblock.name,
img.name]
p = Run(cmd, stdout=subprocess.PIPE)
p.communicate()
@@ -1083,6 +1088,9 @@
processor."""
return self._DoCall("IncrementalOTA_InstallEnd")
+ def VerifyOTA_Assertions(self):
+ return self._DoCall("VerifyOTA_Assertions")
+
class File(object):
def __init__(self, name, data):
self.name = name
@@ -1277,6 +1285,25 @@
self._WriteUpdate(script, output_zip)
self._WritePostInstallVerifyScript(script)
+ def WriteStrictVerifyScript(self, script):
+ """Verify all the blocks in the care_map, including clobbered blocks.
+
+ This differs from the WriteVerifyScript() function: a) it prints different
+ error messages; b) it doesn't allow half-way updated images to pass the
+ verification."""
+
+ partition = self.partition
+ script.Print("Verifying %s..." % (partition,))
+ ranges = self.tgt.care_map
+ ranges_str = ranges.to_string_raw()
+ script.AppendExtra('range_sha1("%s", "%s") == "%s" && '
+ 'ui_print(" Verified.") || '
+ 'ui_print("\\"%s\\" has unexpected contents.");' % (
+ self.device, ranges_str,
+ self.tgt.TotalSha1(include_clobbered_blocks=True),
+ self.device))
+ script.AppendExtra("")
+
def WriteVerifyScript(self, script):
partition = self.partition
if not self.src:
@@ -1284,7 +1311,20 @@
else:
ranges = self.src.care_map.subtract(self.src.clobbered_blocks)
ranges_str = ranges.to_string_raw()
- if self.version >= 3:
+ if self.version >= 4:
+ script.AppendExtra(('if (range_sha1("%s", "%s") == "%s" || '
+ 'block_image_verify("%s", '
+ 'package_extract_file("%s.transfer.list"), '
+ '"%s.new.dat", "%s.patch.dat") || '
+ '(block_image_recover("%s", "%s") && '
+ 'block_image_verify("%s", '
+ 'package_extract_file("%s.transfer.list"), '
+ '"%s.new.dat", "%s.patch.dat"))) then') % (
+ self.device, ranges_str, self.src.TotalSha1(),
+ self.device, partition, partition, partition,
+ self.device, ranges_str,
+ self.device, partition, partition, partition))
+ elif self.version == 3:
script.AppendExtra(('if (range_sha1("%s", "%s") == "%s" || '
'block_image_verify("%s", '
'package_extract_file("%s.transfer.list"), '
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index a4fc0b3..b3785ac 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -152,6 +152,15 @@
"".join([', "%s"' % (i,) for i in sha1]) +
') || abort("\\"%s\\" has unexpected contents.");' % (filename,))
+ def Verify(self, filename):
+ """Check that the given file (or MTD reference) has one of the
+ given hashes (encoded in the filename)."""
+ self.script.append(
+ 'apply_patch_check("{filename}") && '
+ 'ui_print(" Verified.") || '
+ 'ui_print("\\"{filename}\\" has unexpected contents.");'.format(
+ filename=filename))
+
def FileCheck(self, filename, *sha1):
"""Check that the given file (or MTD reference) has one of the
given *sha1 hashes."""
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index ce5808f..aa21d7e 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -102,10 +102,11 @@
if boot_image:
boot_image.AddToZip(output_zip)
- recovery_image = common.GetBootableImage(
- "recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
- if recovery_image:
- recovery_image.AddToZip(output_zip)
+ if OPTIONS.info_dict.get("no_recovery") != "true":
+ recovery_image = common.GetBootableImage(
+ "recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
+ if recovery_image:
+ recovery_image.AddToZip(output_zip)
def banner(s):
print "\n\n++++ " + s + " ++++\n\n"
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 354b9ad..fd57b93 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -91,6 +91,9 @@
--stash_threshold <float>
Specifies the threshold that will be used to compute the maximum
allowed stash size (defaults to 0.8).
+
+ --gen_verify
+ Generate an OTA package that verifies the partitions.
"""
import sys
@@ -130,7 +133,10 @@
OPTIONS.fallback_to_full = True
OPTIONS.full_radio = False
OPTIONS.full_bootloader = False
-
+# Stash size cannot exceed cache_size * threshold.
+OPTIONS.cache_size = None
+OPTIONS.stash_threshold = 0.8
+OPTIONS.gen_verify = False
def MostPopularKey(d, default):
"""Given a dict, return the key corresponding to the largest
@@ -982,6 +988,79 @@
WriteMetadata(metadata, output_zip)
+def WriteVerifyPackage(input_zip, output_zip):
+ script = edify_generator.EdifyGenerator(3, OPTIONS.info_dict)
+
+ oem_props = OPTIONS.info_dict.get("oem_fingerprint_properties")
+ recovery_mount_options = OPTIONS.info_dict.get(
+ "recovery_mount_options")
+ oem_dict = None
+ if oem_props is not None and len(oem_props) > 0:
+ if OPTIONS.oem_source is None:
+ raise common.ExternalError("OEM source required for this build")
+ script.Mount("/oem", recovery_mount_options)
+ oem_dict = common.LoadDictionaryFromLines(
+ open(OPTIONS.oem_source).readlines())
+
+ target_fp = CalculateFingerprint(oem_props, oem_dict, OPTIONS.info_dict)
+ metadata = {
+ "post-build": target_fp,
+ "pre-device": GetOemProperty("ro.product.device", oem_props, oem_dict,
+ OPTIONS.info_dict),
+ "post-timestamp": GetBuildProp("ro.build.date.utc", OPTIONS.info_dict),
+ }
+
+ device_specific = common.DeviceSpecificParams(
+ input_zip=input_zip,
+ input_version=OPTIONS.info_dict["recovery_api_version"],
+ output_zip=output_zip,
+ script=script,
+ input_tmp=OPTIONS.input_tmp,
+ metadata=metadata,
+ info_dict=OPTIONS.info_dict)
+
+ AppendAssertions(script, OPTIONS.info_dict, oem_dict)
+
+ script.Print("Verifying device images against %s..." % target_fp)
+ script.AppendExtra("")
+
+ script.Print("Verifying boot...")
+ boot_img = common.GetBootableImage(
+ "boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
+ boot_type, boot_device = common.GetTypeAndDevice(
+ "/boot", OPTIONS.info_dict)
+ script.Verify("%s:%s:%d:%s" % (
+ boot_type, boot_device, boot_img.size, boot_img.sha1))
+ script.AppendExtra("")
+
+ script.Print("Verifying recovery...")
+ recovery_img = common.GetBootableImage(
+ "recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
+ recovery_type, recovery_device = common.GetTypeAndDevice(
+ "/recovery", OPTIONS.info_dict)
+ script.Verify("%s:%s:%d:%s" % (
+ recovery_type, recovery_device, recovery_img.size, recovery_img.sha1))
+ script.AppendExtra("")
+
+ system_tgt = GetImage("system", OPTIONS.input_tmp, OPTIONS.info_dict)
+ system_tgt.ResetFileMap()
+ system_diff = common.BlockDifference("system", system_tgt, src=None)
+ system_diff.WriteStrictVerifyScript(script)
+
+ if HasVendorPartition(input_zip):
+ vendor_tgt = GetImage("vendor", OPTIONS.input_tmp, OPTIONS.info_dict)
+ vendor_tgt.ResetFileMap()
+ vendor_diff = common.BlockDifference("vendor", vendor_tgt, src=None)
+ vendor_diff.WriteStrictVerifyScript(script)
+
+ # Device specific partitions, such as radio, bootloader and etc.
+ device_specific.VerifyOTA_Assertions()
+
+ script.SetProgress(1.0)
+ script.AddToZip(input_zip, output_zip, input_path=OPTIONS.updater_binary)
+ WriteMetadata(metadata, output_zip)
+
+
class FileDifference(object):
def __init__(self, partition, source_zip, target_zip, output_zip):
self.deferred_patch_list = None
@@ -1550,6 +1629,8 @@
except ValueError:
raise ValueError("Cannot parse value %r for option %r - expecting "
"a float" % (a, o))
+ elif o == "--gen_verify":
+ OPTIONS.gen_verify = True
else:
return False
return True
@@ -1575,6 +1656,7 @@
"verify",
"no_fallback_to_full",
"stash_threshold=",
+ "gen_verify"
], extra_option_handler=option_handler)
if len(args) != 2:
@@ -1612,57 +1694,65 @@
if OPTIONS.device_specific is not None:
OPTIONS.device_specific = os.path.abspath(OPTIONS.device_specific)
- while True:
+ if OPTIONS.info_dict.get("no_recovery") == "true":
+ raise common.ExternalError(
+ "--- target build has specified no recovery ---")
- if OPTIONS.no_signing:
- if os.path.exists(args[1]):
- os.unlink(args[1])
- output_zip = zipfile.ZipFile(args[1], "w",
- compression=zipfile.ZIP_DEFLATED)
- else:
- temp_zip_file = tempfile.NamedTemporaryFile()
- output_zip = zipfile.ZipFile(temp_zip_file, "w",
- compression=zipfile.ZIP_DEFLATED)
+ # Use the default key to sign the package if not specified with package_key.
+ if not OPTIONS.no_signing:
+ if OPTIONS.package_key is None:
+ OPTIONS.package_key = OPTIONS.info_dict.get(
+ "default_system_dev_certificate",
+ "build/target/product/security/testkey")
- cache_size = OPTIONS.info_dict.get("cache_size", None)
- if cache_size is None:
- print "--- can't determine the cache partition size ---"
- OPTIONS.cache_size = cache_size
+ # Set up the output zip. Create a temporary zip file if signing is needed.
+ if OPTIONS.no_signing:
+ if os.path.exists(args[1]):
+ os.unlink(args[1])
+ output_zip = zipfile.ZipFile(args[1], "w",
+ compression=zipfile.ZIP_DEFLATED)
+ else:
+ temp_zip_file = tempfile.NamedTemporaryFile()
+ output_zip = zipfile.ZipFile(temp_zip_file, "w",
+ compression=zipfile.ZIP_DEFLATED)
- if OPTIONS.incremental_source is None:
+ cache_size = OPTIONS.info_dict.get("cache_size", None)
+ if cache_size is None:
+ print "--- can't determine the cache partition size ---"
+ OPTIONS.cache_size = cache_size
+
+ # Generate a verify package.
+ if OPTIONS.gen_verify:
+ WriteVerifyPackage(input_zip, output_zip)
+
+ # Generate a full OTA.
+ elif OPTIONS.incremental_source is None:
+ WriteFullOTAPackage(input_zip, output_zip)
+
+ # Generate an incremental OTA. It will fall back to generate a full OTA on
+ # failure unless no_fallback_to_full is specified.
+ else:
+ print "unzipping source target-files..."
+ OPTIONS.source_tmp, source_zip = common.UnzipTemp(
+ OPTIONS.incremental_source)
+ OPTIONS.target_info_dict = OPTIONS.info_dict
+ OPTIONS.source_info_dict = common.LoadInfoDict(source_zip,
+ OPTIONS.source_tmp)
+ if OPTIONS.verbose:
+ print "--- source info ---"
+ common.DumpInfoDict(OPTIONS.source_info_dict)
+ try:
+ WriteIncrementalOTAPackage(input_zip, source_zip, output_zip)
+ except ValueError:
+ if not OPTIONS.fallback_to_full:
+ raise
+ print "--- failed to build incremental; falling back to full ---"
+ OPTIONS.incremental_source = None
WriteFullOTAPackage(input_zip, output_zip)
- if OPTIONS.package_key is None:
- OPTIONS.package_key = OPTIONS.info_dict.get(
- "default_system_dev_certificate",
- "build/target/product/security/testkey")
- common.ZipClose(output_zip)
- break
- else:
- print "unzipping source target-files..."
- OPTIONS.source_tmp, source_zip = common.UnzipTemp(
- OPTIONS.incremental_source)
- OPTIONS.target_info_dict = OPTIONS.info_dict
- OPTIONS.source_info_dict = common.LoadInfoDict(source_zip,
- OPTIONS.source_tmp)
- if OPTIONS.package_key is None:
- OPTIONS.package_key = OPTIONS.source_info_dict.get(
- "default_system_dev_certificate",
- "build/target/product/security/testkey")
- if OPTIONS.verbose:
- print "--- source info ---"
- common.DumpInfoDict(OPTIONS.source_info_dict)
- try:
- WriteIncrementalOTAPackage(input_zip, source_zip, output_zip)
- common.ZipClose(output_zip)
- break
- except ValueError:
- if not OPTIONS.fallback_to_full:
- raise
- print "--- failed to build incremental; falling back to full ---"
- OPTIONS.incremental_source = None
- common.ZipClose(output_zip)
+ common.ZipClose(output_zip)
+ # Sign the generated zip package unless no_signing is specified.
if not OPTIONS.no_signing:
SignOutput(temp_zip_file.name, args[1])
temp_zip_file.close()
diff --git a/tools/releasetools/sparse_img.py b/tools/releasetools/sparse_img.py
index 07f3c1c..013044f 100644
--- a/tools/releasetools/sparse_img.py
+++ b/tools/releasetools/sparse_img.py
@@ -210,6 +210,16 @@
nonzero_blocks = []
reference = '\0' * self.blocksize
+ # Workaround for bug 23227672. For squashfs, we don't have a system.map. So
+ # the whole system image will be treated as a single file. But for some
+ # unknown bug, the updater will be killed due to OOM when writing back the
+ # patched image to flash (observed on lenok-userdebug MEA49). Prior to
+ # getting a real fix, we evenly divide the non-zero blocks into smaller
+ # groups (currently 1024 blocks or 4MB per group).
+ # Bug: 23227672
+ MAX_BLOCKS_PER_GROUP = 1024
+ nonzero_groups = []
+
f = self.simg_f
for s, e in remaining:
for b in range(s, e):
@@ -232,12 +242,22 @@
nonzero_blocks.append(b)
nonzero_blocks.append(b+1)
- assert zero_blocks or nonzero_blocks or clobbered_blocks
+ if len(nonzero_blocks) >= MAX_BLOCKS_PER_GROUP:
+ nonzero_groups.append(nonzero_blocks)
+ # Clear the list.
+ nonzero_blocks = []
+
+ if nonzero_blocks:
+ nonzero_groups.append(nonzero_blocks)
+ nonzero_blocks = []
+
+ assert zero_blocks or nonzero_groups or clobbered_blocks
if zero_blocks:
out["__ZERO"] = rangelib.RangeSet(data=zero_blocks)
- if nonzero_blocks:
- out["__NONZERO"] = rangelib.RangeSet(data=nonzero_blocks)
+ if nonzero_groups:
+ for i, blocks in enumerate(nonzero_groups):
+ out["__NONZERO-%d" % i] = rangelib.RangeSet(data=blocks)
if clobbered_blocks:
out["__COPY"] = clobbered_blocks
diff --git a/tools/target_files_diff.py b/tools/target_files_diff.py
new file mode 100755
index 0000000..010ea84
--- /dev/null
+++ b/tools/target_files_diff.py
@@ -0,0 +1,224 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2009 The Android Open Source 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.
+#
+
+#
+# Finds differences between two target files packages
+#
+
+from __future__ import print_function
+
+import argparse
+import contextlib
+import os
+import re
+import subprocess
+import tempfile
+
+def ignore(name):
+ """
+ Files to ignore when diffing
+
+ These are packages that we're already diffing elsewhere,
+ or files that we expect to be different for every build,
+ or known problems.
+ """
+
+ # We're looking at the files that make the images, so no need to search them
+ if name in ['IMAGES']:
+ return True
+ # These are packages of the recovery partition, which we're already diffing
+ if name in ['SYSTEM/etc/recovery-resource.dat',
+ 'SYSTEM/recovery-from-boot.p']:
+ return True
+
+ # These files are just the BUILD_NUMBER, and will always be different
+ if name in ['BOOT/RAMDISK/selinux_version',
+ 'RECOVERY/RAMDISK/selinux_version']:
+ return True
+
+ # b/24201956 .art/.oat/.odex files are different with every build
+ if name.endswith('.art') or name.endswith('.oat') or name.endswith('.odex'):
+ return True
+ # b/25348136 libpac.so changes with every build
+ if name in ['SYSTEM/lib/libpac.so',
+ 'SYSTEM/lib64/libpac.so']:
+ return True
+
+ return False
+
+
+def rewrite_build_property(original, new):
+ """
+ Rewrite property files to remove values known to change for every build
+ """
+
+ skipped = ['ro.bootimage.build.date=',
+ 'ro.bootimage.build.date.utc=',
+ 'ro.bootimage.build.fingerprint=',
+ 'ro.build.id=',
+ 'ro.build.display.id=',
+ 'ro.build.version.incremental=',
+ 'ro.build.date=',
+ 'ro.build.date.utc=',
+ 'ro.build.host=',
+ 'ro.build.description=',
+ 'ro.build.fingerprint=',
+ 'ro.expect.recovery_id=',
+ 'ro.vendor.build.date=',
+ 'ro.vendor.build.date.utc=',
+ 'ro.vendor.build.fingerprint=']
+
+ for line in original:
+ skip = False
+ for s in skipped:
+ if line.startswith(s):
+ skip = True
+ break
+ if not skip:
+ new.write(line)
+
+
+def trim_install_recovery(original, new):
+ """
+ Rewrite the install-recovery script to remove the hash of the recovery partition.
+ """
+ for line in original:
+ new.write(re.sub(r'[0-9a-f]{40}', '0'*40, line))
+
+def sort_file(original, new):
+ """
+ Sort the file. Some OTA metadata files are not in a deterministic order currently.
+ """
+ lines = original.readlines()
+ lines.sort()
+ for line in lines:
+ new.write(line)
+
+# Map files to the functions that will modify them for diffing
+REWRITE_RULES = {
+ 'BOOT/RAMDISK/default.prop': rewrite_build_property,
+ 'RECOVERY/RAMDISK/default.prop': rewrite_build_property,
+ 'SYSTEM/build.prop': rewrite_build_property,
+ 'VENDOR/build.prop': rewrite_build_property,
+
+ 'SYSTEM/bin/install-recovery.sh': trim_install_recovery,
+
+ 'META/boot_filesystem_config.txt': sort_file,
+ 'META/filesystem_config.txt': sort_file,
+ 'META/recovery_filesystem_config.txt': sort_file,
+ 'META/vendor_filesystem_config.txt': sort_file,
+}
+
+@contextlib.contextmanager
+def preprocess(name, filename):
+ """
+ Optionally rewrite files before diffing them, to remove known-variable information.
+ """
+ if name in REWRITE_RULES:
+ with tempfile.NamedTemporaryFile() as newfp:
+ with open(filename, 'r') as oldfp:
+ REWRITE_RULES[name](oldfp, newfp)
+ newfp.flush()
+ yield newfp.name
+ else:
+ yield filename
+
+def diff(name, file1, file2):
+ """
+ Diff a file pair with diff, running preprocess() on the arguments first.
+ """
+ with preprocess(name, file1) as f1:
+ with preprocess(name, file2) as f2:
+ proc = subprocess.Popen(['diff', f1, f2], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ (stdout, ignore) = proc.communicate()
+ if proc.returncode == 0:
+ return
+ stdout = stdout.strip()
+ if stdout == 'Binary files %s and %s differ' % (f1, f2):
+ print("%s: Binary files differ" % name)
+ else:
+ for line in stdout.strip().split('\n'):
+ print("%s: %s" % (name, line))
+
+def recursiveDiff(prefix, dir1, dir2):
+ """
+ Recursively diff two directories, checking metadata then calling diff()
+ """
+ list1 = sorted(os.listdir(dir1))
+ list2 = sorted(os.listdir(dir2))
+
+ for entry in list1:
+ name = os.path.join(prefix, entry)
+ name1 = os.path.join(dir1, entry)
+ name2 = os.path.join(dir2, entry)
+
+ if ignore(name):
+ continue
+
+ if entry in list2:
+ if os.path.islink(name1):
+ if os.path.islink(name2):
+ link1 = os.readlink(name1)
+ link2 = os.readlink(name2)
+ if link1 != link2:
+ print("%s: Symlinks differ: %s vs %s" % (name, link1, link2))
+ else:
+ print("%s: File types differ, skipping compare" % name)
+ continue
+
+ stat1 = os.stat(name1)
+ stat2 = os.stat(name2)
+ type1 = stat1.st_mode & ~0777
+ type2 = stat2.st_mode & ~0777
+
+ if type1 != type2:
+ print("%s: File types differ, skipping compare" % name)
+ continue
+
+ if stat1.st_mode != stat2.st_mode:
+ print("%s: Modes differ: %o vs %o" % (name, stat1.st_mode, stat2.st_mode))
+
+ if os.path.isdir(name1):
+ recursiveDiff(name, name1, name2)
+ elif os.path.isfile(name1):
+ diff(name, name1, name2)
+ else:
+ print("%s: Unknown file type, skipping compare" % name)
+ else:
+ print("%s: Only in base package" % name)
+
+ for entry in list2:
+ name = os.path.join(prefix, entry)
+ name1 = os.path.join(dir1, entry)
+ name2 = os.path.join(dir2, entry)
+
+ if ignore(name):
+ continue
+
+ if entry not in list1:
+ print("%s: Only in new package" % name)
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('dir1', help='The base target files package (extracted)')
+ parser.add_argument('dir2', help='The new target files package (extracted)')
+ args = parser.parse_args()
+
+ recursiveDiff('', args.dir1, args.dir2)
+
+if __name__ == '__main__':
+ main()
diff --git a/tools/zipalign/ZipEntry.cpp b/tools/zipalign/ZipEntry.cpp
index b2270cb..a13b8d1 100644
--- a/tools/zipalign/ZipEntry.cpp
+++ b/tools/zipalign/ZipEntry.cpp
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
+#include <inttypes.h>
using namespace android;
@@ -56,7 +57,7 @@
/* using the info in the CDE, go load up the LFH */
posn = ftell(fp);
if (fseek(fp, mCDE.mLocalHeaderRelOffset, SEEK_SET) != 0) {
- ALOGD("local header seek failed (%ld)\n",
+ ALOGD("local header seek failed (%" PRIu32 ")\n",
mCDE.mLocalHeaderRelOffset);
return UNKNOWN_ERROR;
}
@@ -123,12 +124,12 @@
mCDE.mExternalAttrs = 0x81b60020; // matches what WinZip does
if (mCDE.mFileNameLength > 0) {
- mCDE.mFileName = new unsigned char[mCDE.mFileNameLength+1];
+ mCDE.mFileName = new uint8_t[mCDE.mFileNameLength+1];
strcpy((char*) mCDE.mFileName, fileName);
}
if (mCDE.mFileCommentLength > 0) {
/* TODO: stop assuming null-terminated ASCII here? */
- mCDE.mFileComment = new unsigned char[mCDE.mFileCommentLength+1];
+ mCDE.mFileComment = new uint8_t[mCDE.mFileCommentLength+1];
strcpy((char*) mCDE.mFileComment, comment);
}
@@ -150,20 +151,20 @@
memcpy(&mCDE, &pEntry->mCDE, sizeof(mCDE));
if (mCDE.mFileNameLength > 0) {
- mCDE.mFileName = new unsigned char[mCDE.mFileNameLength+1];
+ mCDE.mFileName = new uint8_t[mCDE.mFileNameLength+1];
if (mCDE.mFileName == NULL)
return NO_MEMORY;
strcpy((char*) mCDE.mFileName, (char*)pEntry->mCDE.mFileName);
}
if (mCDE.mFileCommentLength > 0) {
- mCDE.mFileComment = new unsigned char[mCDE.mFileCommentLength+1];
+ mCDE.mFileComment = new uint8_t[mCDE.mFileCommentLength+1];
if (mCDE.mFileComment == NULL)
return NO_MEMORY;
strcpy((char*) mCDE.mFileComment, (char*)pEntry->mCDE.mFileComment);
}
if (mCDE.mExtraFieldLength > 0) {
/* we null-terminate this, though it may not be a string */
- mCDE.mExtraField = new unsigned char[mCDE.mExtraFieldLength+1];
+ mCDE.mExtraField = new uint8_t[mCDE.mExtraFieldLength+1];
if (mCDE.mExtraField == NULL)
return NO_MEMORY;
memcpy(mCDE.mExtraField, pEntry->mCDE.mExtraField,
@@ -180,7 +181,7 @@
assert(mLFH.mExtraField == NULL);
mLFH.mExtraFieldLength = pEntry->mLFH.mExtraFieldLength;
if (mLFH.mExtraFieldLength > 0) {
- mLFH.mExtraField = new unsigned char[mLFH.mExtraFieldLength+1];
+ mLFH.mExtraField = new uint8_t[mLFH.mExtraFieldLength+1];
if (mLFH.mExtraField == NULL)
return NO_MEMORY;
memcpy(mLFH.mExtraField, pEntry->mLFH.mExtraField,
@@ -205,9 +206,9 @@
if (mLFH.mExtraFieldLength > 0) {
/* extend existing field */
- unsigned char* newExtra;
+ uint8_t* newExtra;
- newExtra = new unsigned char[mLFH.mExtraFieldLength + padding];
+ newExtra = new uint8_t[mLFH.mExtraFieldLength + padding];
if (newExtra == NULL)
return NO_MEMORY;
memset(newExtra + mLFH.mExtraFieldLength, 0, padding);
@@ -218,7 +219,7 @@
mLFH.mExtraFieldLength += padding;
} else {
/* create new field */
- mLFH.mExtraField = new unsigned char[padding];
+ mLFH.mExtraField = new uint8_t[padding];
memset(mLFH.mExtraField, 0, padding);
mLFH.mExtraFieldLength = padding;
}
@@ -246,7 +247,7 @@
delete[] mLFH.mFileName;
if (mLFH.mFileNameLength > 0) {
- mLFH.mFileName = new unsigned char[mLFH.mFileNameLength+1];
+ mLFH.mFileName = new uint8_t[mLFH.mFileNameLength+1];
strcpy((char*) mLFH.mFileName, (const char*) mCDE.mFileName);
} else {
mLFH.mFileName = NULL;
@@ -256,7 +257,7 @@
/*
* Set some information about a file after we add it.
*/
-void ZipEntry::setDataInfo(long uncompLen, long compLen, unsigned long crc32,
+void ZipEntry::setDataInfo(long uncompLen, long compLen, uint32_t crc32,
int compressionMethod)
{
mCDE.mCompressionMethod = compressionMethod;
@@ -360,7 +361,7 @@
struct tm tmResult;
#endif
time_t even;
- unsigned short zdate, ztime;
+ uint16_t zdate, ztime;
struct tm* ptm;
@@ -402,7 +403,7 @@
status_t ZipEntry::LocalFileHeader::read(FILE* fp)
{
status_t result = NO_ERROR;
- unsigned char buf[kLFHLen];
+ uint8_t buf[kLFHLen];
assert(mFileName == NULL);
assert(mExtraField == NULL);
@@ -433,7 +434,7 @@
/* grab filename */
if (mFileNameLength != 0) {
- mFileName = new unsigned char[mFileNameLength+1];
+ mFileName = new uint8_t[mFileNameLength+1];
if (mFileName == NULL) {
result = NO_MEMORY;
goto bail;
@@ -447,7 +448,7 @@
/* grab extra field */
if (mExtraFieldLength != 0) {
- mExtraField = new unsigned char[mExtraFieldLength+1];
+ mExtraField = new uint8_t[mExtraFieldLength+1];
if (mExtraField == NULL) {
result = NO_MEMORY;
goto bail;
@@ -468,7 +469,7 @@
*/
status_t ZipEntry::LocalFileHeader::write(FILE* fp)
{
- unsigned char buf[kLFHLen];
+ uint8_t buf[kLFHLen];
ZipEntry::putLongLE(&buf[0x00], kSignature);
ZipEntry::putShortLE(&buf[0x04], mVersionToExtract);
@@ -507,13 +508,13 @@
void ZipEntry::LocalFileHeader::dump(void) const
{
ALOGD(" LocalFileHeader contents:\n");
- ALOGD(" versToExt=%u gpBits=0x%04x compression=%u\n",
+ ALOGD(" versToExt=%" PRIu16 " gpBits=0x%04" PRIx16 " compression=%" PRIu16 "\n",
mVersionToExtract, mGPBitFlag, mCompressionMethod);
- ALOGD(" modTime=0x%04x modDate=0x%04x crc32=0x%08lx\n",
+ ALOGD(" modTime=0x%04" PRIx16 " modDate=0x%04" PRIx16 " crc32=0x%08" PRIx32 "\n",
mLastModFileTime, mLastModFileDate, mCRC32);
- ALOGD(" compressedSize=%lu uncompressedSize=%lu\n",
+ ALOGD(" compressedSize=%" PRIu32 " uncompressedSize=%" PRIu32 "\n",
mCompressedSize, mUncompressedSize);
- ALOGD(" filenameLen=%u extraLen=%u\n",
+ ALOGD(" filenameLen=%" PRIu16 " extraLen=%" PRIu16 "\n",
mFileNameLength, mExtraFieldLength);
if (mFileName != NULL)
ALOGD(" filename: '%s'\n", mFileName);
@@ -536,7 +537,7 @@
status_t ZipEntry::CentralDirEntry::read(FILE* fp)
{
status_t result = NO_ERROR;
- unsigned char buf[kCDELen];
+ uint8_t buf[kCDELen];
/* no re-use */
assert(mFileName == NULL);
@@ -575,7 +576,7 @@
/* grab filename */
if (mFileNameLength != 0) {
- mFileName = new unsigned char[mFileNameLength+1];
+ mFileName = new uint8_t[mFileNameLength+1];
if (mFileName == NULL) {
result = NO_MEMORY;
goto bail;
@@ -589,7 +590,7 @@
/* read "extra field" */
if (mExtraFieldLength != 0) {
- mExtraField = new unsigned char[mExtraFieldLength+1];
+ mExtraField = new uint8_t[mExtraFieldLength+1];
if (mExtraField == NULL) {
result = NO_MEMORY;
goto bail;
@@ -604,7 +605,7 @@
/* grab comment, if any */
if (mFileCommentLength != 0) {
- mFileComment = new unsigned char[mFileCommentLength+1];
+ mFileComment = new uint8_t[mFileCommentLength+1];
if (mFileComment == NULL) {
result = NO_MEMORY;
goto bail;
@@ -626,7 +627,7 @@
*/
status_t ZipEntry::CentralDirEntry::write(FILE* fp)
{
- unsigned char buf[kCDELen];
+ uint8_t buf[kCDELen];
ZipEntry::putLongLE(&buf[0x00], kSignature);
ZipEntry::putShortLE(&buf[0x04], mVersionMadeBy);
@@ -676,15 +677,15 @@
void ZipEntry::CentralDirEntry::dump(void) const
{
ALOGD(" CentralDirEntry contents:\n");
- ALOGD(" versMadeBy=%u versToExt=%u gpBits=0x%04x compression=%u\n",
+ ALOGD(" versMadeBy=%" PRIu16 " versToExt=%" PRIu16 " gpBits=0x%04" PRIx16 " compression=%" PRIu16 "\n",
mVersionMadeBy, mVersionToExtract, mGPBitFlag, mCompressionMethod);
- ALOGD(" modTime=0x%04x modDate=0x%04x crc32=0x%08lx\n",
+ ALOGD(" modTime=0x%04" PRIx16 " modDate=0x%04" PRIx16 " crc32=0x%08" PRIx32 "\n",
mLastModFileTime, mLastModFileDate, mCRC32);
- ALOGD(" compressedSize=%lu uncompressedSize=%lu\n",
+ ALOGD(" compressedSize=%" PRIu32 " uncompressedSize=%" PRIu32 "\n",
mCompressedSize, mUncompressedSize);
- ALOGD(" filenameLen=%u extraLen=%u commentLen=%u\n",
+ ALOGD(" filenameLen=%" PRIu16 " extraLen=%" PRIu16 " commentLen=%" PRIu16 "\n",
mFileNameLength, mExtraFieldLength, mFileCommentLength);
- ALOGD(" diskNumStart=%u intAttr=0x%04x extAttr=0x%08lx relOffset=%lu\n",
+ ALOGD(" diskNumStart=%" PRIu16 " intAttr=0x%04" PRIx16 " extAttr=0x%08" PRIx32 " relOffset=%" PRIu32 "\n",
mDiskNumberStart, mInternalAttrs, mExternalAttrs,
mLocalHeaderRelOffset);
diff --git a/tools/zipalign/ZipEntry.h b/tools/zipalign/ZipEntry.h
index 7f721b4..129a759 100644
--- a/tools/zipalign/ZipEntry.h
+++ b/tools/zipalign/ZipEntry.h
@@ -25,6 +25,7 @@
#include <utils/Errors.h>
#include <stdlib.h>
+#include <stdint.h>
#include <stdio.h>
namespace android {
@@ -85,7 +86,7 @@
/*
* Return the data CRC.
*/
- unsigned long getCRC32(void) const { return mCDE.mCRC32; }
+ uint32_t getCRC32(void) const { return mCDE.mCRC32; }
/*
* Return file modification time in UNIX seconds-since-epoch.
@@ -108,21 +109,21 @@
* Some basic functions for raw data manipulation. "LE" means
* Little Endian.
*/
- static inline unsigned short getShortLE(const unsigned char* buf) {
+ static inline uint16_t getShortLE(const uint8_t* buf) {
return buf[0] | (buf[1] << 8);
}
- static inline unsigned long getLongLE(const unsigned char* buf) {
+ static inline uint32_t getLongLE(const uint8_t* buf) {
return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
}
- static inline void putShortLE(unsigned char* buf, short val) {
- buf[0] = (unsigned char) val;
- buf[1] = (unsigned char) (val >> 8);
+ static inline void putShortLE(uint8_t* buf, uint16_t val) {
+ buf[0] = (uint8_t) val;
+ buf[1] = (uint8_t) (val >> 8);
}
- static inline void putLongLE(unsigned char* buf, long val) {
- buf[0] = (unsigned char) val;
- buf[1] = (unsigned char) (val >> 8);
- buf[2] = (unsigned char) (val >> 16);
- buf[3] = (unsigned char) (val >> 24);
+ static inline void putLongLE(uint8_t* buf, uint32_t val) {
+ buf[0] = (uint8_t) val;
+ buf[1] = (uint8_t) (val >> 8);
+ buf[2] = (uint8_t) (val >> 16);
+ buf[3] = (uint8_t) (val >> 24);
}
/* defined for Zip archives */
@@ -177,7 +178,7 @@
/*
* Set information about the data for this entry.
*/
- void setDataInfo(long uncompLen, long compLen, unsigned long crc32,
+ void setDataInfo(long uncompLen, long compLen, uint32_t crc32,
int compressionMethod);
/*
@@ -195,7 +196,7 @@
* the current file.
*/
void setLFHOffset(off_t offset) {
- mCDE.mLocalHeaderRelOffset = (long) offset;
+ mCDE.mLocalHeaderRelOffset = (uint32_t) offset;
}
/* mark for deletion; used by ZipFile::remove() */
@@ -240,19 +241,19 @@
status_t read(FILE* fp);
status_t write(FILE* fp);
- // unsigned long mSignature;
- unsigned short mVersionToExtract;
- unsigned short mGPBitFlag;
- unsigned short mCompressionMethod;
- unsigned short mLastModFileTime;
- unsigned short mLastModFileDate;
- unsigned long mCRC32;
- unsigned long mCompressedSize;
- unsigned long mUncompressedSize;
- unsigned short mFileNameLength;
- unsigned short mExtraFieldLength;
- unsigned char* mFileName;
- unsigned char* mExtraField;
+ // uint32_t mSignature;
+ uint16_t mVersionToExtract;
+ uint16_t mGPBitFlag;
+ uint16_t mCompressionMethod;
+ uint16_t mLastModFileTime;
+ uint16_t mLastModFileDate;
+ uint32_t mCRC32;
+ uint32_t mCompressedSize;
+ uint32_t mUncompressedSize;
+ uint16_t mFileNameLength;
+ uint16_t mExtraFieldLength;
+ uint8_t* mFileName;
+ uint8_t* mExtraField;
enum {
kSignature = 0x04034b50,
@@ -298,26 +299,26 @@
status_t read(FILE* fp);
status_t write(FILE* fp);
- // unsigned long mSignature;
- unsigned short mVersionMadeBy;
- unsigned short mVersionToExtract;
- unsigned short mGPBitFlag;
- unsigned short mCompressionMethod;
- unsigned short mLastModFileTime;
- unsigned short mLastModFileDate;
- unsigned long mCRC32;
- unsigned long mCompressedSize;
- unsigned long mUncompressedSize;
- unsigned short mFileNameLength;
- unsigned short mExtraFieldLength;
- unsigned short mFileCommentLength;
- unsigned short mDiskNumberStart;
- unsigned short mInternalAttrs;
- unsigned long mExternalAttrs;
- unsigned long mLocalHeaderRelOffset;
- unsigned char* mFileName;
- unsigned char* mExtraField;
- unsigned char* mFileComment;
+ // uint32_t mSignature;
+ uint16_t mVersionMadeBy;
+ uint16_t mVersionToExtract;
+ uint16_t mGPBitFlag;
+ uint16_t mCompressionMethod;
+ uint16_t mLastModFileTime;
+ uint16_t mLastModFileDate;
+ uint32_t mCRC32;
+ uint32_t mCompressedSize;
+ uint32_t mUncompressedSize;
+ uint16_t mFileNameLength;
+ uint16_t mExtraFieldLength;
+ uint16_t mFileCommentLength;
+ uint16_t mDiskNumberStart;
+ uint16_t mInternalAttrs;
+ uint32_t mExternalAttrs;
+ uint32_t mLocalHeaderRelOffset;
+ uint8_t* mFileName;
+ uint8_t* mExtraField;
+ uint8_t* mFileComment;
void dump(void) const;
diff --git a/tools/zipalign/ZipFile.cpp b/tools/zipalign/ZipFile.cpp
index 3c5ec15..7c3ff37 100644
--- a/tools/zipalign/ZipFile.cpp
+++ b/tools/zipalign/ZipFile.cpp
@@ -34,6 +34,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <assert.h>
+#include <inttypes.h>
using namespace android;
@@ -206,7 +207,7 @@
status_t ZipFile::readCentralDir(void)
{
status_t result = NO_ERROR;
- unsigned char* buf = NULL;
+ uint8_t* buf = NULL;
off_t fileLength, seekStart;
long readAmount;
int i;
@@ -222,7 +223,7 @@
goto bail;
}
- buf = new unsigned char[EndOfCentralDir::kMaxEOCDSearch];
+ buf = new uint8_t[EndOfCentralDir::kMaxEOCDSearch];
if (buf == NULL) {
ALOGD("Failure allocating %d bytes for EOCD search",
EndOfCentralDir::kMaxEOCDSearch);
@@ -296,7 +297,7 @@
* we're hoping to preserve.
*/
if (fseek(mZipFp, mEOCD.mCentralDirOffset, SEEK_SET) != 0) {
- ALOGD("Failure seeking to central dir offset %ld\n",
+ ALOGD("Failure seeking to central dir offset %" PRIu32 "\n",
mEOCD.mCentralDirOffset);
result = UNKNOWN_ERROR;
goto bail;
@@ -305,7 +306,7 @@
/*
* Loop through and read the central dir entries.
*/
- ALOGV("Scanning %d entries...\n", mEOCD.mTotalNumEntries);
+ ALOGV("Scanning %" PRIu16 " entries...\n", mEOCD.mTotalNumEntries);
int entry;
for (entry = 0; entry < mEOCD.mTotalNumEntries; entry++) {
ZipEntry* pEntry = new ZipEntry;
@@ -325,7 +326,7 @@
* If all went well, we should now be back at the EOCD.
*/
{
- unsigned char checkBuf[4];
+ uint8_t checkBuf[4];
if (fread(checkBuf, 1, 4, mZipFp) != 4) {
ALOGD("EOCD check read failed\n");
result = INVALID_OPERATION;
@@ -365,7 +366,7 @@
status_t result = NO_ERROR;
long lfhPosn, startPosn, endPosn, uncompressedLen;
FILE* inputFp = NULL;
- unsigned long crc;
+ uint32_t crc;
time_t modWhen;
if (mReadOnly)
@@ -466,14 +467,16 @@
bool scanResult;
int method;
long compressedLen;
+ unsigned long longcrc;
scanResult = ZipUtils::examineGzip(inputFp, &method, &uncompressedLen,
- &compressedLen, &crc);
+ &compressedLen, &longcrc);
if (!scanResult || method != ZipEntry::kCompressDeflated) {
ALOGD("this isn't a deflated gzip file?");
result = UNKNOWN_ERROR;
goto bail;
}
+ crc = longcrc;
result = copyPartialFpToFp(mZipFp, inputFp, compressedLen, NULL);
if (result != NO_ERROR) {
@@ -710,7 +713,7 @@
goto bail;
}
long startPosn = ftell(mZipFp);
- unsigned long crc;
+ uint32_t crc;
if (compressFpToFp(mZipFp, NULL, buf, uncompressedLen, &crc) != NO_ERROR) {
ALOGW("recompress of '%s' failed\n", pEntry->mCDE.mFileName);
result = UNKNOWN_ERROR;
@@ -780,9 +783,9 @@
* On exit, "srcFp" will be seeked to the end of the file, and "dstFp"
* will be seeked immediately past the data.
*/
-status_t ZipFile::copyFpToFp(FILE* dstFp, FILE* srcFp, unsigned long* pCRC32)
+status_t ZipFile::copyFpToFp(FILE* dstFp, FILE* srcFp, uint32_t* pCRC32)
{
- unsigned char tmpBuf[32768];
+ uint8_t tmpBuf[32768];
size_t count;
*pCRC32 = crc32(0L, Z_NULL, 0);
@@ -811,7 +814,7 @@
* On exit, "dstFp" will be seeked immediately past the data.
*/
status_t ZipFile::copyDataToFp(FILE* dstFp,
- const void* data, size_t size, unsigned long* pCRC32)
+ const void* data, size_t size, uint32_t* pCRC32)
{
size_t count;
@@ -836,9 +839,9 @@
* will be seeked immediately past the data just written.
*/
status_t ZipFile::copyPartialFpToFp(FILE* dstFp, FILE* srcFp, long length,
- unsigned long* pCRC32)
+ uint32_t* pCRC32)
{
- unsigned char tmpBuf[32768];
+ uint8_t tmpBuf[32768];
size_t count;
if (pCRC32 != NULL)
@@ -846,7 +849,7 @@
while (length) {
long readSize;
-
+
readSize = sizeof(tmpBuf);
if (readSize > length)
readSize = length;
@@ -878,15 +881,15 @@
* will be seeked immediately past the compressed data.
*/
status_t ZipFile::compressFpToFp(FILE* dstFp, FILE* srcFp,
- const void* data, size_t size, unsigned long* pCRC32)
+ const void* data, size_t size, uint32_t* pCRC32)
{
status_t result = NO_ERROR;
const size_t kBufSize = 1024 * 1024;
- unsigned char* inBuf = NULL;
- unsigned char* outBuf = NULL;
+ uint8_t* inBuf = NULL;
+ uint8_t* outBuf = NULL;
size_t outSize = 0;
bool atEof = false; // no feof() aviailable yet
- unsigned long crc;
+ uint32_t crc;
ZopfliOptions options;
unsigned char bp = 0;
@@ -902,7 +905,7 @@
/*
* Create an input buffer and an output buffer.
*/
- inBuf = new unsigned char[kBufSize];
+ inBuf = new uint8_t[kBufSize];
if (inBuf == NULL) {
result = NO_MEMORY;
goto bail;
@@ -1128,7 +1131,7 @@
if (dst == src || n <= 0)
return NO_ERROR;
- unsigned char readBuf[32768];
+ uint8_t readBuf[32768];
if (dst < src) {
/* shift stuff toward start of file; must read from start */
@@ -1294,7 +1297,7 @@
* "buf" should be positioned at the EOCD signature, and should contain
* the entire EOCD area including the comment.
*/
-status_t ZipFile::EndOfCentralDir::readBuf(const unsigned char* buf, int len)
+status_t ZipFile::EndOfCentralDir::readBuf(const uint8_t* buf, int len)
{
/* don't allow re-use */
assert(mComment == NULL);
@@ -1322,11 +1325,11 @@
if (mCommentLen > 0) {
if (kEOCDLen + mCommentLen > len) {
- ALOGD("EOCD(%d) + comment(%d) exceeds len (%d)\n",
+ ALOGD("EOCD(%d) + comment(%" PRIu16 ") exceeds len (%d)\n",
kEOCDLen, mCommentLen, len);
return UNKNOWN_ERROR;
}
- mComment = new unsigned char[mCommentLen];
+ mComment = new uint8_t[mCommentLen];
memcpy(mComment, buf + kEOCDLen, mCommentLen);
}
@@ -1338,7 +1341,7 @@
*/
status_t ZipFile::EndOfCentralDir::write(FILE* fp)
{
- unsigned char buf[kEOCDLen];
+ uint8_t buf[kEOCDLen];
ZipEntry::putLongLE(&buf[0x00], kSignature);
ZipEntry::putShortLE(&buf[0x04], mDiskNumber);
@@ -1366,9 +1369,9 @@
void ZipFile::EndOfCentralDir::dump(void) const
{
ALOGD(" EndOfCentralDir contents:\n");
- ALOGD(" diskNum=%u diskWCD=%u numEnt=%u totalNumEnt=%u\n",
+ ALOGD(" diskNum=%" PRIu16 " diskWCD=%" PRIu16 " numEnt=%" PRIu16 " totalNumEnt=%" PRIu16 "\n",
mDiskNumber, mDiskWithCentralDir, mNumEntries, mTotalNumEntries);
- ALOGD(" centDirSize=%lu centDirOff=%lu commentLen=%u\n",
+ ALOGD(" centDirSize=%" PRIu32 " centDirOff=%" PRIu32 " commentLen=%" PRIu32 "\n",
mCentralDirSize, mCentralDirOffset, mCommentLen);
}
diff --git a/tools/zipalign/ZipFile.h b/tools/zipalign/ZipFile.h
index b99cda5..b0bafe9 100644
--- a/tools/zipalign/ZipFile.h
+++ b/tools/zipalign/ZipFile.h
@@ -194,18 +194,18 @@
delete[] mComment;
}
- status_t readBuf(const unsigned char* buf, int len);
+ status_t readBuf(const uint8_t* buf, int len);
status_t write(FILE* fp);
- //unsigned long mSignature;
- unsigned short mDiskNumber;
- unsigned short mDiskWithCentralDir;
- unsigned short mNumEntries;
- unsigned short mTotalNumEntries;
- unsigned long mCentralDirSize;
- unsigned long mCentralDirOffset; // offset from first disk
- unsigned short mCommentLen;
- unsigned char* mComment;
+ //uint32_t mSignature;
+ uint16_t mDiskNumber;
+ uint16_t mDiskWithCentralDir;
+ uint16_t mNumEntries;
+ uint16_t mTotalNumEntries;
+ uint32_t mCentralDirSize;
+ uint32_t mCentralDirOffset; // offset from first disk
+ uint16_t mCommentLen;
+ uint8_t* mComment;
enum {
kSignature = 0x06054b50,
@@ -235,18 +235,18 @@
ZipEntry** ppEntry);
/* copy all of "srcFp" into "dstFp" */
- status_t copyFpToFp(FILE* dstFp, FILE* srcFp, unsigned long* pCRC32);
+ status_t copyFpToFp(FILE* dstFp, FILE* srcFp, uint32_t* pCRC32);
/* copy all of "data" into "dstFp" */
status_t copyDataToFp(FILE* dstFp,
- const void* data, size_t size, unsigned long* pCRC32);
+ const void* data, size_t size, uint32_t* pCRC32);
/* copy some of "srcFp" into "dstFp" */
status_t copyPartialFpToFp(FILE* dstFp, FILE* srcFp, long length,
- unsigned long* pCRC32);
+ uint32_t* pCRC32);
/* like memmove(), but on parts of a single file */
status_t filemove(FILE* fp, off_t dest, off_t src, size_t n);
/* compress all of "srcFp" into "dstFp", using Deflate */
status_t compressFpToFp(FILE* dstFp, FILE* srcFp,
- const void* data, size_t size, unsigned long* pCRC32);
+ const void* data, size_t size, uint32_t* pCRC32);
/* get modification date from a file descriptor */
time_t getModTime(int fd);
diff --git a/tools/check_prereq/Android.mk b/tools/ziptime/Android.mk
similarity index 65%
rename from tools/check_prereq/Android.mk
rename to tools/ziptime/Android.mk
index 4329aff..3575229 100644
--- a/tools/check_prereq/Android.mk
+++ b/tools/ziptime/Android.mk
@@ -1,4 +1,5 @@
-# Copyright (C) 2009 The Android Open Source Project
+#
+# Copyright 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -11,15 +12,21 @@
# 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.
+#
-LOCAL_PATH := $(call my-dir)
+#
+# Zip timestamp removal tool
+#
+
+LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := check_prereq.c
-LOCAL_MODULE := check_prereq
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_MODULE_TAGS := eng
-LOCAL_C_INCLUDES +=
-LOCAL_STATIC_LIBRARIES += libcutils libc
+LOCAL_SRC_FILES := \
+ ZipTime.cpp \
+ ZipEntry.cpp \
+ ZipFile.cpp
-include $(BUILD_EXECUTABLE)
+LOCAL_MODULE := ziptime
+LOCAL_MODULE_HOST_OS := darwin linux windows
+
+include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/ziptime/README.txt b/tools/ziptime/README.txt
new file mode 100644
index 0000000..8a101e9
--- /dev/null
+++ b/tools/ziptime/README.txt
@@ -0,0 +1,10 @@
+ziptime -- zip timestamp tool
+
+usage: ziptime file.zip
+
+ file.zip is an existing Zip archive to rewrite
+
+
+This tools replaces the timestamps in the zip headers with a static time
+(Jan 1 2008). The extra fields are not changed, so you'll need to use the
+-X option to zip so that it doesn't create the 'universal time' extra.
diff --git a/tools/ziptime/ZipEntry.cpp b/tools/ziptime/ZipEntry.cpp
new file mode 100644
index 0000000..51ce09f
--- /dev/null
+++ b/tools/ziptime/ZipEntry.cpp
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2006 The Android Open Source 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.
+ */
+
+//
+// Access to entries in a Zip archive.
+//
+
+#include "ZipEntry.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <inttypes.h>
+
+using namespace android;
+
+#define LOG(...) fprintf(stderr, __VA_ARGS__)
+
+/* Jan 01 2008 */
+#define STATIC_DATE (28 << 9 | 1 << 5 | 1)
+#define STATIC_TIME 0
+
+/*
+ * Initialize a new ZipEntry structure from a FILE* positioned at a
+ * CentralDirectoryEntry. Rewrites the headers to remove the dynamic
+ * timestamps.
+ *
+ * On exit, the file pointer will be at the start of the next CDE or
+ * at the EOCD.
+ */
+status_t ZipEntry::initAndRewriteFromCDE(FILE* fp)
+{
+ status_t result;
+ long posn;
+
+ /* read the CDE */
+ result = mCDE.rewrite(fp);
+ if (result != 0) {
+ LOG("mCDE.rewrite failed\n");
+ return result;
+ }
+
+ /* using the info in the CDE, go load up the LFH */
+ posn = ftell(fp);
+ if (fseek(fp, mCDE.mLocalHeaderRelOffset, SEEK_SET) != 0) {
+ LOG("local header seek failed (%" PRIu32 ")\n",
+ mCDE.mLocalHeaderRelOffset);
+ return -1;
+ }
+
+ result = mLFH.rewrite(fp);
+ if (result != 0) {
+ LOG("mLFH.rewrite failed\n");
+ return result;
+ }
+
+ if (fseek(fp, posn, SEEK_SET) != 0)
+ return -1;
+
+ return 0;
+}
+
+/*
+ * ===========================================================================
+ * ZipEntry::LocalFileHeader
+ * ===========================================================================
+ */
+
+/*
+ * Rewrite a local file header.
+ *
+ * On entry, "fp" points to the signature at the start of the header.
+ */
+status_t ZipEntry::LocalFileHeader::rewrite(FILE* fp)
+{
+ status_t result = 0;
+ uint8_t buf[kLFHLen];
+
+ if (fread(buf, 1, kLFHLen, fp) != kLFHLen)
+ return -1;
+
+ if (ZipEntry::getLongLE(&buf[0x00]) != kSignature) {
+ LOG("whoops: didn't find expected signature\n");
+ return -1;
+ }
+
+ ZipEntry::putShortLE(&buf[0x0a], STATIC_TIME);
+ ZipEntry::putShortLE(&buf[0x0c], STATIC_DATE);
+
+ if (fseek(fp, -kLFHLen, SEEK_CUR) != 0)
+ return -1;
+
+ if (fwrite(buf, 1, kLFHLen, fp) != kLFHLen)
+ return -1;
+
+ return 0;
+}
+
+/*
+ * ===========================================================================
+ * ZipEntry::CentralDirEntry
+ * ===========================================================================
+ */
+
+/*
+ * Read and rewrite the central dir entry that appears next in the file.
+ *
+ * On entry, "fp" should be positioned on the signature bytes for the
+ * entry. On exit, "fp" will point at the signature word for the next
+ * entry or for the EOCD.
+ */
+status_t ZipEntry::CentralDirEntry::rewrite(FILE* fp)
+{
+ status_t result = 0;
+ uint8_t buf[kCDELen];
+ uint16_t fileNameLength, extraFieldLength, fileCommentLength;
+
+ if (fread(buf, 1, kCDELen, fp) != kCDELen)
+ return -1;
+
+ if (ZipEntry::getLongLE(&buf[0x00]) != kSignature) {
+ LOG("Whoops: didn't find expected signature\n");
+ return -1;
+ }
+
+ ZipEntry::putShortLE(&buf[0x0c], STATIC_TIME);
+ ZipEntry::putShortLE(&buf[0x0e], STATIC_DATE);
+
+ fileNameLength = ZipEntry::getShortLE(&buf[0x1c]);
+ extraFieldLength = ZipEntry::getShortLE(&buf[0x1e]);
+ fileCommentLength = ZipEntry::getShortLE(&buf[0x20]);
+ mLocalHeaderRelOffset = ZipEntry::getLongLE(&buf[0x2a]);
+
+ if (fseek(fp, -kCDELen, SEEK_CUR) != 0)
+ return -1;
+
+ if (fwrite(buf, 1, kCDELen, fp) != kCDELen)
+ return -1;
+
+ if (fseek(fp, fileNameLength + extraFieldLength + fileCommentLength, SEEK_CUR) != 0)
+ return -1;
+
+ return 0;
+}
diff --git a/tools/ziptime/ZipEntry.h b/tools/ziptime/ZipEntry.h
new file mode 100644
index 0000000..26bf596
--- /dev/null
+++ b/tools/ziptime/ZipEntry.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2006 The Android Open Source 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.
+ */
+
+//
+// Zip archive entries.
+//
+// The ZipEntry class is tightly meshed with the ZipFile class.
+//
+#ifndef __LIBS_ZIPENTRY_H
+#define __LIBS_ZIPENTRY_H
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+
+typedef int status_t;
+
+namespace android {
+
+class ZipFile;
+
+/*
+ * ZipEntry objects represent a single entry in a Zip archive.
+ *
+ * File information is stored in two places: next to the file data (the Local
+ * File Header, and possibly a Data Descriptor), and at the end of the file
+ * (the Central Directory Entry). The two must be kept in sync.
+ */
+class ZipEntry {
+public:
+ friend class ZipFile;
+
+ ZipEntry(void) {}
+ ~ZipEntry(void) {}
+
+ /*
+ * Some basic functions for raw data manipulation. "LE" means
+ * Little Endian.
+ */
+ static inline uint16_t getShortLE(const uint8_t* buf) {
+ return buf[0] | (buf[1] << 8);
+ }
+ static inline uint32_t getLongLE(const uint8_t* buf) {
+ return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
+ }
+ static inline void putShortLE(uint8_t* buf, uint16_t val) {
+ buf[0] = (uint8_t) val;
+ buf[1] = (uint8_t) (val >> 8);
+ }
+
+protected:
+ /*
+ * Initialize the structure from the file, which is pointing at
+ * our Central Directory entry. And rewrite it.
+ */
+ status_t initAndRewriteFromCDE(FILE* fp);
+
+private:
+ /* these are private and not defined */
+ ZipEntry(const ZipEntry& src);
+ ZipEntry& operator=(const ZipEntry& src);
+
+ /*
+ * Every entry in the Zip archive starts off with one of these.
+ */
+ class LocalFileHeader {
+ public:
+ LocalFileHeader(void) {}
+
+ status_t rewrite(FILE* fp);
+
+ enum {
+ kSignature = 0x04034b50,
+ kLFHLen = 30, // LocalFileHdr len, excl. var fields
+ };
+ };
+
+ /*
+ * Every entry in the Zip archive has one of these in the "central
+ * directory" at the end of the file.
+ */
+ class CentralDirEntry {
+ public:
+ CentralDirEntry(void) :
+ mLocalHeaderRelOffset(0)
+ {}
+
+ status_t rewrite(FILE* fp);
+
+ uint32_t mLocalHeaderRelOffset;
+
+ enum {
+ kSignature = 0x02014b50,
+ kCDELen = 46, // CentralDirEnt len, excl. var fields
+ };
+ };
+
+ LocalFileHeader mLFH;
+ CentralDirEntry mCDE;
+};
+
+}; // namespace android
+
+#endif // __LIBS_ZIPENTRY_H
diff --git a/tools/ziptime/ZipFile.cpp b/tools/ziptime/ZipFile.cpp
new file mode 100644
index 0000000..1d111af
--- /dev/null
+++ b/tools/ziptime/ZipFile.cpp
@@ -0,0 +1,241 @@
+/*
+ * Copyright (C) 2006 The Android Open Source 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.
+ */
+
+//
+// Access to Zip archives.
+//
+
+#include "ZipFile.h"
+
+#include <memory.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <assert.h>
+#include <inttypes.h>
+
+using namespace android;
+
+#define LOG(...) fprintf(stderr, __VA_ARGS__)
+
+/*
+ * Open a file and rewrite the headers
+ */
+status_t ZipFile::rewrite(const char* zipFileName)
+{
+ assert(mZipFp == NULL); // no reopen
+
+ /* open the file */
+ mZipFp = fopen(zipFileName, "r+b");
+ if (mZipFp == NULL) {
+ int err = errno;
+ LOG("fopen failed: %d\n", err);
+ return -1;
+ }
+
+ /*
+ * Load the central directory. If that fails, then this probably
+ * isn't a Zip archive.
+ */
+ return rewriteCentralDir();
+}
+
+/*
+ * Find the central directory, read and rewrite the contents.
+ *
+ * The fun thing about ZIP archives is that they may or may not be
+ * readable from start to end. In some cases, notably for archives
+ * that were written to stdout, the only length information is in the
+ * central directory at the end of the file.
+ *
+ * Of course, the central directory can be followed by a variable-length
+ * comment field, so we have to scan through it backwards. The comment
+ * is at most 64K, plus we have 18 bytes for the end-of-central-dir stuff
+ * itself, plus apparently sometimes people throw random junk on the end
+ * just for the fun of it.
+ *
+ * This is all a little wobbly. If the wrong value ends up in the EOCD
+ * area, we're hosed. This appears to be the way that everbody handles
+ * it though, so we're in pretty good company if this fails.
+ */
+status_t ZipFile::rewriteCentralDir(void)
+{
+ status_t result = 0;
+ uint8_t* buf = NULL;
+ off_t fileLength, seekStart;
+ long readAmount;
+ int i;
+
+ fseek(mZipFp, 0, SEEK_END);
+ fileLength = ftell(mZipFp);
+ rewind(mZipFp);
+
+ /* too small to be a ZIP archive? */
+ if (fileLength < EndOfCentralDir::kEOCDLen) {
+ LOG("Length is %ld -- too small\n", (long)fileLength);
+ result = -1;
+ goto bail;
+ }
+
+ buf = new uint8_t[EndOfCentralDir::kMaxEOCDSearch];
+ if (buf == NULL) {
+ LOG("Failure allocating %d bytes for EOCD search",
+ EndOfCentralDir::kMaxEOCDSearch);
+ result = -1;
+ goto bail;
+ }
+
+ if (fileLength > EndOfCentralDir::kMaxEOCDSearch) {
+ seekStart = fileLength - EndOfCentralDir::kMaxEOCDSearch;
+ readAmount = EndOfCentralDir::kMaxEOCDSearch;
+ } else {
+ seekStart = 0;
+ readAmount = (long) fileLength;
+ }
+ if (fseek(mZipFp, seekStart, SEEK_SET) != 0) {
+ LOG("Failure seeking to end of zip at %ld", (long) seekStart);
+ result = -1;
+ goto bail;
+ }
+
+ /* read the last part of the file into the buffer */
+ if (fread(buf, 1, readAmount, mZipFp) != (size_t) readAmount) {
+ LOG("short file? wanted %ld\n", readAmount);
+ result = -1;
+ goto bail;
+ }
+
+ /* find the end-of-central-dir magic */
+ for (i = readAmount - 4; i >= 0; i--) {
+ if (buf[i] == 0x50 &&
+ ZipEntry::getLongLE(&buf[i]) == EndOfCentralDir::kSignature)
+ {
+ break;
+ }
+ }
+ if (i < 0) {
+ LOG("EOCD not found, not Zip\n");
+ result = -1;
+ goto bail;
+ }
+
+ /* extract eocd values */
+ result = mEOCD.readBuf(buf + i, readAmount - i);
+ if (result != 0) {
+ LOG("Failure reading %ld bytes of EOCD values", readAmount - i);
+ goto bail;
+ }
+
+ /*
+ * So far so good. "mCentralDirSize" is the size in bytes of the
+ * central directory, so we can just seek back that far to find it.
+ * We can also seek forward mCentralDirOffset bytes from the
+ * start of the file.
+ *
+ * We're not guaranteed to have the rest of the central dir in the
+ * buffer, nor are we guaranteed that the central dir will have any
+ * sort of convenient size. We need to skip to the start of it and
+ * read the header, then the other goodies.
+ *
+ * The only thing we really need right now is the file comment, which
+ * we're hoping to preserve.
+ */
+ if (fseek(mZipFp, mEOCD.mCentralDirOffset, SEEK_SET) != 0) {
+ LOG("Failure seeking to central dir offset %" PRIu32 "\n",
+ mEOCD.mCentralDirOffset);
+ result = -1;
+ goto bail;
+ }
+
+ /*
+ * Loop through and read the central dir entries.
+ */
+ int entry;
+ for (entry = 0; entry < mEOCD.mTotalNumEntries; entry++) {
+ ZipEntry* pEntry = new ZipEntry;
+
+ result = pEntry->initAndRewriteFromCDE(mZipFp);
+ if (result != 0) {
+ LOG("initFromCDE failed\n");
+ delete pEntry;
+ goto bail;
+ }
+
+ delete pEntry;
+ }
+
+
+ /*
+ * If all went well, we should now be back at the EOCD.
+ */
+ uint8_t checkBuf[4];
+ if (fread(checkBuf, 1, 4, mZipFp) != 4) {
+ LOG("EOCD check read failed\n");
+ result = -1;
+ goto bail;
+ }
+ if (ZipEntry::getLongLE(checkBuf) != EndOfCentralDir::kSignature) {
+ LOG("EOCD read check failed\n");
+ result = -1;
+ goto bail;
+ }
+
+bail:
+ delete[] buf;
+ return result;
+}
+
+/*
+ * ===========================================================================
+ * ZipFile::EndOfCentralDir
+ * ===========================================================================
+ */
+
+/*
+ * Read the end-of-central-dir fields.
+ *
+ * "buf" should be positioned at the EOCD signature, and should contain
+ * the entire EOCD area including the comment.
+ */
+status_t ZipFile::EndOfCentralDir::readBuf(const uint8_t* buf, int len)
+{
+ uint16_t diskNumber, diskWithCentralDir, numEntries;
+
+ if (len < kEOCDLen) {
+ /* looks like ZIP file got truncated */
+ LOG(" Zip EOCD: expected >= %d bytes, found %d\n",
+ kEOCDLen, len);
+ return -1;
+ }
+
+ /* this should probably be an assert() */
+ if (ZipEntry::getLongLE(&buf[0x00]) != kSignature)
+ return -1;
+
+ diskNumber = ZipEntry::getShortLE(&buf[0x04]);
+ diskWithCentralDir = ZipEntry::getShortLE(&buf[0x06]);
+ numEntries = ZipEntry::getShortLE(&buf[0x08]);
+ mTotalNumEntries = ZipEntry::getShortLE(&buf[0x0a]);
+ mCentralDirOffset = ZipEntry::getLongLE(&buf[0x10]);
+
+ if (diskNumber != 0 || diskWithCentralDir != 0 ||
+ numEntries != mTotalNumEntries)
+ {
+ LOG("Archive spanning not supported\n");
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/tools/ziptime/ZipFile.h b/tools/ziptime/ZipFile.h
new file mode 100644
index 0000000..b049e05
--- /dev/null
+++ b/tools/ziptime/ZipFile.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2006 The Android Open Source 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.
+ */
+
+//
+// Class to rewrite zip file headers to remove dynamic timestamps.
+//
+#ifndef __LIBS_ZIPFILE_H
+#define __LIBS_ZIPFILE_H
+
+#include <stdio.h>
+
+#include "ZipEntry.h"
+
+namespace android {
+
+/*
+ * Manipulate a Zip archive.
+ */
+class ZipFile {
+public:
+ ZipFile(void) : mZipFp(NULL) {}
+ ~ZipFile(void) {
+ if (mZipFp != NULL)
+ fclose(mZipFp);
+ }
+
+ /*
+ * Rewrite an archive's headers to remove dynamic timestamps.
+ */
+ status_t rewrite(const char* zipFileName);
+
+private:
+ /* these are private and not defined */
+ ZipFile(const ZipFile& src);
+ ZipFile& operator=(const ZipFile& src);
+
+ class EndOfCentralDir {
+ public:
+ EndOfCentralDir(void) : mTotalNumEntries(0), mCentralDirOffset(0) {}
+
+ status_t readBuf(const uint8_t* buf, int len);
+
+ uint16_t mTotalNumEntries;
+ uint32_t mCentralDirOffset; // offset from first disk
+
+ enum {
+ kSignature = 0x06054b50,
+ kEOCDLen = 22, // EndOfCentralDir len, excl. comment
+
+ kMaxCommentLen = 65535, // longest possible in ushort
+ kMaxEOCDSearch = kMaxCommentLen + EndOfCentralDir::kEOCDLen,
+
+ };
+ };
+
+ /* read all entries in the central dir */
+ status_t rewriteCentralDir(void);
+
+ /*
+ * We use stdio FILE*, which gives us buffering but makes dealing
+ * with files >2GB awkward. Until we support Zip64, we're fine.
+ */
+ FILE* mZipFp; // Zip file pointer
+
+ /* one of these per file */
+ EndOfCentralDir mEOCD;
+};
+
+}; // namespace android
+
+#endif // __LIBS_ZIPFILE_H
diff --git a/tools/ziptime/ZipTime.cpp b/tools/ziptime/ZipTime.cpp
new file mode 100644
index 0000000..99d3231
--- /dev/null
+++ b/tools/ziptime/ZipTime.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 The Android Open Source 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.
+ */
+
+/*
+ * Zip tool to remove dynamic timestamps
+ */
+#include "ZipFile.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+using namespace android;
+
+static void usage(void)
+{
+ fprintf(stderr, "Zip timestamp utility\n");
+ fprintf(stderr, "Copyright (C) 2015 The Android Open Source Project\n\n");
+ fprintf(stderr, "Usage: ziptime file.zip\n");
+}
+
+int main(int argc, char* const argv[])
+{
+ if (argc != 2) {
+ usage();
+ return 2;
+ }
+
+ ZipFile zip;
+ if (zip.rewrite(argv[1]) != 0) {
+ fprintf(stderr, "Unable to rewrite '%s' as zip archive\n", argv[1]);
+ return 1;
+ }
+
+ return 0;
+}