blob: 4b5a7f7753f48e00883cb156d7c512f7a3f21255 (
plain)
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
|
# /usr/bin/make
# armel amd64 i386
ARCHITECTURE = armel
# dreamplug guruplug
MACHINE = dreamplug
# card usb
DESTINATION = card
BUILD = $(MACHINE)-$(ARCHITECTURE)-$(DESTINATION)
BUILD_DIR = build/$(ARCHITECTURE)
MOUNTPOINT = /media/
BOOTPOINT = $(MOUNTPOINT)/boot
DEVICE = /dev/sdb
TODAY = `date +%Y.%m%d`
NAME = torouter-unstable_$(TODAY)_$(BUILD)
IMAGE = $(NAME).img
ARCHIVE = $(NAME).tar.bz2
LOOP = /dev/loop0
# populate a tree with DreamPlug root filesystem
rootfs: rootfs-$(ARCHITECTURE)
rootfs-$(ARCHITECTURE): multistrap-configs/fbx-base.conf \
multistrap-configs/fbx-$(ARCHITECTURE).conf \
mk_dreamplug_rootfs \
bin/projects bin/finalize bin/projects-chroot
-sudo umount `pwd`/$(BUILD_DIR)/var/cache/apt/
sudo ./mk_dreamplug_rootfs $(ARCHITECTURE) multistrap-configs/fbx-$(ARCHITECTURE).conf
touch rootfs-$(ARCHITECTURE)
# copy DreamPlug root filesystem to a usb stick or microSD card
# stick assumed to have 2 partitions, 128meg FAT and the rest ext3 partition
image: rootfs-$(ARCHITECTURE)
-umount $(BOOTPOINT)
-umount $(MOUNTPOINT)
mount $(MOUNTPOINT)
sudo mkdir -p $(BOOTPOINT)
mount $(BOOTPOINT)
sudo rsync -atvz --progress --delete --exclude=boot $(BUILD_DIR)/ $(MOUNTPOINT)/
cp $(BUILD_DIR)/boot/* $(BOOTPOINT)/
ifeq ($(DESTINATION),usb)
# prevent the first-run script from running during boot.
# we'll do this during copy2dream.
rm $(MOUNTPOINT)/etc/rc1.d/S01first-run $(MOUNTPOINT)/etc/rc2.d/S01first-run
# add u-boot binary for the DreamPlug to the FAT partition for easy access
cp -r $(MOUNTPOINT)/usr/lib/u-boot/dreamplug $(MOUNTPOINT)/boot
endif
ifeq ($(DESTINATION),card)
# we don't need to copy2dream, this is the microSD card.
sudo rm $(MOUNTPOINT)/sbin/copy2dream
# fix fstab for the SD card.
sudo sh -c "sed -e 's/sdc1/sda1/g' < $(BUILD_DIR)/etc/fstab > $(MOUNTPOINT)/etc/fstab"
endif
ifeq ($(MACHINE),guruplug)
# we can't flash the guru plug's kernel
mkdir -p $(MOUNTPOINT)/var/freedombox/
touch $(MOUNTPOINT)/var/freedombox/dont-tweak-kernel
endif
sync
sleep 1
umount $(BOOTPOINT)
umount $(MOUNTPOINT)
@echo "Build complete."
# build a virtualbox image
virtualbox-image: stamp-vbox-predepend
./mk_virtualbox_image freedombox-unstable_$(TODAY)_virtualbox-i386-hdd
# build the weekly test image
weekly-image: image
# if we aren't installing to an armel system, assume we need a bootloader.
ifneq ($(ARCHITECTURE),armel)
# also, try my best to protect users from themselves:
ifneq ($(DEVICE),/dev/sda)
sudo grub-install $(DEVICE)
endif
endif
dd if=$(DEVICE) of=$(IMAGE) bs=1M
@echo "Image copied. The microSD card may now be removed."
tar -cjvf $(ARCHIVE) $(IMAGE)
#
# meta
#
# install required files so users don't need to do it themselves.
stamp-predepend:
sudo sh -c "apt-get install multistrap qemu-user-static u-boot-tools git mercurial"
touch stamp-predepend
stamp-vbox-predepend:
sudo sh -c "apt-get install debootstrap extlinux qemu-utils parted mbr kpartx python-cliapp"
touch stamp-vbox-predepend
clean:
# just in case I tried to build before plugging in the USB drive.
-sudo umount `pwd`/$(BUILD_DIR)/var/cache/apt/
sudo rm -rf $(BUILD_DIR)
-rm -f $(IMAGE) $(ARCHIVE)
-rm -f rootfs-* stamp-*
distclean: clean
sudo rm -rf build
# remove all data from the microSD card to repopulate it with a pristine image.
clean-card:
-umount $(BOOTPOINT)
-umount $(MOUNTPOINT)
sudo mkdir -p $(BOOTPOINT)
mount $(BOOTPOINT)
sudo rm -rf $(BOOTPOINT)/*
umount $(BOOTPOINT)
sudo mkdir -p $(MOUNTPOINT)
mount $(MOUNTPOINT)
sudo rm -rf $(MOUNTPOINT)/*
umount $(MOUNTPOINT)
|