forked from zhoulihuagithub/bootable-live-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Android.mk
124 lines (106 loc) · 4.71 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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 ($(ENABLE_GRUB_INSTALLER),true)
GRUB_DEFAULT := 0
ifeq ($(CI_BUILD),true)
GRUB_TIMEOUT := 1
else
GRUB_TIMEOUT := 10
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
SERIAL = ttyUSB0
ifeq ($(findstring $(SERIAL),$(SERIAL_PARAMETER)),$(SERIAL))
SERIAL_PARAMETER := console=ttyS0,115200n8
endif
$(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)|; s|CONFIG|config|" $(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)
$(ACP) $(TARGET_DEVICE_DIR)/gpt.ini $(TARGET_INITRD_DIR)/gpt.$(TARGET_PRODUCT).ini
$(MKBOOTFS) $(TARGET_INITRD_DIR) | gzip -9 > $@
ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
$(PRODUCT_OUT)/super.sfs : $(PRODUCT_OUT)/super.img | $(UNSPARSER) $(SQUASHER)
simg2img $(PRODUCT_OUT)/{super.img,super.unsparse}
mksquashfs $(PRODUCT_OUT)/{super.unsparse,super.sfs} -noappend
rm $(PRODUCT_OUT)/super.unsparse
else
$(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.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.unsparse
endif
# 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
PROJECT_CELADON-EFI := $(PRODUCT_OUT)/$(TARGET_PRODUCT)_grubinstaller.img
DISK_LAYOUT := $(LOCAL_PATH)/editdisklbl/disk_layout.conf
ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
GRUB_FILES := $(addprefix $(PRODUCT_OUT)/,initrd.img kernel ramdisk.img super.sfs boot.img efi/kernelflinger.efi)
else
GRUB_FILES := $(addprefix $(PRODUCT_OUT)/,initrd.img kernel ramdisk.img system.sfs vendor.sfs boot.img efi/kernelflinger.efi)
endif
SRC_GRUBCFG := $(BOOT_DIR)/boot/grub/grub.cfg
ifeq ($(BOARD_AVB_ENABLE),true)
GRUB_FILES += $(PRODUCT_OUT)/vbmeta.img
SRC_GRUBCFG := $(BOOT_DIR)/boot/grub/grub_kfonly.cfg
endif
ifneq ($(BOARD_SLOT_AB_ENABLE),true)
GRUB_FILES += $(PRODUCT_OUT)/recovery.img
endif
ifeq ($(TARGET_USE_TRUSTY),true)
GRUB_FILES += $(PRODUCT_OUT)/tos.img
endif
$(PROJECT_CELADON-EFI): $(GRUB_FILES) | $(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 PROJECTCELADON -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|console=tty[^ ]* ||g; s|SERIAL_PORT|$(SERIAL_PARAMETER)|g; s|CONSOLE|console=tty0|g; s|memmap=[^ ]*||g" $(SRC_GRUBCFG) > $(@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]
endif # ENABLE_GRUB_INSTALLER
.PHONY: project_celadon-efi
ifneq ($(TARGET_BUILD_VARIANT), user)
project_celadon-efi: $(PROJECT_CELADON-EFI)
else
project_celadon-efi:
echo "Do not generate grub installer in user mode"
endif