From 19043dfe1d6c10399b565e41b02672f440ee734e Mon Sep 17 00:00:00 2001 From: vpeter4 Date: Sat, 2 Aug 2014 18:49:57 +0200 Subject: [PATCH] allow packages in projects folder This allows to use local package from project folder instead of system one from packages folder. It simplifies package dependency for newer projects like for TBS Matrix I'm working on. It requires different gcc, u-boot, ... --- config/functions | 24 ++++++++++++++++++++---- config/path | 31 ++++++++++++++++++++++++++++++- scripts/image | 11 ++++++++++- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/config/functions b/config/functions index 29937ff181..fadbd4124f 100644 --- a/config/functions +++ b/config/functions @@ -55,12 +55,22 @@ setup_toolchain() { } kernel_path() { - . $ROOT/packages/linux/package.mk + if [ -e $ROOT/projects/$PROJECT/packages/linux/package.mk ]; then + . $ROOT/projects/$PROJECT/packages/linux/package.mk + else + . $ROOT/packages/linux/package.mk + fi + echo $ROOT/$BUILD/${PKG_NAME}-${PKG_VERSION} } kernel_version() { - . $ROOT/packages/linux/package.mk + if [ -e $ROOT/projects/$PROJECT/packages/linux/package.mk ]; then + . $ROOT/projects/$PROJECT/packages/linux/package.mk + else + . $ROOT/packages/linux/package.mk + fi + echo ${PKG_VERSION} } @@ -72,10 +82,16 @@ get_module_dir() { # get package's build dir get_build_dir() { if [ ! -z $1 ] ; then - local _PKG_DIR=$(find $ROOT/packages -name $1) - if [ -d $_PKG_DIR -a -f $_PKG_DIR/package.mk ] ; then + local _PKG_DIR=$(find $ROOT/projects/$PROJECT/packages -name $1) + if [ -d "$_PKG_DIR" -a -f $_PKG_DIR/package.mk ] ; then . $_PKG_DIR/package.mk + else + local _PKG_DIR=$(find $ROOT/packages -name $1) + if [ -d "$_PKG_DIR" -a -f $_PKG_DIR/package.mk ] ; then + . $_PKG_DIR/package.mk + fi fi + echo $ROOT/$BUILD/${PKG_NAME}-${PKG_VERSION} fi } diff --git a/config/path b/config/path index 6867e03db8..8defcd927a 100644 --- a/config/path +++ b/config/path @@ -64,8 +64,12 @@ SED="sed -i" PKG_IS_ADDON="no" if [ -n "$1" ]; then + _PKG_ROOT_NAME=$(echo $1 | cut -d: -f1) + + # first check project folder for a package FOUND=0 - for DIR in $ROOT/`find $PACKAGES -type d -name $(echo $1| awk -F : '{print $1}') ! -wholename \*\/source\/\* 2>/dev/null` ; do + ALL_DIRS="" + for DIR in $ROOT/`find projects/$PROJECT/packages -type d -name $_PKG_ROOT_NAME ! -wholename \*\/source\/\* 2>/dev/null` ; do # keep track of dirs with meta for debugging if [ -z "$ALL_DIRS" ] ; then ALL_DIRS="$DIR" @@ -84,6 +88,31 @@ SED="sed -i" fi fi done + + # then check packages folder if not found already + if [ $FOUND -eq 0 ] ; then + FOUND=0 + ALL_DIRS="" + for DIR in $ROOT/`find $PACKAGES -type d -name $_PKG_ROOT_NAME ! -wholename \*\/source\/\* 2>/dev/null` ; do + # keep track of dirs with meta for debugging + if [ -z "$ALL_DIRS" ] ; then + ALL_DIRS="$DIR" + else + ALL_DIRS="$ALL_DIRS\\n$DIR" + fi + if [ -f "$DIR/package.mk" ] ; then + FOUND=$((FOUND+1)) + # found first. set $PKG_DIR + PKG_DIR="$DIR" + if [ $FOUND -gt 1 ] ; then + # found more ? fail + echo "Error - multiple package folders:" + echo -e "$ALL_DIRS" + exit 1 + fi + fi + done + fi fi if [ -r $PKG_DIR/package.mk ]; then diff --git a/scripts/image b/scripts/image index 98b39544d2..36f59f1dae 100755 --- a/scripts/image +++ b/scripts/image @@ -237,7 +237,16 @@ IMAGE_NAME="$DISTRONAME-$TARGET_VERSION" # remove n previous created release image rm -rf $TARGET_IMG/$IMAGE_NAME.img.gz if [ -n "$BOOTLOADER" ]; then - BOOTLOADER_DIR=`find $PACKAGES -type d -name $BOOTLOADER 2>/dev/null` + if [ -d $ROOT/projects/$PROJECT/packages ]; then + BOOTLOADER_DIR=`find $ROOT/projects/$PROJECT/packages -type d -name $BOOTLOADER 2>/dev/null` + else + BOOTLOADER_DIR="" + fi + + if [ -z "$BOOTLOADER_DIR" -o ! -d "$BOOTLOADER_DIR" ]; then + BOOTLOADER_DIR=`find $PACKAGES -type d -name $BOOTLOADER 2>/dev/null` + fi + if [ -d "$BOOTLOADER_DIR"/files ]; then cp -R $BOOTLOADER_DIR/files/* $RELEASE_DIR fi