Makefile revision 6784
1#	$Id: Makefile,v 1.110 1995/02/26 20:45:34 phk Exp $
2#
3# How to roll a release:
4#
5#	make release CHROOTDIR=<lots of disk> [ RELEASETAG=something ]
6#
7# As far as I know, this will roll everything nicely into the "stage"
8# directory.  I still need to write the two rules to move that into
9# the "cdrom" and "ftp" directories.
10# I also need to "make ports" and install those, but I'm not going to do
11# that on a 14.4 line just yet...
12
13# Things which without too much trouble can be considered variables
14EXTRADISTRIBUTIONS=	secure games manpages proflibs dict info
15CPIO1=			etc/services etc/protocols
16CPIO2=  scripts/miscfuncs.sh scripts/instdist.sh scripts/netinst.sh \
17	scripts/adduser.sh scripts/bininst.sh scripts/setup.sh
18
19FDDEVICE=		fd0
20FDCYLS=			80
21FDCYLSIZE=		15k
22FDLABEL=		fd1200
23MNT=			/mnt
24
25ZIPNSPLIT=		gzip --no-name -9 -c | split -b 240640 -
26
27
28# Things which will get you into trouble if you change them
29DISTRIBUTIONS=		bin ${EXTRADISTRIBUTIONS}                      
30MTREEFILES=		${.CURDIR}/../etc/mtree
31RD=			${RELEASEDIR}/stage
32
33release:
34.if !defined(CHROOTDIR)
35	@echo "To make a release you must set CHROOTDIR" && false
36.endif
37	-mkdir ${CHROOTDIR}
38	chflags -R noschg ${CHROOTDIR}/.
39	rm -rf ${CHROOTDIR}/*
40	cd ${.CURDIR}/../etc ; ${MAKE} distrib-dirs DESTDIR=${CHROOTDIR}
41	cd ${.CURDIR}/../etc ; ${MAKE} distribution DESTDIR=${CHROOTDIR}
42	cd ${.CURDIR}/.. ; ${MAKE} install DESTDIR=${CHROOTDIR}
43	echo "#!/bin/sh"			> ${CHROOTDIR}/mk
44	echo "set -ex"				>> ${CHROOTDIR}/mk
45	echo "cd /usr/src"			>> ${CHROOTDIR}/mk
46	echo "make world"			>> ${CHROOTDIR}/mk
47	echo "cd sbin/sysinstall"		>> ${CHROOTDIR}/mk
48	echo "make obj"				>> ${CHROOTDIR}/mk
49	echo "cd ../../release"			>> ${CHROOTDIR}/mk
50	echo "make obj"				>> ${CHROOTDIR}/mk
51	echo "make doRELEASE"			>> ${CHROOTDIR}/mk
52	echo "RELEASEDIR=/R"			>> ${CHROOTDIR}/etc/make.conf
53.if !defined(RELEASETAG)
54	cd ${CHROOTDIR}/usr ; cvs co src -P
55.else
56	cd ${CHROOTDIR}/usr ; cvs export -P -r ${RELEASETAG} src
57.endif
58	chmod 755 ${CHROOTDIR}/mk
59	chroot ${CHROOTDIR} /mk
60
61clean:
62	rm -rf cpio_crunch boot_crunch release.[1-9]
63
64# Clean out ${RELEASEDIR} and make the directory structure.
65release.1:
66	@cd ${.CURDIR} ; $(MAKE) ckRELEASEDIR
67	-mkdir ${RELEASEDIR}
68	chflags -R noschg ${RELEASEDIR}/.
69	rm -rf ${RELEASEDIR}/*
70	mkdir ${RD}
71	mkdir ${RD}/bootfd
72	mkdir ${RD}/bootfd/dev
73	mkdir ${RD}/bootfd/mnt
74	mkdir ${RD}/bootfd/stand
75	mkdir ${RD}/cpiofd
76	mkdir ${RD}/cpiofd/stand
77	mkdir ${RD}/floppies
78	mkdir ${RD}/dists
79	mkdir ${RD}/dists/bin
80	mkdir ${RD}/tarballs
81	mkdir ${RD}/tarballs/bin
82	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/dists/bin
83	for i in ${EXTRADISTRIBUTIONS} ; do \
84		mkdir ${RD}/dists/$$i ; \
85		mkdir ${RD}/tarballs/$$i ; \
86		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
87		    -p ${RD}/dists/$$i > /dev/null ; \
88		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
89		    -p ${RD}/dists/$$i/usr > /dev/null ; \
90		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
91		    -p ${RD}/dists/$$i/var > /dev/null ; \
92	done
93	touch release.1
94
95# Install the system into the various distributions.
96release.2:
97	@cd ${.CURDIR} ; $(MAKE) ckRELEASEDIR
98	cd ${.CURDIR}/.. ; make distribute DISTDIR=${RD}/dists
99	touch release.2
100
101# Make and install a couple of kernels we need.
102release.3:
103	@cd ${.CURDIR} ; $(MAKE) ckRELEASEDIR
104	cd ${.CURDIR}/../sys/i386/conf ; \
105		config GENERIC ; \
106		config BOOTFLP
107	cd ${.CURDIR}/../sys/compile/GENERIC ; \
108		make depend ; \
109		make kernel ; \
110		install -c kernel ${RD}/dists/bin/kernel.GENERIC
111	ln  -f ${RD}/dists/bin/kernel.GENERIC \
112		${RD}/cpiofd/kernel
113	cd ${.CURDIR}/../sys/compile/BOOTFLP ; \
114		make depend ; \
115		make kernel ; \
116		install -s -c kernel ${RD}/bootfd/kernel
117	touch release.3
118
119# Make and install the two crunched binaries which live on the floppies.
120# You are not supposed to like this :-)
121release.4:
122	@cd ${.CURDIR} ; $(MAKE) ckRELEASEDIR
123	for j in boot cpio ; do \
124		rm -rf $${j}_crunch ; \
125		mkdir $${j}_crunch ; \
126		( cd $${j}_crunch ; \
127		crunchgen ${.CURDIR}/$${j}_crunch.conf ; \
128		${MAKE} -f $${j}_crunch.mk objs exe NOCRYPT=yes ) ; \
129		gzip -9 < $${j}_crunch/$${j}_crunch \
130			> ${RD}/$${j}fd/stand/$${j}_crunch ; \
131		rm -rf $${j}_crunch ; \
132		chmod 555 ${RD}/$${j}fd/stand/$${j}_crunch ; \
133		for i in `crunchgen -l ${.CURDIR}/$${j}_crunch.conf` ; do \
134			ln -f ${RD}/$${j}fd/stand/$${j}_crunch \
135				${RD}/$${j}fd/stand/$$i ; \
136		done ; \
137	done
138	touch release.4
139
140# Fix up the distributions.
141release.5:
142	@cd ${.CURDIR} ; $(MAKE) ckRELEASEDIR
143	if [ -d ${RD}/dists/bin/usr/share/man ] ; then \
144		rm -rf ${RD}/dists/manpages/usr/share/man ;\
145		mv ${RD}/dists/bin/usr/share/man \
146			${RD}/dists/manpages/usr/share/man ;\
147	fi
148	if [ -d ${RD}/dists/bin/usr/games ] ; then \
149		rm -rf ${RD}/dists/games/usr/games ;\
150		mv ${RD}/dists/bin/usr/games \
151			${RD}/dists/games/usr/games ;\
152	fi
153	if [ -d ${RD}/dists/bin/usr/share/games ] ; then \
154		rm -rf ${RD}/dists/games/usr/share/games ;\
155		mv ${RD}/dists/bin/usr/share/games \
156			${RD}/dists/games/usr/share/games ;\
157	fi
158	if [ -d ${RD}/dists/bin/var/games ] ; then \
159		rm -rf ${RD}/dists/games/var/games ;\
160		mv ${RD}/dists/bin/var/games \
161			${RD}/dists/games/var/games ;\
162	fi
163	if [ -d ${RD}/dists/bin/usr/share/dict ] ; then \
164		rm -rf ${RD}/dists/dict/usr/share/dict ;\
165		mv ${RD}/dists/bin/usr/share/dict \
166			${RD}/dists/dict/usr/share/dict ;\
167	fi
168	for i in airport birthtoken flowers na.phone zipcodes ; do \
169		if [ -f ${RD}/dists/bin/usr/share/misc/$$i ] ; then \
170			mv ${RD}/dists/bin/usr/share/misc/$$i \
171				${RD}/dists/dict/usr/share/misc ; \
172		fi ; \
173	done
174	for i in ${RD}/dists/bin/usr/lib/*_p.a ; do \
175		if [ -f $$i ] ; then \
176			mv $$i \
177				${RD}/dists/proflibs/usr/lib ; \
178		fi ; \
179	done
180	-cd ${RD}/dists ; \
181		find ${EXTRADISTRIBUTIONS} -depth -type d -print | xargs rmdir
182
183	touch release.5
184
185# Complete the bootfd 
186release.6:
187	@cd ${.CURDIR} ; $(MAKE) ckRELEASEDIR
188	( cd ${RD}/dists/bin/dev ; \
189		ls console tty ttyv1 null zero \
190		sd[0123][a-h] wd[0123][a-h] fd[01] \
191		rsd[0123][a-h] rwd[0123][a-h] rfd[01] | \
192	cpio -dump ${RD}/bootfd/dev )
193	install -c ${.CURDIR}/../COPYRIGHT ${RD}/bootfd
194	cd ${RD}/dists/bin/usr/share/FAQ ; \
195		install -c diskspace.FAQ ${RD}/bootfd/DISKSPACE.FAQ ;\
196		install -c RELNOTES.FreeBSD ${RD}/bootfd ;\
197		install -c TROUBLESHOOTING ${RD}/bootfd ;\
198		install -c README-2.0 ${RD}/bootfd/README
199	touch ${RD}/bootfd/this_is_boot_flp
200.if !defined(VNDEVICE)
201	-umount /dev/${FDDEVICE}
202	-umount ${MNT}
203	echo y | fdformat /dev/r${FDDEVICE}
204	disklabel -w -r -B \
205		-b ${RD}/dists/bin/usr/mdec/fdboot \
206		-s ${RD}/dists/bin/usr/mdec/bootfd \
207		/dev/r${FDDEVICE} ${FDLABEL}
208	newfs -c 80 -b 4096 -f 512 -i 9000 -m 0 -t 0 -u 0 \
209		-o space -T ${FDLABEL} /dev/r${FDDEVICE}
210	mount -o async /dev/${FDDEVICE} ${MNT}
211	cd ${RD}/bootfd ; find . -print | cpio -dumpv ${MNT}
212	sync
213	umount ${MNT}
214	fsck /dev/r${FDDEVICE}
215	dd if=/dev/r${FDDEVICE} of=${RD}/floppies/boot.tmp \
216		bs=${FDCYLSIZE} count=${FDCYLS}
217	mv ${RD}/floppies/boot.tmp ${RD}/floppies/boot.flp
218	gzip -9 -c < ${RD}/floppies/boot.flp > ${RD}/floppies/boot.flp.gz
219.endif
220	touch release.6
221
222# Complete the cpiofd directory
223# XXX a lot of stuff is missing here...
224release.7:
225	@cd ${.CURDIR} ; $(MAKE) ckRELEASEDIR
226	cd ${RD}/dists/bin ; ls ${CPIO1} | cpio -dump ${RD}/cpiofd
227	cd ${.CURDIR} ; ls ${CPIO2} | cpio -dumpv ${RD}/cpiofd
228	chmod 755 ${RD}/cpiofd/scripts/*
229	cp ${RD}/dists/bin/usr/sbin/tzsetup ${RD}/cpiofd
230	( cd ${RD}/cpiofd ; \
231		( rm -f OK ; find . -print ; touch OK ; echo OK ) | \
232		cpio -H newc -oa | gzip -9 -c | dd conv=osync ) \
233		> ${RD}/floppies/cpio.flp
234	gzip -1 -c < ${RD}/floppies/cpio.flp > ${RD}/floppies/cpio.flp.gz
235	touch release.7
236
237# Make binary tarballs
238release.8:
239	@cd ${.CURDIR} ; $(MAKE) ckRELEASEDIR
240	rm -rf ${RD}/tarballs
241	mkdir -p ${RD}/tarballs
242	@for i in ${DISTRIBUTIONS} ; \
243	do \
244		if [ -d ${RD}/dists/$${i} ] ; then \
245			cd ${.CURDIR} ; \
246				$(MAKE) doTARBALL SD=${RD}/dists/$${i} \
247					TD=$$i ARG="." ; \
248			( cd ${RD}/tarballs/$${i}; \
249			sh -e ${.CURDIR}/scripts/mkchecksums.sh ) ; \
250			cp ${.CURDIR}/scripts/extract_$${i}.sh \
251				${RD}/tarballs/$${i}/extract.sh;\
252			echo "$${i} distribution is finished."; \
253		fi ; \
254	done                                                 
255	touch release.8
256
257
258# Make source tarballs
259release.9:
260	@cd ${.CURDIR} ; $(MAKE) ckRELEASEDIR
261	@cd ${.CURDIR} ; $(MAKE) doTARBALL SD=/usr/src TD=src/base ARG="[A-Z]*"
262	@for i in bin etc games gnu include lib libexec release sbin \
263		secure lkm eBones share sys usrbin usrsbin ; do \
264		if [ -d /usr/src/$$i ] ; then \
265			cd ${.CURDIR} ; \
266				$(MAKE) doTARBALL SD=/usr/src \
267					TD=src/$$i ARG="$$i" ; \
268		fi ; \
269	done
270	( cd ${RD}/tarballs/src; \
271	sh -e ${.CURDIR}/scripts/mkchecksums.sh ) ; \
272	cp ${.CURDIR}/scripts/extract_src.sh \
273		${RD}/tarballs/src/extract.sh;\
274	echo "src distribution is finished."; \
275	touch release.9
276
277# Various "subroutine" and other supporting targets.
278
279doTARBALL:
280.if !defined(SD)
281	@echo "SD undefined in doTARBALL" ; exit 1
282.endif               
283.if !defined(TD)
284	@echo "TB undefined in doTARBALL" ; exit 1
285.endif               
286.if !defined(ARG)
287	@echo "ARGundefined in doTARBALL" ; exit 1
288.endif               
289	rm -rf ${RD}/tarballs/${TD}
290	mkdir -p ${RD}/tarballs/${TD}
291	( cd ${SD} ; \
292		echo rolling ${TD} tarball ;\
293		tar --exclude CVS -cf - ${ARG} | \
294		${ZIPNSPLIT} ${RD}/tarballs/${TD}/`basename ${TD}`. )
295
296doRELEASE:  release.1 release.2 release.3 release.4 release.5 release.6 \
297		release.7 release.8 release.9
298	@echo "Release done"
299
300ckRELEASEDIR:
301.if !defined(RELEASEDIR)
302	@echo "To make a release RELEASEDIR must be defined" && false
303.endif               
304
305.include <bsd.prog.mk>
306