| 1 |
# note: requires x86 because we assume grub is the mbr bootloader. |
| 2 |
ifeq ($(TARGET_ARCH),x86) |
| 3 |
ifeq ($(TARGET_USE_DISKINSTALLER),true) |
| 4 |
|
| 5 |
diskinstaller_root := bootable/diskinstaller |
| 6 |
|
| 7 |
android_sysbase_modules := \ |
| 8 |
libc \ |
| 9 |
libcutils \ |
| 10 |
libdl \ |
| 11 |
liblog \ |
| 12 |
libm \ |
| 13 |
libstdc++ \ |
| 14 |
linker \ |
| 15 |
sh \ |
| 16 |
toolbox \ |
| 17 |
logcat \ |
| 18 |
gdbserver \ |
| 19 |
strace \ |
| 20 |
netcfg |
| 21 |
android_sysbase_files = \ |
| 22 |
$(call module-installed-files,$(android_sysbase_modules)) |
| 23 |
|
| 24 |
# $(1): source base dir |
| 25 |
# $(2): target base dir |
| 26 |
define sysbase-copy-files |
| 27 |
$(hide) $(foreach _f,$(android_sysbase_files), \ |
| 28 |
f=$(patsubst $(1)/%,$(2)/%,$(_f)); \ |
| 29 |
mkdir -p `dirname $$f`; \ |
| 30 |
echo "Copy: $$f" ; \ |
| 31 |
cp -fR $(_f) $$f; \ |
| 32 |
) |
| 33 |
endef |
| 34 |
|
| 35 |
installer_base_modules := \ |
| 36 |
libdiskconfig \ |
| 37 |
libext2fs \ |
| 38 |
libext2_com_err \ |
| 39 |
libext2_e2p \ |
| 40 |
libext2_blkid \ |
| 41 |
libext2_uuid \ |
| 42 |
libext2_profile \ |
| 43 |
badblocks \ |
| 44 |
resize2fs \ |
| 45 |
tune2fs \ |
| 46 |
mke2fs \ |
| 47 |
e2fsck |
| 48 |
installer_base_files = \ |
| 49 |
$(call module-built-files,$(installer_base_modules)) |
| 50 |
|
| 51 |
# $(1): source base dir |
| 52 |
# $(2): target base dir |
| 53 |
define installer-copy-modules |
| 54 |
$(hide) $(foreach m,$(installer_base_modules), \ |
| 55 |
src=$(firstword $(strip $(call module-built-files,$(m)))); \ |
| 56 |
dest=$(patsubst $(strip $(1))/%,$(strip $(2))/%,\ |
| 57 |
$(firstword $(strip $(call module-installed-files,$(m))))); \ |
| 58 |
echo "Copy: $$src -> $$dest"; \ |
| 59 |
mkdir -p `dirname $$dest`; \ |
| 60 |
cp -fdp $$src $$dest; \ |
| 61 |
) |
| 62 |
endef |
| 63 |
|
| 64 |
# Build the installer ramdisk image |
| 65 |
installer_initrc := $(diskinstaller_root)/init.rc |
| 66 |
installer_kernel := $(INSTALLED_KERNEL_TARGET) |
| 67 |
installer_ramdisk := $(TARGET_INSTALLER_OUT)/ramdisk-installer.img |
| 68 |
installer_build_prop := $(INSTALLED_BUILD_PROP_TARGET) |
| 69 |
installer_config := $(diskinstaller_root)/installer.conf |
| 70 |
installer_binary := \ |
| 71 |
$(call intermediates-dir-for,EXECUTABLES,diskinstaller)/diskinstaller |
| 72 |
|
| 73 |
$(installer_ramdisk): $(diskinstaller_root)/config.mk \ |
| 74 |
$(MKBOOTFS) \ |
| 75 |
$(INSTALLED_RAMDISK_TARGET) \ |
| 76 |
$(INSTALLED_BOOTIMAGE_TARGET) \ |
| 77 |
$(TARGET_DISK_LAYOUT_CONFIG) \ |
| 78 |
$(installer_binary) \ |
| 79 |
$(installer_initrc) \ |
| 80 |
$(installer_kernel) \ |
| 81 |
$(installer_config) \ |
| 82 |
$(android_sysbase_files) \ |
| 83 |
$(installer_base_files) \ |
| 84 |
$(installer_build_prop) |
| 85 |
@echo ----- Making installer image ------ |
| 86 |
rm -rf $(TARGET_INSTALLER_OUT) |
| 87 |
mkdir -p $(TARGET_INSTALLER_OUT) |
| 88 |
mkdir -p $(TARGET_INSTALLER_ROOT_OUT) |
| 89 |
mkdir -p $(TARGET_INSTALLER_ROOT_OUT)/sbin |
| 90 |
mkdir -p $(TARGET_INSTALLER_ROOT_OUT)/data |
| 91 |
mkdir -p $(TARGET_INSTALLER_SYSTEM_OUT) |
| 92 |
mkdir -p $(TARGET_INSTALLER_SYSTEM_OUT)/etc |
| 93 |
mkdir -p $(TARGET_INSTALLER_SYSTEM_OUT)/bin |
| 94 |
@echo Copying baseline ramdisk... |
| 95 |
cp -fR $(TARGET_ROOT_OUT) $(TARGET_INSTALLER_OUT) |
| 96 |
@echo Copying sysbase files... |
| 97 |
$(call sysbase-copy-files,$(TARGET_OUT),$(TARGET_INSTALLER_SYSTEM_OUT)) |
| 98 |
@echo Copying installer base files... |
| 99 |
$(call installer-copy-modules,$(TARGET_OUT),\ |
| 100 |
$(TARGET_INSTALLER_SYSTEM_OUT)) |
| 101 |
@echo Modifying ramdisk contents... |
| 102 |
cp -f $(installer_initrc) $(TARGET_INSTALLER_ROOT_OUT)/ |
| 103 |
cp -f $(TARGET_DISK_LAYOUT_CONFIG) \ |
| 104 |
$(TARGET_INSTALLER_SYSTEM_OUT)/etc/disk_layout.conf |
| 105 |
cp -f $(installer_config) \ |
| 106 |
$(TARGET_INSTALLER_SYSTEM_OUT)/etc/installer.conf |
| 107 |
cp -f $(installer_binary) $(TARGET_INSTALLER_SYSTEM_OUT)/bin/installer |
| 108 |
$(hide) chmod ug+rw $(TARGET_INSTALLER_ROOT_OUT)/default.prop |
| 109 |
cat $(installer_build_prop) >> $(TARGET_INSTALLER_ROOT_OUT)/default.prop |
| 110 |
$(MKBOOTFS) $(TARGET_INSTALLER_ROOT_OUT) | gzip > $(installer_ramdisk) |
| 111 |
@echo ----- Made installer ramdisk -[ $@ ]- |
| 112 |
|
| 113 |
###################################################################### |
| 114 |
# Now the installer boot image which includes the kernel and the ramdisk |
| 115 |
internal_installerimage_args := \ |
| 116 |
--kernel $(installer_kernel) \ |
| 117 |
--ramdisk $(installer_ramdisk) |
| 118 |
|
| 119 |
internal_installerimage_files := \ |
| 120 |
$(filter-out --%,$(internal_installerimage_args)) |
| 121 |
|
| 122 |
BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE)) |
| 123 |
ifdef BOARD_KERNEL_CMDLINE |
| 124 |
internal_installerimage_args += --cmdline "$(BOARD_KERNEL_CMDLINE)" |
| 125 |
endif |
| 126 |
|
| 127 |
installer_tmp_img := $(TARGET_INSTALLER_OUT)/installer_tmp.img |
| 128 |
tmp_dir_for_inst_image := \ |
| 129 |
$(call intermediates-dir-for,EXECUTABLES,installer_img)/installer_img |
| 130 |
internal_installerimage_args += --tmpdir $(tmp_dir_for_inst_image) |
| 131 |
internal_installerimage_args += --genext2fs $(MKEXT2IMG) |
| 132 |
$(installer_tmp_img): $(MKEXT2IMG) $(internal_installerimage_files) |
| 133 |
$(call pretty,"Target installer image: $@") |
| 134 |
$(hide) $(MKEXT2BOOTIMG) $(internal_installerimage_args) --output $@ |
| 135 |
|
| 136 |
###################################################################### |
| 137 |
# Now make a data image that contains all the target image files for the |
| 138 |
# installer. |
| 139 |
bootldr_bin := $(PRODUCT_OUT)/grub/grub.bin |
| 140 |
installer_target_data_files := \ |
| 141 |
$(INSTALLED_BOOTIMAGE_TARGET) \ |
| 142 |
$(INSTALLED_SYSTEMIMAGE) \ |
| 143 |
$(INSTALLED_USERDATAIMAGE_TARGET) \ |
| 144 |
$(bootldr_bin) |
| 145 |
|
| 146 |
installer_data_img := $(TARGET_INSTALLER_OUT)/installer_data.img |
| 147 |
$(installer_data_img): $(diskinstaller_root)/config.mk \ |
| 148 |
$(installer_target_data_files) \ |
| 149 |
$(MKEXT2IMG) \ |
| 150 |
$(installer_ramdisk) |
| 151 |
@echo --- Making installer data image ------ |
| 152 |
mkdir -p $(TARGET_INSTALLER_OUT) |
| 153 |
mkdir -p $(TARGET_INSTALLER_OUT)/data |
| 154 |
cp -f $(bootldr_bin) $(TARGET_INSTALLER_OUT)/data/bootldr.bin |
| 155 |
cp -f $(INSTALLED_BOOTIMAGE_TARGET) $(TARGET_INSTALLER_OUT)/data/boot.img |
| 156 |
cp -f $(INSTALLED_SYSTEMIMAGE) \ |
| 157 |
$(TARGET_INSTALLER_OUT)/data/system.img |
| 158 |
cp -f $(INSTALLED_USERDATAIMAGE_TARGET) \ |
| 159 |
$(TARGET_INSTALLER_OUT)/data/userdata.img |
| 160 |
$(call build-userimage-ext2-target,$(TARGET_INSTALLER_OUT)/data,$@,\ |
| 161 |
inst_data,) |
| 162 |
@echo --- Finished installer data image -[ $@ ]- |
| 163 |
|
| 164 |
###################################################################### |
| 165 |
# now combine the installer image with the grub bootloader |
| 166 |
grub_bin := $(PRODUCT_OUT)/grub/grub.bin |
| 167 |
installer_layout := $(diskinstaller_root)/installer_img_layout.conf |
| 168 |
edit_mbr := $(HOST_OUT_EXECUTABLES)/editdisklbl |
| 169 |
|
| 170 |
INSTALLED_DISKINSTALLERIMAGE_TARGET := $(PRODUCT_OUT)/installer.img |
| 171 |
$(INSTALLED_DISKINSTALLERIMAGE_TARGET): \ |
| 172 |
$(installer_tmp_img) \ |
| 173 |
$(installer_data_img) \ |
| 174 |
$(grub_bin) \ |
| 175 |
$(edit_mbr) \ |
| 176 |
$(installer_layout) |
| 177 |
@echo "Creating bootable installer image: $@" |
| 178 |
@rm -f $@ |
| 179 |
@cat $(grub_bin) > $@ |
| 180 |
@$(edit_mbr) -l $(installer_layout) -i $@ \ |
| 181 |
inst_boot=$(installer_tmp_img) \ |
| 182 |
inst_data=$(installer_data_img) |
| 183 |
@echo "Done with bootable installer image -[ $@ ]-" |
| 184 |
|
| 185 |
else # ! TARGET_USE_DISKINSTALLER |
| 186 |
INSTALLED_DISKINSTALLERIMAGE_TARGET := |
| 187 |
endif |
| 188 |
endif # TARGET_ARCH == x86 |
| 189 |
|
| 190 |
.PHONY: installer_img |
| 191 |
installer_img: $(INSTALLED_DISKINSTALLERIMAGE_TARGET) |