summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: d654184071f04f3e84788251d9a1395015fd0b70 (plain) (blame)
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
PACKAGE=alpine-baselayout
VERSION=2.2.0

PV 		=$(PACKAGE)-$(VERSION)
TARBALL 	=$(PV).tar.bz2
SUBDIRS 	=src

GENERATED_FILES := shadow

ETC_FILES 	= TZ \
		crontab \
		fstab \
		group \
		hostname \
		hosts \
		inittab \
		motd \
		passwd \
		profile \
		protocols \
		services \
		shells

MODPROBED_FILES	=aliases.conf blacklist.conf i386.conf kms.conf
PROFILED_FILES  =color_prompt
SYSCTL_FILES	=00-alpine.conf
CRONTABS 	=crontab
DISTFILES 	=$(ETC_FILES) $(SYSCTL_FILES) $(MODPROBED_FILES) Makefile

all:	$(GENERATED_FILES)
	for i in $(SUBDIRS) ; do \
		cd $$i && $(MAKE) && cd ..  ; \
	done

clean:
	for i in $(SUBDIRS) ; do \
		cd $$i && make clean && cd .. ; \
	done
	rm -f $(TARBALL) $(GENERATED_FILES) *~

shadow:	passwd
	lastchange=$$(( `date +%s` / ( 24 * 3600 ) ));\
	awk -F: ' { \
		pw = ":!:";\
		if ($$1 == "root") { pw = "::" };\
		print $$1 pw "'"$$lastchange"':0:::::"  \
	}' passwd > $@

install: $(GENERATED_FILES)
	install -m 0755 -d $(addprefix $(DESTDIR)/, \
		dev \
		dev/pts \
		dev/shm \
		etc \
		etc/apk \
		etc/conf.d \
		etc/crontabs \
		etc/init.d \
		etc/modprobe.d \
		etc/profile.d \
		etc/sysctl.d \
		etc/network/if-down.d \
		etc/network/if-post-down.d \
		etc/network/if-pre-up.d \
		etc/network/if-up.d \
		etc/periodic/15min \
		etc/periodic/daily \
		etc/periodic/hourly \
		etc/periodic/monthly \
		etc/periodic/weekly \
		home \
		lib/firmware \
		lib/mdev \
		media/cdrom \
		media/floppy \
		media/usb \
		mnt \
		proc \
		sbin \
		sys \
		usr/bin \
		usr/sbin \
		usr/local/bin \
		usr/local/lib \
		usr/local/share \
		usr/share \
		var/cache/misc \
		var/lib/misc \
		var/lock/subsys \
		var/log \
		var/run \
		var/spool/cron \
		run \
		)
	install -d -m 0700 $(DESTDIR)/root
	install -d -m 1777 $(DESTDIR)/tmp $(DESTDIR)/var/tmp
	for i in $(SUBDIRS) ; do \
		cd $$i && make install && cd .. ;\
	done
	install -m 0644 $(ETC_FILES) $(GENERATED_FILES) $(DESTDIR)/etc
	chmod 600 $(DESTDIR)/etc/shadow
	install -m 0644 $(MODPROBED_FILES) $(DESTDIR)/etc/modprobe.d
	install -m 0755 $(PROFILED_FILES) $(DESTDIR)/etc/profile.d
	install -m 0644 $(SYSCTL_FILES) $(DESTDIR)/etc/sysctl.d
	mv $(DESTDIR)/etc/crontab $(DESTDIR)/etc/crontabs/root
	ln -s /etc/crontabs $(DESTDIR)/var/spool/cron/crontabs
	ln -s /proc/mounts $(DESTDIR)/etc/mtab
	echo "af_packet" >$(DESTDIR)/etc/modules



$(TARBALL): $(DISTFILES) $(SUBDIRS)
	rm -rf $(PV)
	mkdir $(PV)
	for i in $(SUBDIRS) ; do \
		cd $$i && make clean && cd .. ; \
	done
	cp $(DISTFILES) $(PV)
	mkdir $(PV)/conf.d
	rsync -Cr $(SUBDIRS) $(PV)
	tar -cjf $@ $(PV)
	rm -r $(PV)

dist:	$(TARBALL)


.PHONY:	install clean all