summaryrefslogtreecommitdiffstats
path: root/rules/post/image_ext2.make
blob: 3e3423b2d5bdfe167b80c233f11c3def8500f3a6 (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
# -*-makefile-*-
#
# Copyright (C) 2003-2010 by the ptxdist project <ptxdist@pengutronix.de>
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

SEL_ROOTFS-$(PTXCONF_IMAGE_EXT2)	+= $(IMAGEDIR)/root.ext2
SEL_ROOTFS-$(PTXCONF_IMAGE_EXT2_GZIP)	+= $(IMAGEDIR)/root.ext2.gz

ifdef PTXCONF_IMAGE_EXT2
$(IMAGEDIR)/root.ext2: $(STATEDIR)/image_working_dir
	@echo -n "Creating root.ext2 from working dir..."
	@cd $(image/work_dir);						\
	(awk -F: $(DOPERMISSIONS) $(image/permissions) &&		\
	(								\
		echo -n "$(PTXCONF_SYSROOT_HOST)/bin/genext2fs ";	\
		echo -n "-b $(PTXCONF_IMAGE_EXT2_SIZE) ";		\
		echo -n "-i 16384 ";					\
		echo -n "$(PTXCONF_IMAGE_EXT2_EXTRA_ARGS) ";		\
		echo -n "-d $(image/work_dir) ";			\
		echo "$@" )						\
	) | $(FAKEROOT) --
	@echo "done."

ifdef PTXCONF_IMAGE_EXT2_JOURNAL
#	# Since genext2fs cannot generate ext3 images, we use tune2fs to create
#	# the journal entry and then run e2fsck to update the revision from 0
#	# to 1 to prevent a mount warning. Since both programs lack a quiet
#	# mode we use output redirection (and since we're operating on files
#	# and not on real block devices, it's very unlikely that there are
#	# errors we want to see.
	@echo -n "Upgrading root.ext2 to ext3..."
	@tune2fs -O has_journal "$(IMAGEDIR)/root.ext2" >/dev/null
	@echo "done."
endif

ifdef PTXCONF_IMAGE_EXT2_EXT4
	@echo -n "Upgrading root.ext2 to ext4..."
	@tune2fs -O extents,uninit_bg,dir_index "$(IMAGEDIR)/root.ext2" >/dev/null
	@echo "done."
endif

	@echo -n "Running e2fsck on root.ext2..."
	@e2fsck -pvfD "$(IMAGEDIR)/root.ext2" >/dev/null 2>&1; test $$? -le 2
	@echo "done."

	@echo -n "Summary of root.ext2:"
	@e2fsck -pvf "$(IMAGEDIR)/root.ext2"
endif

ifdef PTXCONF_IMAGE_EXT2_GZIP
$(IMAGEDIR)/root.ext2.gz: $(IMAGEDIR)/root.ext2
	@echo -n "Creating root.ext2.gz from root.ext2...";
	@rm -f $@
	@cat $< | gzip -v9 > $@
	@echo "done."
endif

# vim: syntax=make