network - Fix issue with recent unix domain socket gc fixes
[dragonfly.git] / nrelease / Makefile
blobff6ea49de00cec7989f02e19f0d3d84ebab3ab0c
1 #########################################################################
2 # ENHANCEMENTS #
3 #########################################################################
5 # New method e.g. 'make gui release'. A series of enhancement
6 # targes may be specified which set make variables which enhance
7 # the build in various ways.
9 # img is now the default (produces both the .iso and .img)
11 gui installer img:
13 #########################################################################
14 # SETUP #
15 #########################################################################
17 ISODIR?= /usr/release
18 ISOROOT?= ${ISODIR}/root
19 OBJSYS= ${.OBJDIR}/../sys
21 MAKE_JOBS?= $$(sysctl -n hw.ncpu)
23 # temporary until everybody has converted to x86_64
24 .if ${MACHINE_ARCH} == "amd64"
25 MACHINE_ARCH= x86_64
26 .makeenv MACHINE_ARCH
27 .endif
29 # XXX makeshift fix to build the right kernel for the (target) architecture
30 # We should configure this in the platform files somehow
31 .if ${MACHINE_ARCH} == "i386"
32 KERNCONF ?= GENERIC VKERNEL
33 .else
34 KERNCONF ?= X86_64_GENERIC VKERNEL64
35 .endif
37 PKGSRC_PREFIX?= /usr/pkg
38 PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
39 PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
40 PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
41 PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
42 PKGSRC_PKG_PATH?= ${ISODIR}/packages
44 # We use env -i in the chroot, so that environment variables won't
45 # disturb any (pkgsrc) build. This has happened for TARGET_ARCH,
46 # which is used by gmake in completely different context.
48 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
50 # User may specify extra packages in addition to the defaults
52 PKGSRC_EXTRA_PACKAGES?=
54 # Pkgsrc packages to be built and installed on the release ISO
56 PKGSRC_PACKAGES?= pkgtools/pkg_leaves \
57 pkgtools/pkg_tarup \
58 pkgtools/pkgin \
59 devel/scmgit \
60 net/bind96 \
61 net/isc-dhcp4 \
62 net/isc-dhcpd4 \
63 sysutils/cdrtools \
64 net/csup \
65 ${PKGSRC_EXTRA_PACKAGES}
67 # pkgsrc options to use when building packages
69 PKGSRC_OPTIONS+= MAKE_JOBS=${MAKE_JOBS}
70 PKGSRC_OPTIONS+= WRKOBJDIR=/usr/pkgobj
71 PKGSRC_OPTIONS+= PKG_DEFAULT_OPTIONS='dri inet6'
72 .if !make(gui)
73 PKGSRC_OPTIONS+= PKG_OPTIONS.scmgit=-scmgit-gui
74 .endif
76 # Even though buildiso wipes the packages, our check target has to run
77 # first and old packages (listed as they appear in pkg_info) must be
78 # cleaned out in order for the pkg_add -n test we use in the check target
79 # to operate properly.
81 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 \
82 cdrecord-2.00.3nb2 \
83 bootstrap-kit-20070205 \
84 dfuibe_installer-1.1.6 \
85 gettext-lib-0.14.5 \
86 dfuibe_installer-1.1.7nb1 \
87 dfuife_curses-1.5 \
88 gettext-lib-0.14.6 \
89 gettext-tools-0.14.6nb1 \
90 libaura-3.1 \
91 libdfui-4.2 \
92 libinstaller-5.1 \
93 bootstrap-kit-20080211 \
94 cdrtools-ossdvd-2.01.1.36nb2 \
95 isc-dhcp-base-4.0.0 \
96 isc-dhcp-server-4.0.0
98 # Specify which root skeletons are required, and let the user include
99 # their own. They are copied into ISODIR during the `customizeiso'
100 # target; each overwrites the last.
102 REQ_ROOTSKELS= ${.CURDIR}/root
103 ROOTSKELS?= ${REQ_ROOTSKELS}
105 .if make(gui)
106 ISOFILE?= ${ISODIR}/dfly-gui.iso
107 IMGFILE?= ${ISODIR}/dfly-gui.img
108 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-apps \
109 meta-pkgs/modular-xorg-drivers \
110 meta-pkgs/modular-xorg-fonts \
111 meta-pkgs/modular-xorg-libs \
112 wm/fluxbox \
113 wm/fvwm \
114 www/firefox \
115 print/xpdf \
116 shells/zsh \
117 editors/emacs \
118 editors/vim \
119 chat/pidgin \
120 chat/irssi \
121 chat/xchat \
122 x11/modular-xorg-server \
123 x11/rxvt-unicode \
124 x11/eterm \
125 lang/perl5 \
126 editors/nano \
127 shells/bash \
128 devel/exctags \
129 archivers/zip \
130 security/sudo \
131 www/links-gui \
132 net/nmap \
133 net/wget \
134 fonts/terminus-font \
135 net/rsync \
136 sysutils/idesk \
137 time/asclock \
138 misc/screen
139 ROOTSKELS+= ${.CURDIR}/gui
140 .endif
142 ISOFILE ?= ${ISODIR}/dfly.iso
143 IMGFILE ?= ${ISODIR}/dfly.img
145 IMGMNT ?= ${ISODIR}/mnt
147 # USB umass now probes starting at da8, so the usb stick is
148 # probably sitting on da8.
150 IMGUSBDEV ?= da8
152 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
153 # the additional '/nrelease' manually, as a safety measure.
155 NRLOBJDIR?= /usr/obj
157 #########################################################################
158 # BASE ISO TARGETS #
159 #########################################################################
161 release: check clean buildworld1 buildkernel1 \
162 buildiso srcs customizeiso mkiso mkimg
164 quickrel: check clean buildworld2 buildkernel2 \
165 buildiso srcs customizeiso mkiso mkimg
167 realquickrel: check clean \
168 buildiso srcs customizeiso mkiso mkimg
170 restartpkgs: check customizeiso mkiso mkimg
172 quick: quickrel
174 realquick: realquickrel
177 #########################################################################
178 # CORE SUPPORT TARGETS #
179 #########################################################################
181 check:
182 .if !exists(${PKGBIN_PKG_ADMIN})
183 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
184 @echo " make pkgsrc_bootstrap"
185 .endif
186 .if !exists (${PKGBIN_MKISOFS})
187 @echo
188 @echo "Your machine does not have cdrtools installed. You can install it with:"
189 @echo " make pkgsrc_cdrecord"
190 .endif
191 .if !defined(PKGSRC_PATH)
192 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
193 @echo "package building. For example /usr/pkgsrc. See the Makefile"
194 @echo "in /usr if you are unfamiliar with pkgsrc."
195 .endif
196 .if !exists (${PKGBIN_MKISOFS})
197 @exit 1
198 .endif
199 .if !defined(PKGSRC_PATH)
200 @exit 1
201 .endif
203 buildworld1 buildworld2:
204 cd ${.CURDIR}/..; \
205 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
206 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
208 buildkernel1 buildkernel2:
209 cd ${.CURDIR}/..; \
210 first=; \
211 for kernconf in ${KERNCONF}; do \
212 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
213 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
214 KERNCONF=$${kernconf} \
215 $${first:+-DNO_MODULES}; \
216 first=done; \
217 done
219 # note that we do not want to mess with any /usr/obj directories not related
220 # to buildworld, buildkernel, or nrelease, so we must supply the proper
221 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
222 # buildkernel mechanism.
224 # Unconditionally clean out /usr/release/root so a previous img build
225 # does not blow up a future quick iso build
227 buildiso:
228 -rm -rf ${ISOROOT}
229 -chflags -R noschg ${ISOROOT}
230 rm -rf ${ISOROOT}
231 mkdir -p ${ISOROOT}
232 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
233 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
234 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
235 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
236 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
237 cd ${.CURDIR}/..; \
238 first=; \
239 for kernconf in ${KERNCONF}; do \
240 make DESTDIR=${ISOROOT} \
241 installkernel KERNCONF=$${kernconf} \
242 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
243 $${first:+-DNO_MODULES}; \
244 first=done; \
245 done
246 ln -s kernel ${ISOROOT}/boot/kernel.BOOTP
247 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
248 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
249 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
251 # Release CD: Kernel sources (~16M) and the full pkgsrc tree (~27M)
252 # Release DVD: Full sources (~90M) and the full pkgsrc tree (~27M)
254 srcs:
255 .if !defined(WITHOUT_SRCS)
256 cd ${ISOROOT}/usr && make pkgsrc-create
257 .if make(gui)
258 cd ${ISOROOT}/usr && make src-create
259 .else
260 rm -f ${ISOROOT}/usr/src-sys.tgz
261 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
262 -czf ${ISOROOT}/usr/src-sys.tgz ./Makefile ./Makefile.inc1 ./sys
263 .endif
264 .endif
266 # Customize the ISO by copying rootskels in reverse priority order,
267 # building packages, and doing other post-install tasks.
269 customizeiso:
270 # Copy the rootskels. Allow sources to be owned by someone other
271 # than root (as is common when checked out via git).
273 .for ROOTSKEL in ${ROOTSKELS}
274 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
275 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
276 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
277 .endfor
278 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
279 .for UPGRADE_ITEM in Makefile \
280 etc.${MACHINE_ARCH} \
281 isdn/Makefile \
282 rc.d/Makefile \
283 periodic/Makefile \
284 periodic/daily/Makefile \
285 periodic/security/Makefile \
286 periodic/weekly/Makefile \
287 periodic/monthly/Makefile
288 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
289 .endfor
291 # Setup some things & mount pkgsrc tree. Use defensive umounts and
292 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
294 # If we did not get past the bootstrap we clean out the entire
295 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
296 # we left off.
298 cp -p /etc/resolv.conf ${ISOROOT}/etc
299 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
300 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
301 -@umount ${ISOROOT}/usr/pkgsrc
302 -@umount ${ISOROOT}/dev
303 mkdir -p ${ISODIR}/distfiles
304 rm -rf ${ISOROOT}/usr/pkgobj
306 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable.
307 # Make /usr/pkgsrc read-only for safety, else a failed umount and
308 # our rm -rf will do bad things.
310 mkdir -p ${ISOROOT}/usr/pkgobj
311 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
312 mkdir -p ${ISOROOT}/usr/pkgsrc
313 mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
314 mount_null /dev ${ISOROOT}/dev
315 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
316 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
318 # Bootstrap, if not already installed, and add licenses needed
319 # for the gui release
321 test -e ${ISODIR}/.didbootstrap || \
322 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
323 ${ISOROOT}/var/db/pkg.refcount
324 test -e ${ISODIR}/.didbootstrap || \
325 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \
326 export share_dir=/usr/pkgobj/bootstrap/work/share; \
327 ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
328 .if make(gui)
329 test -e ${ISODIR}/.didbootstrap || \
330 echo ".ifdef BSD_PKG_MK # added by nrelease" \
331 >> ${ISOROOT}/usr/pkg/etc/mk.conf
332 test -e ${ISODIR}/.didbootstrap || \
333 echo "ACCEPTABLE_LICENSES+=openmotif-license" \
334 >> ${ISOROOT}/usr/pkg/etc/mk.conf
335 test -e ${ISODIR}/.didbootstrap || \
336 echo "ACCEPTABLE_LICENSES+=vim-license" \
337 >> ${ISOROOT}/usr/pkg/etc/mk.conf
338 test -e ${ISODIR}/.didbootstrap || \
339 echo ".endif # added by nrelease" \
340 >> ${ISOROOT}/usr/pkg/etc/mk.conf
341 .endif
342 test -e ${ISODIR}/.didbootstrap || sync
343 test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
345 # Build and install packages, skip packages already installed
347 .for PKG in ${PKGSRC_PACKAGES}
348 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
349 (bmake check > /dev/null 2>&1 || \
350 bmake ${PKGSRC_OPTIONS} clean build install)"
351 .endfor
353 # Remove packages which nothing depends on, add a whatis database
354 # for pkgsrc manual pages, create an initial locate database and
355 # clean up
357 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
358 ${CHROOT_CMD} "makewhatis /usr/pkg/man"
359 -umount ${ISOROOT}/usr/pkgsrc/distfiles
360 umount ${ISOROOT}/usr/pkgsrc
361 rm -rf ${ISOROOT}/usr/pkgobj
362 rm -f ${ISOROOT}/etc/resolv.conf
363 ${CHROOT_CMD} /etc/periodic/weekly/310.locate
364 umount ${ISOROOT}/dev
366 mkiso:
367 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
368 -R -J -o ${ISOFILE} \
369 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
372 mkimg:
373 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
374 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
375 vnconfig -u `cat ${ISODIR}/vn.which`; fi
376 @echo "STEP: determine required image size"
377 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
378 sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`; \
379 dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz};
380 fdisk -IB -p ${IMGFILE}
381 @echo "STEP: determine free vn device"
382 vnconfig -l | grep "not in use" | head -n 1 | \
383 cut -f 1 -d: > ${ISODIR}/vn.which
384 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
385 @echo "STEP: write standard disklabel"
386 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
387 @echo "STEP: read disklabel back"
388 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
389 @echo "STEP: determine number of sectors of whole disk"
390 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
391 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
392 @echo "STEP: write modified disklabel back"
393 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
394 rm ${IMGFILE}.label
395 @echo "STEP: write bootsector"
396 disklabel -B `cat ${ISODIR}/vn.which`s1
397 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
398 newfs /dev/`cat ${ISODIR}/vn.which`s1a
399 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
400 cpdup ${ISOROOT} ${IMGMNT}
401 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
402 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
403 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
404 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
405 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
406 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
407 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
408 @echo "STEP: cleanup"
409 df ${IMGMNT}
410 umount ${IMGMNT}
411 vnconfig -u `cat ${ISODIR}/vn.which`
412 rm -f ${ISODIR}/vn.which
413 rmdir ${IMGMNT}
414 @echo "STEP: done"
416 clean:
417 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
418 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
419 -umount ${ISOROOT}/dev > /dev/null 2>&1
420 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
421 vnconfig -u `cat ${ISODIR}/vn.which`; fi
422 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
423 rm -rf ${ISOROOT}
424 rm -rf ${NRLOBJDIR}/nrelease
425 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
427 realclean: clean
428 rm -rf ${OBJSYS}/${KERNCONF}
430 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
431 # override location.
433 rm -rf ${ISODIR}/packages
434 rm -rf ${ISODIR}/distfiles
436 pkgsrc_bootstrap:
437 mkdir -p /usr/release/bootstrap
438 (cd ${PKGSRC_PATH}/bootstrap; \
439 export share_dir=/usr/release/bootstrap/share; \
440 ./bootstrap --workdir /usr/release/bootstrap)
442 pkgsrc_cdrecord:
443 .if !exists (${PKGBIN_MKISOFS})
444 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
445 .endif
447 help all:
448 @echo "make [gui] release - complete build from scratch"
449 @echo "make [gui] quick - attempt to do an incremental rebuild"
450 @echo "make [gui] realquick - attempt to restart after world & kernel"
451 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
452 @echo ""
453 @echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
455 .PHONY: release quickrel realquickrel
456 .PHONY: installer
457 .PHONY: quick realquick
458 .PHONY: check buildworld1 buildworld2
459 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
460 .PHONY: clean realclean help all srcs
462 .include <bsd.prog.mk>