Merge "Continue to use search.html for site searching"
diff --git a/core/Makefile b/core/Makefile
index afb2a48..f66710c 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -348,6 +348,11 @@
   INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
 endif
 
+BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
+ifdef BOARD_KERNEL_PAGESIZE
+  INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
+endif
+
 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
 
 ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
@@ -622,6 +627,10 @@
 ifdef BOARD_KERNEL_BASE
   INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
 endif
+BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
+ifdef BOARD_KERNEL_PAGESIZE
+  INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
+endif
 
 # Keys authorized to sign OTA packages this build will accept.  The
 # build always uses test-keys for this; release packaging tools will
@@ -992,6 +1001,9 @@
 ifdef BOARD_KERNEL_BASE
 	$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
 endif
+ifdef BOARD_KERNEL_PAGESIZE
+	$(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
+endif
 	@# Components of the boot image
 	$(hide) mkdir -p $(zip_root)/BOOT
 	$(hide) $(call package_files-copy-root, \
@@ -1009,6 +1021,9 @@
 ifdef BOARD_KERNEL_BASE
 	$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
 endif
+ifdef BOARD_KERNEL_PAGESIZE
+	$(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
+endif
 	$(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
 	            mkdir -p $(zip_root)/RADIO; \
 	            $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
@@ -1053,6 +1068,9 @@
 	$(hide) echo "partition_type=MTD" >> $(zip_root)/META/misc_info.txt
 endif
 	$(hide) echo "$(tool_extensions)" > $(zip_root)/META/tool-extensions.txt
+ifdef mkyaffs2_extra_flags
+	$(hide) echo "$(mkyaffs2_extra_flags)" > $(zip_root)/META/mkyaffs2-extra-flags.txt
+endif
 	@# Zip everything up, preserving symlinks
 	$(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
 	@# Run fs_config on all the system files in the zip, and save the output
@@ -1068,6 +1086,7 @@
 ifneq ($(TARGET_SIMULATOR),true)
 ifneq ($(TARGET_PRODUCT),sdk)
 ifneq ($(TARGET_DEVICE),generic)
+ifneq ($(TARGET_NO_KERNEL),true)
 
 name := $(TARGET_PRODUCT)
 ifeq ($(TARGET_BUILD_TYPE),debug)
@@ -1081,7 +1100,7 @@
 
 $(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
 	@echo "Package OTA: $@"
-	$(hide) ./build/tools/releasetools/ota_from_target_files \
+	$(hide) ./build/tools/releasetools/ota_from_target_files -v \
 	   -p $(HOST_OUT) \
            -k $(KEY_CERT_PAIR) \
            $(BUILT_TARGET_FILES_PACKAGE) $@
@@ -1089,6 +1108,7 @@
 .PHONY: otapackage
 otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
 
+endif    # TARGET_NO_KERNEL != true
 endif    # TARGET_DEVICE != generic
 endif    # TARGET_PRODUCT != sdk
 endif    # TARGET_SIMULATOR != true
@@ -1229,7 +1249,7 @@
 
 $(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
 	@echo "Package: $@"
-	$(hide) ./build/tools/releasetools/img_from_target_files \
+	$(hide) ./build/tools/releasetools/img_from_target_files -v \
 	   -s $(extensions) \
 	   -p $(HOST_OUT) \
 	   $(addprefix --fs_type ,$(INTERNAL_USERIMAGES_EXT_VARIANT)) \
diff --git a/core/base_rules.mk b/core/base_rules.mk
index c515313..f813dfb 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -65,7 +65,7 @@
 # Only the tags mentioned in this test are expected to be set by module
 # makefiles. Anything else is either a typo or a source of unexpected
 # behaviors.
-ifneq ($(filter-out user debug eng tests optional samples,$(LOCAL_MODULE_TAGS)),)
+ifneq ($(filter-out user debug eng tests optional samples shell_ash shell_mksh,$(LOCAL_MODULE_TAGS)),)
 $(warning unusual tags $(LOCAL_MODULE_TAGS) on $(LOCAL_MODULE) at $(LOCAL_PATH))
 endif
 
diff --git a/core/build-system.html b/core/build-system.html
index ce5e869..e547185 100644
--- a/core/build-system.html
+++ b/core/build-system.html
@@ -247,6 +247,7 @@
         for <code>eng</code>.
         <ul>
         <li>Installs modules tagged with: <code>eng</code>, <code>debug</code>,
+            <code>shell_</code>$(TARGET_SHELL),
             <code>user</code>, and/or <code>development</code>.
         <li>Installs non-APK modules that have no tags specified.
         <li>Installs APKs according to the product definition files, in
@@ -266,7 +267,7 @@
         <p>
         This is the flavor intended to be the final release bits.
         <ul>
-        <li>Installs modules tagged with <code>user</code>.
+        <li>Installs modules tagged with <code>shell_</code>$(TARGET_SHELL) and <code>user</code>.
         <li>Installs non-APK modules that have no tags specified.
         <li>Installs APKs according to the product definition files; tags
             are ignored for APK modules.
@@ -681,7 +682,8 @@
 <h4>LOCAL_MODULE_TAGS</h4>
 <p>Set <code>LOCAL_MODULE_TAGS</code> to any number of whitespace-separated
 tags.  If the tag list is empty or contains <code>droid</code>, the module
-will get installed as part of a <code>make droid</code>.  Otherwise, it will
+will get installed as part of a <code>make droid</code>.  Modules with the tag
+<code>shell_</code>$(TARGET_SHELL) will also be installed. Otherwise, it will
 only get installed by running <code>make &lt;your-module&gt;</code>
 or with the <code>make all</code> pseudotarget.</p>
 
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index 0aa27b1..121f89b 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -23,6 +23,21 @@
 HOST_GLOBAL_CFLAGS += -m32
 HOST_GLOBAL_LDFLAGS += -m32
 
+# Use the Mac OSX SDK 10.5 if the build host is 10.6
+build_mac_version := $(shell sw_vers -productVersion)
+ifneq ($(filter 10.6.%, $(build_mac_version)),)
+sdk_105_root := /Developer/SDKs/MacOSX10.5.sdk
+ifeq ($(wildcard $(sdk_105_root)),)
+$(warning *****************************************************)
+$(warning * You are building on Mac OSX 10.6.)
+$(warning * Can not find SDK 10.5 at $(sdk_105_root))
+$(warning *****************************************************)
+$(error Stop.)
+endif
+
+HOST_GLOBAL_CFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5
+HOST_GLOBAL_LDFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5
+endif # build_mac_version is 10.6
 
 HOST_GLOBAL_CFLAGS += -fPIC
 HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
diff --git a/core/config.mk b/core/config.mk
index a866435..3f72624 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -108,6 +108,9 @@
 # Default is to prelink modules.
 TARGET_PRELINK_MODULE := true
 
+# Default shell is ash. Other possible value is mksh.
+TARGET_SHELL := ash
+
 # ###############################################################
 # Include sub-configuration files
 # ###############################################################
diff --git a/core/main.mk b/core/main.mk
index ded9d44..c0fe1c3 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -571,7 +571,7 @@
 endif
 # Use tags to get the non-APPS user modules.  Use the product
 # definition files to get the APPS user modules.
-user_MODULES := $(sort $(call get-tagged-modules,user))
+user_MODULES := $(sort $(call get-tagged-modules,user shell_$(TARGET_SHELL)))
 user_MODULES := $(user_MODULES) $(user_PACKAGES)
 
 eng_MODULES := $(sort $(call get-tagged-modules,eng))
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index 9e52d25..26bf6ab 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -12,3 +12,6 @@
 
 # no hardware camera
 USE_CAMERA_STUB := true
+
+# Set /system/bin/sh to mksh, not ash, to test the transition.
+TARGET_SHELL := mksh
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 18ba842..4db9095 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -36,6 +36,7 @@
 OPTIONS.tempfiles = []
 OPTIONS.device_specific = None
 OPTIONS.extras = {}
+OPTIONS.mkyaffs2_extra_flags = None
 
 
 # Values for "certificate" in apkcerts that mean special things.
@@ -103,6 +104,17 @@
       raise
 
 
+def LoadMkyaffs2ExtraFlags():
+  """Load mkyaffs2 extra flags."""
+  try:
+    fn = os.path.join(OPTIONS.input_tmp, "META", "mkyaffs2-extra-flags.txt");
+    if os.access(fn, os.F_OK):
+      OPTIONS.mkyaffs2_extra_flags = open(fn).read().rstrip("\n")
+  except IOError, e:
+    if e.errno == errno.ENOENT:
+      pass
+
+
 def BuildAndAddBootableImage(sourcedir, targetname, output_zip):
   """Take a kernel, cmdline, and ramdisk directory from the input (in
   'sourcedir'), and turn them into a boot image.  Put the boot image
@@ -155,6 +167,11 @@
     cmd.append("--base")
     cmd.append(open(fn).read().rstrip("\n"))
 
+  fn = os.path.join(sourcedir, "pagesize")
+  if os.access(fn, os.F_OK):
+    cmd.append("--pagesize")
+    cmd.append(open(fn).read().rstrip("\n"))
+
   cmd.extend(["--ramdisk", ramdisk_img.name,
               "--output", img.name])
 
diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files
index d180998..b1f67a6 100755
--- a/tools/releasetools/img_from_target_files
+++ b/tools/releasetools/img_from_target_files
@@ -77,8 +77,11 @@
     if "userdata.img" in OPTIONS.max_image_size:
       build_command.append(str(OPTIONS.max_image_size["userdata.img"]))
   else:
-    build_command = ["mkyaffs2image", "-f",
-                     user_dir, img.name]
+    build_command = ["mkyaffs2image", "-f"]
+    if OPTIONS.mkyaffs2_extra_flags is not None:
+      build_command.append(OPTIONS.mkyaffs2_extra_flags);
+    build_command.append(user_dir)
+    build_command.append(img.name)
 
   p = common.Run(build_command);
   p.communicate()
@@ -122,8 +125,11 @@
     if "system.img" in OPTIONS.max_image_size:
       build_command.append(str(OPTIONS.max_image_size["system.img"]))
   else:
-    build_command = ["mkyaffs2image", "-f",
-                     os.path.join(OPTIONS.input_tmp, "system"), img.name]
+    build_command = ["mkyaffs2image", "-f"]
+    if OPTIONS.mkyaffs2_extra_flags is not None:
+      build_command.append(OPTIONS.mkyaffs2_extra_flags);
+    build_command.append(os.path.join(OPTIONS.input_tmp, "system"))
+    build_command.append(img.name)
 
   p = common.Run(build_command)
   p.communicate()
@@ -174,6 +180,8 @@
     print "  image size limits."
     print
 
+  common.LoadMkyaffs2ExtraFlags()
+
   output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED)
 
   common.AddBoot(output_zip)