Menu

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

Download this file

148 lines (133 with data), 3.4 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
#!/bin/sh
#
# Build (either from scratch or using cached files):
# sh build/do_build.sh
#
# Force a resync/repatch of just ports:
# sh build/do_build.sh -f ports
#
# Force a resync/repatch of everything:
# sh build/do_build.sh -f all
#
# Just pull the sources:
# sh build/do_build.sh -B
#
error() {
echo >&2 "${0##/*}: ERROR: $*"
exit 1
}
usage() {
echo "usage: ${0##*/} [-B] [-f ports|all] [-- nanobsd-options]"
exit 1
}
cd "$(dirname "$0")/.."
BUILD=true
FORCE_UPDATE=false
FORCE_REBUILD_PORTS=false
FORCE_REBUILD_SRC=false
while getopts 'f:' optch; do
case "$optch" in
B)
echo "will not build"
BUILD=false
;;
f)
FORCE_UPDATE=true
case "$OPTARG" in
all)
FORCE_REBUILD_PORTS=true
FORCE_REBUILD_SRC=true
;;
ports)
FORCE_REBUILD_PORTS=true
;;
src)
FORCE_REBUILD_SRC=true
;;
*)
usage
;;
esac
;;
\?)
usage
;;
esac
done
shift $(( $OPTIND - 1 ))
if [ $(id -ru) -ne 0 ]; then
error "You must be root when running $0"
fi
root=$(pwd)
: ${FREENAS_ARCH=$(uname -p)}
export FREENAS_ARCH
export NANO_OBJ=${root}/obj.${FREENAS_ARCH}
if [ ! -d FreeBSD ]; then
mkdir FreeBSD
fi
# Make sure we have FreeBSD src, fetch using csup if not
if [ ! -f FreeBSD/supfile ] || "$FORCE_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}..."
cat <<EOF > FreeBSD/supfile
*default host=${FREEBSD_CVSUP_HOST}
*default base=${root}/FreeBSD/sup
*default prefix=${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 FreeBSD/supfile
# Force a repatch because csup pulls pristine sources.
: > ${root}/FreeBSD/src-patches
: > ${root}/FreeBSD/ports-patches
# XXX: work around a bug in csup where it doesn't clean out all
# mime-types, as it nukes certain types (.c, .h, etc) files properly.
#
# 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
# Make sure that all the patches are applied
for i in $(cd ${root}/patches && echo freebsd-*.patch); do
if ! grep -q $i ${root}/FreeBSD/src-patches; then
echo "Applying patch $i..."
(cd FreeBSD/src && patch -p0 < ${root}/patches/$i)
echo $i >> ${root}/FreeBSD/src-patches
fi
done
for i in $(cd ${root}/patches && echo ports-*.patch); do
if ! grep -q $i ${root}/FreeBSD/ports-patches; then
echo "Applying patch $i..."
(cd FreeBSD/ports && patch -p0 < ${root}/patches/$i)
echo $i >> ${root}/FreeBSD/ports-patches
fi
done
if ! $BUILD; then
exit 0
fi
# OK, now we can build
cd FreeBSD/src
args="-c ${root}/nanobsd/freenas-common"
if [ -d ${NANO_OBJ} ] && ! "$FORCE_REBUILD_SRC"; then
extra_args="-b"
fi
if $FORCE_REBUILD_PORTS; then
find $NANO_OBJ/ports/packages/ 2>/dev/null | xargs -n 1 rm -Rf
fi
echo tools/tools/nanobsd/nanobsd.sh $args $* $extra_args
if sh tools/tools/nanobsd/nanobsd.sh $args $* $extra_args; then
REVISION=$(svnversion ${root})
NANO_NAME="FreeNAS-8r${REVISION}-${FREENAS_ARCH}"
xz -f ${NANO_OBJ}/_.disk.image
mv ${NANO_OBJ}/_.disk.image.xz ${NANO_OBJ}/${NANO_NAME}.xz
sha256 ${NANO_OBJ}/${NANO_NAME}.xz
else
error 'FreeNAS 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.