#! /bin/sh /usr/share/dpatch/dpatch-run ## 001_tinyos-sh.dpatch by ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Sourced file that sets up TinyOS environment, with per-user persistence @DPATCH@ diff -urN tinyos-2.1.0.orig/tinyos.sh tinyos-2.1.0/tinyos.sh --- tinyos-2.1.0.orig/tinyos.sh 1969-12-31 17:00:00.000000000 -0700 +++ tinyos-2.1.0/tinyos.sh 2008-08-27 13:28:48.000000000 -0600 @@ -0,0 +1,43 @@ +#! /usr/bin/env bash +# Here we setup the environment +# variables needed by the tinyos +# make system + +TOSBASE=/opt/tinyos + +# $1 is a directory or tos version number +# returns a fully rooted and valid TOSROOT +getdir() +{ + if [ -d "$1" -a -d "$1/tos" ]; then + echo "$1" + elif [ -d "$TOSBASE/$1" -a -d "$TOSBASE/$1/tos" ]; then + echo "$TOSBASE/$1" + fi +} + +# Clear TOS environment +if [ -n "$TOSROOT" ]; then + CLASSPATH=$(echo $CLASSPATH | sed -e "s|:$TOSROOT/support/sdk/java||") +fi +unset TOSDIR MAKERULES + +# Set TOS environment +TOSROOT=$(getdir "$1") +if [ -z "$TOSROOT" ]; then + TOSROOT=$(cat ~/.tosrc 2>/dev/null) +fi + +if [ -z "$TOSROOT" ]; then + echo "No TinyOS source directory found. Usage:" >&2 + echo "source /opt/tinyos/tinyos.sh [ | ]" >&2 + export TOSROOT TOSDIR MAKERULES +else + echo "Setting up for TinyOS source in $TOSROOT" + echo "$TOSROOT" > ~/.tosrc + TOSDIR="$TOSROOT/tos" + CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java + MAKERULES="$TOSROOT/support/make/Makerules" + export TOSROOT TOSDIR CLASSPATH MAKERULES +fi +unset TOSBASE tmp