-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.ramdisk
137 lines (107 loc) · 4.7 KB
/
Makefile.ramdisk
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
NFS_ROOT="/srv/nfs"
# Busybox
busybox-git-repo="git://git.busybox.net/busybox"
GIT_PROJECTS += busybox
busybox-build: $(FILESYSTEM_ROOT)/busybox_update
busybox-rebuild:
rm $(FILESYSTEM_ROOT)/busybox_update
$(MAKE) busybox-build
$(FILESYSTEM_ROOT)/busybox_update: | busybox $(FS_DIRS) gnu-tools
@echo "Building Busybox..."
$(call remote-maybe, cd $(SOURCES_DIR)/busybox-git; \
$(MAKE) ARCH=arm CROSS_COMPILE=$(GNU_TOOLS_PREFIX) CONFIG_PREFIX="$(FILESYSTEM_ROOT)" defconfig && \
$(MAKE) ARCH=arm CROSS_COMPILE=$(GNU_TOOLS_PREFIX) CONFIG_PREFIX="$(FILESYSTEM_ROOT)" install)
(date && find $(FILESYSTEM_ROOT)) > $@
FS_DIRS = $(FILESYSTEM_ROOT)/lib \
$(FILESYSTEM_ROOT)/dev \
$(FILESYSTEM_ROOT)/etc \
$(FILESYSTEM_ROOT)/etc/dropbear \
$(FILESYSTEM_ROOT)/etc/init.d \
$(FILESYSTEM_ROOT)/mnt \
$(FILESYSTEM_ROOT)/opt \
$(FILESYSTEM_ROOT)/proc \
$(FILESYSTEM_ROOT)/root \
$(FILESYSTEM_ROOT)/sys \
$(FILESYSTEM_ROOT)/tmp \
$(FILESYSTEM_ROOT)/var \
$(FILESYSTEM_ROOT)/var/log \
$(FILESYSTEM_ROOT)/var/www \
$(FILESYSTEM_ROOT)/sbin \
$(FILESYSTEM_ROOT)/bin \
$(FILESYSTEM_ROOT)/usr/ \
$(FILESYSTEM_ROOT)/usr/bin \
$(FILESYSTEM_ROOT)/usr/lib \
$(FILESYSTEM_ROOT)/usr/libexec \
$(FILESYSTEM_ROOT)/usr/sbin \
$(FILESYSTEM_ROOT)/usr/share \
$(MODULES_DIR)
DIRECTORIES += $(FS_DIRS)
FS_FILES = $(FILESYSTEM_ROOT)/etc/fstab \
$(FILESYSTEM_ROOT)/etc/inittab \
$(FILESYSTEM_ROOT)/etc/init.d/rcS \
$(FILESYSTEM_ROOT)/etc/passwd \
$(FILESYSTEM_ROOT)/bin/test_thinklcdml.sh \
$(FILESYSTEM_ROOT)/etc/profile
$(FILESYSTEM_ROOT)/bin/test_thinklcdml.sh: $(DATA_DIR)/test_thinklcdml.sh | $(DIRECTORIES)
cp $< $@
chmod +x $@
libc-install: | gnu-tools $(FILESYSTEM_ROOT)
$(call remote-maybe, rsync -azvr --exclude "*locale/" --exclude "*locales/" $(GNU_TOOLS_LIBC)/* $(FILESYSTEM_ROOT))
$(FILESYSTEM_ROOT)/init.sh: $(DATA_DIR)/fdinit.sh
$(call remote-maybe, cp $(DATA_DIR)/fdinit.sh $@ && chmod a+x $@)
filesystem-nossh: $(FILESYSTEM_ROOT)/fs_update
$(FILESYSTEM_ROOT)/etc/%: $(DATA_DIR)/% | $(FILESYSTEM_ROOT)
$(call remote-maybe, cp $(DATA_DIR)/$* $(FILESYSTEM_ROOT)/etc/$*)
$(FILESYSTEM_ROOT)/etc/init.d/rcS: $(DATA_DIR)/rcS | $(FILESYSTEM_ROOT)
$(call remote-maybe, cp $(DATA_DIR)/rcS $@)
$(call remote-maybe, chmod 755 $@)
@echo "I am about to 'sudo chown root:root $(FILESYSTEM_ROOT)/etc/init.d/rcS'. No need to worry."
if [ "$$(stat --format '%U:%G' $(FILESYSTEM_ROOT)/etc/init.d/rcS)" = "root:root" ]; then \
sudo chown root:root $(FILESYSTEM_ROOT)/etc/init.d/rcS; \
fi
$(FILESYSTEM_ROOT)/fs_update: $(FS_DIRS) $(FS_FILES) $(FILESYSTEM_ROOT)/busybox_update | $(FILESYSTEM_ROOT) libc-install
@echo "Building filesystem"
# Strip debug symbols
ifneq ($(DEBUG_LIBS),y)
$(call remote-maybe, for i in $(FILESYSTEM_ROOT)/lib/*; do \
if ([ -f "$$i" ] && [ ! "`file -b $$i`" = "ASCII text" ]); then $(GNU_TOOLS_PREFIX)strip $$i; fi; \
done)
endif
(date && find $(FILESYSTEM_ROOT)) > $@
filesystem: openssh-build $(FS_DIRS) $(FS_FILES)
filesystem-clean:
rm -rf $(FILESYSTEM_ROOT)
ramdisk: ramdisk-board ramdisk-qemu
ramdisk-board: $(RESOURCES_DIR)/uramdisk.image.gz
# Use this to update NFS_ROOT
SYNC_CMD=rsync -azvr --delete $(FILESYSTEM_ROOT)/* $(NFS_ROOT)
.PHONY:
nfsroot: filesystem
if ! $(SYNC_CMD); then \
sudo $(SYNC_CMD) ; \
fi
comma=,
$(RESOURCES_DIR)/ramdisk.img: $(FILESYSTEM_ROOT)/fs_update | $(DRAFTS_DIR) $(RESOURCES_DIR)
@echo "Building ramdisk..."
$(call remote-maybe, dd if=/dev/zero of=$@ bs=1024 count=$$(($$(du -s $(FILESYSTEM_ROOT) | awk "{print \$$1}") + 1000)))
$(call remote-maybe, mke2fs -t ext2 -F $@ -L "ramdisk" -b 1024 -m 0)
$(call remote-maybe, tune2fs $@ -i 0)
$(call remote-maybe, mkdir -p $(DRAFTS_DIR)/ramdisk)
$(call remote-maybe, chmod a+w $@)
@echo "Sudo is used to mount ramdisk..."
$(call remote-maybe, sudo mount -v -t ext2 -o loop$(comma)rw $@ $(DRAFTS_DIR)/ramdisk/)
$(call remote-maybe, sudo rsync -azvr --delete --exclude "*locale/" --exclude "*locales/" $(FILESYSTEM_ROOT)/* $(DRAFTS_DIR)/ramdisk/)
$(call remote-maybe, sudo umount $(DRAFTS_DIR)/ramdisk/)
$(call remote-maybe, rmdir $(DRAFTS_DIR)/ramdisk/)
ramdisk-umount:
$(call remote-maybe, [ -n "$$(mount -l | grep $(DRAFTS_DIR)/ramdisk)" ] && echo "Sudo to unmount ramdisk..." && sudo umount $(DRAFTS_DIR)/ramdisk/ || true)
ramdisk-clean: ramdisk-umount
$(call remote-maybe, rm -rf $(DRAFTS_DIR)/ramdisk)
$(call remote-maybe, rm -rf $(RESOURCES_DIR)/*ramdisk.img*)
$(RESOURCES_DIR)/ramdisk.image.gz: $(RESOURCES_DIR)/ramdisk.img
$(call remote-maybe, gzip -9 $(RESOURCES_DIR)/ramdisk.img -c > $@)
$(RESOURCES_DIR)/uramdisk.image.gz: $(RESOURCES_DIR)/ramdisk.image.gz
$(call remote-maybe, $(SOURCES_DIR)/uboot-git/tools/mkimage -A arm -T ramdisk -C gzip -d $< $@)
ramdisk-dev:
$(MAKE) ramdisk-clean
$(MAKE) ramdisk-board