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