forked from kalyankondapally/bootable-live-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Android.mk
82 lines (72 loc) · 3.42 KB
/
Android.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ifeq ($(HOST_OS),linux)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
../../system/core/libdiskconfig/diskconfig.c \
../../system/core/libdiskconfig/diskutils.c \
../../system/core/libdiskconfig/write_lst.c \
../../system/core/libdiskconfig/config_mbr.c
LOCAL_C_INCLUDES += system/core/libdiskconfig/include
LOCAL_MODULE := libdiskconfig_host_grub
LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS := -O2 -g -W -Wall -Werror -D_LARGEFILE64_SOURCE
include $(BUILD_HOST_STATIC_LIBRARY)
endif # HOST_OS == linux
include $(CLEAR_VARS)
LOCAL_MODULE := install_mbr
LOCAL_C_INCLUDES += system/core/libdiskconfig/include
LOCAL_SRC_FILES := editdisklbl/editdisklbl.c
LOCAL_CFLAGS := -O2 -g -W -Wall -Werror# -D_LARGEFILE64_SOURCE
LOCAL_STATIC_LIBRARIES := libdiskconfig_host_grub libcutils liblog
install_mbr := $(HOST_OUT_EXECUTABLES)/$(LOCAL_MODULE)
UNSPARSER := $(HOST_OUT_EXECUTABLES)/simg2img
SQUASHER := $(HOST_OUT_EXECUTABLES)/mksquashfs
include $(BUILD_HOST_EXECUTABLE)
ifeq ($(CI_BUILD),true)
GRUB_TIMEOUT := 1
GRUB_DEFAULT := 2
else
GRUB_TIMEOUT := 10
GRUB_DEFAULT := 0
endif
BDATE ?= $(shell date +"%F")
TARGET_INITRD_DIR := $(PRODUCT_OUT)/initrd
LOCAL_INITRD_DIR := $(LOCAL_PATH)/initrd
BOOT_DIR := $(LOCAL_PATH)/boot
INITRD := $(PRODUCT_OUT)/initrd.img
$(INITRD): $(LOCAL_PATH)/initrd/init $(wildcard $(LOCAL_PATH)/initrd/*/*) | $(MKBOOTFS)
rm -rf $(TARGET_INITRD_DIR)
$(ACP) -dprf $(LOCAL_INITRD_DIR) $(TARGET_INITRD_DIR)
echo "BUILDDATE=$(BDATE)" > $(TARGET_INITRD_DIR)/scripts/3-buildinfo
echo "CI_BUILD=$(CI_BUILD)" >> $(TARGET_INITRD_DIR)/scripts/3-buildinfo
sed "s|SERIAL_PORT|$(SERIAL_PARAMETER)|" $(LOCAL_INITRD_DIR)/scripts/2-install > $(TARGET_INITRD_DIR)/scripts/2-install
mkdir -p $(addprefix $(TARGET_INITRD_DIR)/,mnt proc sys tmp dev etc lib newroot sbin usr/bin usr/sbin scratchpad)
$(MKBOOTFS) $(TARGET_INITRD_DIR) | gzip -9 > $@
$(PRODUCT_OUT)/vendor.sfs : $(PRODUCT_OUT)/vendor.img | $(UNSPARSER) $(SQUASHER)
simg2img $(PRODUCT_OUT)/{vendor.img,vendor.unsparse}
mksquashfs $(PRODUCT_OUT)/{vendor.unsparse,vendor.sfs} -noappend
rm $(PRODUCT_OUT)/vendor.{img,unsparse}
$(PRODUCT_OUT)/system.sfs : $(PRODUCT_OUT)/system.img | $(UNSPARSER) $(SQUASHER)
simg2img $(PRODUCT_OUT)/{system.img,system.unsparse}
mksquashfs $(PRODUCT_OUT)/{system.unsparse,system.sfs} -noappend
rm $(PRODUCT_OUT)/system.{img,unsparse}
# 1. Compute the disk file size need in blocks for a block size of 1M
# 2. Prepare a vfat disk file and copy necessary files
# 3. Copy GRUB2 files
ANDROID_IA-EFI := $(PRODUCT_OUT)/$(TARGET_PRODUCT).img
DISK_LAYOUT := $(LOCAL_PATH)/editdisklbl/disk_layout.conf
$(ANDROID_IA-EFI): $(addprefix $(PRODUCT_OUT)/,initrd.img kernel ramdisk.img system.sfs vendor.sfs ) | $(install_mbr)
blksize=0; \
for size in `du -sBM --apparent-size $^ | awk '{print $$1}' | cut -d'M' -f1`; do \
blksize=$$(($$blksize + $$size)); \
done; \
blksize=$$(($$(($$blksize + 64)) * 1024)); \
rm -f [email protected]; mkdosfs -n ANDROID-IA -C [email protected] $$blksize
mcopy -Qsi [email protected] $(BOOT_DIR)/* $^ ::
sed "s|KERNEL_CMDLINE|$(BOARD_KERNEL_CMDLINE)|; s|BUILDDATE|$(BDATE)|; s|GRUB_DEFAULT|$(GRUB_DEFAULT)|; s|GRUB_TIMEOUT|$(GRUB_TIMEOUT)|; s|SERIAL_PORT|$(SERIAL_PARAMETER)|; s|console=ttyS[^ ]* ||" $(BOOT_DIR)/boot/grub/grub.cfg > $(@D)/grub.cfg
mcopy -Qoi [email protected] $(@D)/grub.cfg ::boot/grub
cat /dev/null > $@; $(install_mbr) -l $(DISK_LAYOUT) -i $@ [email protected]
rm -f [email protected]
.PHONY: android_ia-efi
android_ia-efi: $(ANDROID_IA-EFI)