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