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