Menu

[r8924]: / trunk / tools / end2end-build.sh  Maximize  Restore  History

Download this file

160 lines (135 with data), 3.2 kB

  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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/sh
#
# Copy this somewhere else and edit to your heart's content.
#
# Space added in places to avoid potential merge conflicts.
#
# Values you shouldn't change.
clean=true
# Define beforehand to work around shell bugs.
postdir=/dev/null
tmpdir=/dev/null
# Values you can and should change.
branch=trunk
cvsup_host=cvsup1.freebsd.org
default_archs="amd64 i386"
postdir_base=/dev/null
tmpdir_template=e2e-bld.XXXXXXXX
setup() {
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export SHELL=/bin/sh
tmpdir=$(realpath "$(mktemp -d $tmpdir_template)")
chmod 0755 $tmpdir
pull $tmpdir 2>&1 | tail -n 30
cd $tmpdir
if [ -d "$postdir_base" ]; then
postdir="$postdir_base/$(env LC_LANG=C date '+%m-%d-%Y')"
sudo mkdir -p "$postdir"
else
postdir=
fi
}
cleanup() {
sudo rm -Rf $tmpdir
}
pull() {
svn co https://freenas.svn.sourceforge.net/svnroot/freenas/$branch $1
}
post_images() {
(cd obj.$arch
release=$(ls *$arch.iso | sed -e "s/-$arch.*//g")
if [ "${RELEASE_BUILD:-}" = yes ]; then
cp ../ReleaseNotes README
set -- *.iso *.xz README
else
set -- *.iso *.xz
fi
for file in $*; do
sudo sh -c "sha256 $file > $file.sha256.txt"
if [ -d "$postdir" ]; then
sudo cp $file* "$postdir"/.
fi
scp -o BatchMode=yes $file* \
yaberauneya,freenas@frs.sourceforge.net:/home/frs/project/f/fr/freenas/FreeNAS-8-nightly
done)
}
while getopts 'A:b:c:C:p:' optch; do
case "$optch" in
A)
_arch=
for arch in $default_archs; do
if [ "$arch" = "$OPTARG" ]; then
_arch=$OPTARG
break
fi
done
if [ -z "$_arch" ]; then
echo "${0##*/}: ERROR: unknown architecture: $OPTARG"
exit 1
fi
archs="$archs $OPTARG"
;;
b)
branch=$OPTARG
;;
c)
cvsup_host=$OPTARG
;;
C)
clean=false
;;
p)
postdir_base=$OPTARG
;;
*)
echo "${0##*/}: ERROR: unhandled/unknown option: $optch"
exit 1
;;
esac
done
: ${archs=$default_archs}
set -e
setup
set +e
if $clean; then
clean_s='yes'
else
clean_s='no'
fi
cat <<EOF
=========================================================
SETTINGS SUMMARY
=========================================================
Will build these archs: $archs
Branch: $branch
cvsup host: $cvsup_host
---------------------------------------------------------
Image directory: $postdir
Build directory: $tmpdir
Clean if successful: $clean_s
---------------------------------------------------------
EOF
for arch in $archs; do
log=build-$arch.log
# Build
BUILD="sh build/do_build.sh"
BUILD_PASS1_ENV="FREEBSD_CVSUP_HOST=$cvsup_host PACKAGE_PREP_BUILD=1"
BUILD_PASS2_ENV=""
# Build twice so the resulting image is smaller than the fat image
# required for producing ports.
# XXX: this should really be done in the nanobsd files to only have to
# do this once, but it requires installing world twice.
sudo sh -c "export FREENAS_ARCH=$arch; env $BUILD_PASS1_ENV $BUILD && env $BUILD_PASS2_ENV $BUILD" > $log 2>&1
ec=$?
# Build success / failure is printed out in the last line :)...
tail -n 1 $log
if [ $ec -eq 0 ]; then
post_images
else
tail -n 10 $log | head -n 9
clean=false
fi
done
if $clean; then
cd /; cleanup
fi
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.