forked from kalyankondapally/bootable-live-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Android.mk
51 lines (46 loc) · 2.07 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
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := install_mbr
LOCAL_SRC_FILES := editdisklbl/editdisklbl.c
LOCAL_CFLAGS := -O2 -g -W -Wall -Werror# -D_LARGEFILE64_SOURCE
LOCAL_STATIC_LIBRARIES := libdiskconfig_host libcutils liblog
install_mbr := $(HOST_OUT_EXECUTABLES)/$(LOCAL_MODULE)
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): $(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
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 > $@
# 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 vendor.img system.img) | $(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)|" $(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)