xref: /dragonfly/tools/snapshots/dobuild (revision 926deccb)
1#!/bin/csh
2#
3# Create a working chroot for snapshot building
4#
5
6source config
7
8set ncpu = `sysctl -n hw.ncpu`
9set pushdsilent
10set xdate = "date"
11
12echo "`$xdate` - SNAPSHOTS DOBUILD BEGIN"
13
14# Options
15#
16set nrelease_args = "release"
17
18foreach arg ( $argv )
19    switch ( $arg )
20    case "realquick":
21	set quick = 1
22	set realquick = 1
23	set nrelease_args = "realquick"
24	breaksw
25    case "quick":
26	set quick = 1
27	set nrelease_args = "quick"
28	breaksw
29    default:
30	echo "`$xdate` - Unknown option $arg"
31	echo "`$xdate` - SNAPSHOTS DOBUILD END"
32	exit 1
33    endsw
34end
35
36echo "`$xdate` - Setting up chroot environment"
37if ( ! -e $build/root/dev/null ) then
38    mount_devfs dummy $build/root/dev
39endif
40
41umount $build/root/usr/pkgsrc/distfiles >& /dev/null
42mount_null $build/distfiles $build/root/usr/pkgsrc/distfiles
43
44setenv PKGSRC_PATH /usr/pkgsrc
45
46echo "`$xdate` - Build is running nrelease, tail -f $build/nrelease-build.out"
47chroot $build/root csh -c "cd /usr/src/nrelease; make -DNOPROFILE -DWITHOUT_SRCS img $nrelease_args" >& $build/nrelease-build.out
48
49if ( $? > 0 ) then
50    echo "`$xdate` - NRelease build had a problem, see $build/nrelease-build.out"
51    echo "`$xdate` - SNAPSHOTS DOBUILD END"
52    exit 1
53endif
54
55# Figure out the filename
56#
57set arch = `uname -p`
58if ( "$arch" == "i386" ) then
59set kobjs = $build/root/usr/obj/usr/src/sys/GENERIC
60else
61set kobjs = $build/root/usr/obj/usr/src/sys/X86_64_GENERIC
62endif
63
64if ( ! -f $kobjs/vers.txt ) then
65    echo "`$xdate` - nrelease build did not generate $kobjs/vers.txt"
66    echo "`$xdate` - SNAPSHOTS DOBUILD END"
67    exit 1
68endif
69
70# Store the snapshots.  Make sure the files are inaccessible until
71# completely written out.
72#
73set basename = `cat $kobjs/vers.txt`
74mkdir -p $snapshots/$arch/images
75mkdir -p $snapshots/$arch/kernels
76set filepath = $snapshots/$arch
77umask 077
78bzip2 < $build/root/usr/release/dfly.iso > $filepath/images/$basename.iso.bz2
79bzip2 < $build/root/usr/release/dfly.img > $filepath/images/$basename.img.bz2
80(cd $build/root/usr/release/root; tar cf - boot | bzip2 > $filepath/kernels/$basename.boot.tar.bz2)
81chmod 644 $filepath/images/$basename.iso.bz2
82chmod 644 $filepath/images/$basename.img.bz2
83chmod 644 $filepath/kernels/$basename.boot.tar.bz2
84sync
85pushd $filepath/images
86md5 $basename.iso.bz2 >> CHECKSUM.MD5
87md5 $basename.img.bz2 >> CHECKSUM.MD5
88popd
89
90pushd $filepath/kernels
91md5 $basename.boot.tar.bz2 >> CHECKSUM.MD5
92popd
93
94# Only adjust the 'latest' softlink shortcuts for
95# development snapshots.  Release shortcuts have
96# to be done manually.
97#
98if ( "$relsname" == "DEV" ) then
99    pushd $filepath
100    rm -f DragonFly-${arch}-LATEST-ISO.iso.bz2.new
101    rm -f DragonFly-${arch}-LATEST-IMG.img.bz2.new
102    rm -f DragonFly-${arch}-LATEST-BOOT.tar.bz2.new
103    ln -s images/$basename.iso.bz2 DragonFly-${arch}-LATEST-ISO.iso.bz2.new
104    ln -s images/$basename.img.bz2 DragonFly-${arch}-LATEST-IMG.img.bz2.new
105    ln -s kernels/$basename.boot.tar.bz2 DragonFly-${arch}-LATEST-BOOT.tar.bz2.new
106    mv -f DragonFly-${arch}-LATEST-ISO.iso.bz2.new \
107	    DragonFly-${arch}-LATEST-ISO.iso.bz2
108    mv -f DragonFly-${arch}-LATEST-IMG.img.bz2.new \
109	    DragonFly-${arch}-LATEST-IMG.img.bz2
110    mv -f DragonFly-${arch}-LATEST-BOOT.tar.bz2.new \
111	    DragonFly-${arch}-LATEST-BOOT.tar.bz2
112    popd
113endif
114
115sync
116
117echo "`$xdate` - SNAPSHOTS DOBUILD END"
118