Menu

[r9812]: / trunk / build / nano_env  Maximize  Restore  History

Download this file

141 lines (115 with data), 4.3 kB

#!/bin/sh
#
# Script for building the nanobsd environment up. Required because of the way
# things are setup in NanoBSD today (this should be simplified).
#

# Environment variables that drive the nanobsd build and a few of the
# other build / image generation scripts.

# The FreeNAS source and build tree is rooted here.
: ${AVATAR_ROOT=$(pwd)}

# The support site for this avatar project.
: ${AVATAR_SUPPORT_SITE=http://support.freenas.org}

# The architecture for the machine (amd64, i386, etc).
# NOTE: have to do things this way because nanobsd.sh sets this value
# explicitly in the script.
: ${FREENAS_ARCH=$(uname -p)}
NANO_ARCH=$FREENAS_ARCH

# Setup a humanized name for the image. Doesn't affect obj.*'s naming because
# people would get jangry (sic) having to rebuild their workspaces from
# scratch, changing NANO_ARCH would require shuffling around kernconfs, hacking
# TARGET/TARGET_MACHINE before jumping into the [base/ports] build system and
# because it's not user facing.
#
# Bottom line is that this is a cheap 'hack' to get what we want for Linux-y
# and Windows-y users.
case "$NANO_ARCH" in
amd64)
	NANO_ARCH_HUMANIZED="x64"
	;;
i386)
	NANO_ARCH_HUMANIZED="x86"
	;;
*)
	NANO_ARCH_HUMANIZED=$NANO_ARCH
	;;
esac

NANO_OBJ=${AVATAR_ROOT}/obj.${NANO_ARCH}

# Where the build configuration files used by nanobsd.sh live.
NANO_CFG_BASE=$AVATAR_ROOT/nanobsd

# Where the FreeBSD ports tree lives.
NANO_PORTS="$AVATAR_ROOT/FreeBSD/ports"

# Where the FreeBSD source tree lives.
NANO_SRC="$AVATAR_ROOT/FreeBSD/src"

# Where the nanobsd tools live.
NANO_TOOLS="$AVATAR_ROOT/build/nanobsd"

if [ -z "${SVNVERSION}" ]; then
	# This is executed sometimes as set -e; don't let it fail by no-oping
	# it.
	svnversion=$(command -v svnversion || :)
	git_cmd=$(command -v git || :)

	if [ -n "$svnversion" ] ; then
		# svn prints out errors to stdout. Bad svn! No cookie for you!
		svn=$(sh -c "echo r\$(cd ${AVATAR_ROOT} && /usr/bin/env LANG=C $svnversion)") || svn=""
	fi
	[ "${svn}" = "rUnversioned directory" ] && svn=""
	if [ -z "$svn" ]; then
		if [ -n "$git_cmd" ] ; then
			git=`$git_cmd rev-parse --verify --short HEAD 2>/dev/null`
			svn=`$git_cmd svn find-rev $git 2>/dev/null`
			if [ -n "$svn" ] ; then
				svn="r${svn}"
				git="=${git}"
			else
				svn=`$git_cmd log | fgrep 'git-svn-id:' | head -1 | \
				    sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'`
				if [ -n $svn ] ; then
					svn="r${svn}"
					git="+${git}"
				else
					git="${git}"
				fi
			fi
			if $git_cmd --work-tree=${AVATAR_ROOT} diff-index \
			    --name-only HEAD | read dummy; then
				git="${git}_dirty"
			fi
		fi
	fi
fi

# REVISION gets overloaded when doing tagged versions, SVNREVISION allows
# us to keep the SVN revision number even when the version string is
# overloaded with a name.
SVNREVISION=${SVNREVISION:-$(echo ${svn}${git})}
REVISION=${REVISION:-$(echo ${svn}${git})}

NANO_KERNEL="$NANO_CFG_BASE/FREENAS.$NANO_ARCH"

# Local directories to install via buildworld and installworld respectively;
# see LOCAL_DIRS in Makefile.inc1, e.g. tools/regression/netinet6/ip6_sockets .
#NANO_LOCAL_DIRS=

# Modules to build with the kernel.
NANO_MODULES="cxgb ext2fs geom ipmi pf pflog smbfs libiconv libmchain syscons udf zfs opensolaris usb/xhci"

# Feature sets to enable as part of the build.
#SW_FEATURES="DEBUG MULTIMEDIA REPORTING"
SW_FEATURES="DEBUG REPORTING"

# The GEOM label to use.
NANO_LABEL="FreeNAS"

# Version of the software.
VERSION="8.2.1-ALPHA"

# Image name, e.g. FreeNAS-8.1-r7609-amd64 or FreeNAS-8.0.1-RC1-i386, see
# nanobsd/freenas-common:last_orders().
NANO_NAME="$NANO_LABEL-$VERSION-$REVISION-$NANO_ARCH_HUMANIZED"
NANO_IMGNAME="$NANO_NAME"

# Export these vars to override the NanoBSD defaults.
export AVATAR_ROOT FREENAS_ARCH
export NANO_ARCH NANO_ARCH_HUMANIZED NANO_CFG_BASE NANO_IMGNAME NANO_KERNEL
export NANO_MODULES NANO_NAME NANO_OBJ NANO_SRC NANO_TOOLS REVISION
export SVNREVISION

# The following variables are for builders with local package and distfile
# mirrors. They're intentionally unset here to avoid accidental pollution from
# one's environment. Please replace these lines with valid values.

# See bsd.port.mk
unset MASTER_SITE_BACKUP
unset MASTER_SITE_OVERRIDE

# See pkg_add(1).
unset PACKAGEROOT
unset PACKAGESITE

# vim: syntax=sh
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.