Menu

[r8420]: / trunk / build / do_build.sh  Maximize  Restore  History

Download this file

147 lines (130 with data), 3.5 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
#!/bin/sh
#
# Build (either from scratch or using cached files):
# sh build/do_build.sh
#
# Force a full rebuild:
# sh build/do_build.sh -f
#
# Force an update and rebuild world:
# sh build/do_build.sh -u -f
#
# Just pull/update the sources:
# sh build/do_build.sh -B -u
#
cd "$(dirname "$0")/.."
. build/nano_env
. build/functions.sh
BUILD=true
if [ -d ${NANO_OBJ} ]; then
FORCE_FREEBSD_BUILD=false
else
FORCE_FREEBSD_BUILD=true
fi
MAKE_JOBS=$(( 2 * $(sysctl -n kern.smp.cpus) + 1 ))
if [ -f FreeBSD/supfile ]; then
UPDATE=false
else
UPDATE=true
fi
usage() {
cat <<EOF
usage: ${0##*/} [-Bfu] [-j make-jobs] [-- nanobsd-options]
-j defaults to $MAKE_JOBS
EOF
exit 1
}
while getopts 'Bfj:u' optch; do
case "$optch" in
B)
info "will not build"
BUILD=false
;;
f)
FORCE_FREEBSD_BUILD=true
;;
j)
echo $OPTARG | egrep -q '^[[:digit:]]+$' && [ $OPTARG -le 0 ]
if [ $? -ne 0 ]; then
usage
fi
MAKE_JOBS=$OPTARG
;;
u)
UPDATE=true
;;
\?)
usage
;;
esac
done
shift $(( $OPTIND - 1 ))
set -e
requires_root
if $UPDATE; then
if [ -z "$FREEBSD_CVSUP_HOST" ]; then
error "No sup host defined, please define FREEBSD_CVSUP_HOST and rerun"
fi
echo "Checking out tree from ${FREEBSD_CVSUP_HOST}..."
mkdir -p $FREENAS_ROOT/FreeBSD
SUPFILE=$FREENAS_ROOT/FreeBSD/supfile
cat <<EOF > $SUPFILE
*default host=${FREEBSD_CVSUP_HOST}
*default base=$FREENAS_ROOT/FreeBSD/sup
*default prefix=$FREENAS_ROOT/FreeBSD
*default release=cvs
*default delete use-rel-suffix
*default compress
src-all tag=RELENG_8_2
ports-all date=2011.07.17.00.00.00
EOF
csup -L 1 $SUPFILE
# Force a repatch because csup pulls pristine sources.
: > $FREENAS_ROOT/FreeBSD/src-patches
: > $FREENAS_ROOT/FreeBSD/ports-patches
# Nuke the newly created files to avoid build errors, as
# patch(1) will automatically append to the previously
# non-existent file.
for file in $(find FreeBSD/ -name '*.orig' -size 0); do
rm -f "$(echo "$file" | sed -e 's/.orig//')"
done
fi
for patch in $(cd $FREENAS_ROOT/patches && ls freebsd-*.patch); do
if ! grep -q $patch $FREENAS_ROOT/FreeBSD/src-patches; then
echo "Applying patch $patch..."
(cd FreeBSD/src && patch -E -p0 < $FREENAS_ROOT/patches/$patch)
echo $patch >> $FREENAS_ROOT/FreeBSD/src-patches
fi
done
for patch in $(cd $FREENAS_ROOT/patches && ls ports-*.patch); do
if ! grep -q $patch $FREENAS_ROOT/FreeBSD/ports-patches; then
echo "Applying patch $patch..."
(cd FreeBSD/ports && patch -E -p0 < $FREENAS_ROOT/patches/$patch)
echo $patch >> $FREENAS_ROOT/FreeBSD/ports-patches
fi
done
# HACK: chmod +x the script because:
# 1. It's not in FreeBSD proper, so it will always be touched.
# 2. The mode is 0644 by default, and using a pattern like ${SHELL}
# in the Makefile snippet won't work with csh users because the
# script uses /bin/sh constructs.
if [ -f "$NANO_SRC/include/mk-osreldate.sh.orig" ]; then
chmod +x $NANO_SRC/include/mk-osreldate.sh
fi
if ! $BUILD; then
exit 0
fi
# OK, now we can build
cd $NANO_SRC
args="-c ${NANO_CFG_BASE}/freenas-common"
if ! "$FORCE_FREEBSD_BUILD"; then
extra_args="-b"
fi
echo $NANO_SRC/tools/tools/nanobsd/nanobsd.sh $args $* $extra_args
if env MAKE_JOBS=$MAKE_JOBS sh $NANO_SRC/tools/tools/nanobsd/nanobsd.sh $args $* $extra_args; then
xz -f ${NANO_OBJ}/_.disk.image
mv ${NANO_OBJ}/_.disk.image.xz ${NANO_OBJ}/${NANO_IMGNAME}.xz
sha256 ${NANO_OBJ}/${NANO_IMGNAME}.xz
else
error "$NANO_LABEL build FAILED; please check above log for more details"
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.