summaryrefslogtreecommitdiff
path: root/scripts/init
blob: 29c23ba9eca63bf564295a53c368b1eadc0b8a33 (plain)
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
#!/bin/sh
# This script is a init script for our bsp. It resides in the bsp release specific folder
# this is the soc specific init script. It assumes that you have only one soc layer
# which holds all your machines.
PHYLINUX_API_VERSION="2"

# Try to find ROOTDIR from arg0 of shell process.
DIR="`dirname $(readlink -f $0)`"

# Try to find ROOTDIR of the Yocto BSP. Walk up the directory tree until we
# find the sources/meta-phytec or .repo directory. Returns the empty string as
# an error code.
find_root_dir() {
	dir=$(readlink -f "$1")  # should return an absoulte path
	while [ ! "$dir" = "/" ]; do
		if [ -d "$dir/.repo" ]; then
		# or [ -d "$dir/sources/meta-phytec" ];
			echo $dir;
			return;
		fi
		dir=$(dirname "$dir")
	done
	# If anchor directory isn't found, function returns the empty strings
	# as an error code.
}

ROOTDIR=$(find_root_dir "$DIR")
if [ "$ROOTDIR" = "" ]; then
	echo >&2 "ERROR: Cannot find root directory of the Yocto BSP."
        echo >&2 "Is '$DIR' in a checkout of a BSP? Aborting..."
	exit 1;
fi

# copy release notes to rootdir, if they are present in phy2octo
RELEASE_UID=$(sed -n 's:.*release_uid="\([^"]*\).*:\1:p' ${ROOTDIR}/.repo/manifest.xml)
RELEASE_NOTES="${ROOTDIR}/.repo/manifests/releasenotes/${RELEASE_UID}"
if [ -e ${RELEASE_NOTES} ]; then
	install -pm 0644 ${RELEASE_NOTES} ${ROOTDIR}/ReleaseNotes
fi

# Folders and Readme
PHYTEC_DIR="${ROOTDIR}/sources/meta-phytec"
install -m 0644 ${PHYTEC_DIR}/conf/doc/HOWTO ${ROOTDIR}

# Setup template directory. Allow caller to overwrite default TEMPLATECONF.
if [ -z "${TEMPLATECONF}" ]; then
	export TEMPLATECONF="${ROOTDIR}/tools/templateconf"
	copy_file_by_priority=${PHYTEC_DIR}/scripts/copy_file_by_priority.py
	install -d ${TEMPLATECONF}
	$copy_file_by_priority conf/bblayers.conf.sample ${TEMPLATECONF}
	$copy_file_by_priority conf/local.conf.sample ${TEMPLATECONF}
	$copy_file_by_priority conf/conf-notes.txt ${TEMPLATECONF}
fi

# Init a build directory if we dont have one.
# NOTE: Since the script 'oe-buildenv-internal' will use the current working
# directory as the base for the build directory, we set the build directory
# explicitly as argument here. So the 'init' script's actions don't depend on
# the current working directory of the caller. This method works for dash, too.
if [ -z "${1}" ]; then
	set -- "${ROOTDIR}/build"
else
	set -- "${ROOTDIR}/${1}"
fi
cd ${ROOTDIR}/sources/poky/
. ./oe-init-build-env > /dev/null

${PHYTEC_DIR}/scripts/init_bblayers.py
${PHYTEC_DIR}/scripts/copy_site_conf.py
${PHYTEC_DIR}/scripts/init_machine.py

echo ""
echo "Before you start your work, please check your build/conf/local.conf for"
echo "host specific configuration. Check the documentation especially for:"
echo "   - proxy settings"
echo "   - DL_DIR"
echo "   - SSTATE_DIR"
echo ""
echo "To set up your shell environment for some Yocto work, you have to type this"
echo "command, including the 'dot':"
echo ""
echo "    $ . sources/poky/oe-init-build-env"
echo ""
echo ""