Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
257 lines (220 sloc) 6.97 KB
set -e
. config/functions
# setup initial directorys (relative to root)
CONFIG=config
SCRIPTS=scripts
PACKAGES=packages
SOURCES=sources
BUILD_BASE=build
TARGET=target
ADDONS=addons
# include ARCH specific options
if [ -f config/arch.$TARGET_ARCH ]; then
. config/arch.$TARGET_ARCH
fi
HOST_NAME=`$LOCAL_CC -dumpmachine`
TARGET_NAME=$TARGET_GCC_ARCH-libreelec-linux-gnu${TARGET_ABI}
BUILD=$ROOT/$BUILD_BASE.$DISTRONAME-${BOARD:-${DEVICE:-$PROJECT}}.$TARGET_ARCH-$LIBREELEC_VERSION
if [ "$LIBREELEC_VERSION" = "devel" ] ; then
BUILD=$ROOT/$BUILD_BASE.$DISTRONAME-${BOARD:-${DEVICE:-$PROJECT}}.$TARGET_ARCH-$OS_VERSION-$LIBREELEC_VERSION
fi
if [ -n "$BUILD_SUFFIX" ]; then
BUILD=$BUILD-$BUILD_SUFFIX
fi
if [ "$IGNORE_VERSION" = "1" ]; then
BUILD=$ROOT/$BUILD_BASE.$DISTRONAME-${BOARD:-${DEVICE:-$PROJECT}}.$TARGET_ARCH
fi
TARGET_IMG=$ROOT/$TARGET
TARGET_ADDONS="$TARGET_IMG/$ADDONS/$ADDON_PATH"
ADDON_BUILD="$BUILD/$ADDONS/$1"
STAMPS_NOARCH=.stamps
STAMPS=$BUILD/.stamps
STAMPS_INSTALL=$BUILD/image/.stamps
DOCS=DOCS
TOOLCHAIN=$BUILD/toolchain
SYSROOT_PREFIX=$TOOLCHAIN/$TARGET_NAME/sysroot
LIB_PREFIX=$SYSROOT_PREFIX/usr
TARGET_PREFIX=$TOOLCHAIN/bin/$TARGET_NAME-
FAKEROOT_SCRIPT=$BUILD/.fakeroot
if [ -z "$INSTALL" ]; then
INSTALL=$BUILD/image/system
fi
INSTALL_INIT=$BUILD/image/initramfs/root-image
. config/sources
MAKE="$TOOLCHAIN/bin/make"
MAKEINSTALL="$TOOLCHAIN/bin/make -j1 DESTDIR=$SYSROOT_PREFIX install"
SED="sed -i"
# set package metadata
PKG_NAME="$1"
PKG_VERSION="0.0invalid"
PKG_REV="0"
PKG_ARCH="any"
PKG_LICENSE="unknown"
PKG_SITE=""
PKG_URL=""
PKG_GIT_URL=""
PKG_GIT_BRANCH=""
PKG_SOURCE_NAME=""
PKG_SOURCE_DIR=""
PKG_DEPENDS_TARGET=""
PKG_DEPENDS_HOST=""
PKG_DEPENDS_INIT=""
PKG_DEPENDS_BOOTSTRAP=""
PKG_SECTION=""
PKG_SHORTDESC="$1 (autogenerated)"
PKG_LONGDESC="$1 (autogenerated)"
PKG_IS_ADDON="no"
PKG_PATCH_DIRS=""
PKG_NEED_UNPACK=""
PKG_SHA256=""
PKG_ADDON_BROKEN=""
PKG_ADDON_NAME=""
PKG_ADDON_PROVIDES=""
PKG_ADDON_REQUIRES=""
PKG_ADDON_SCREENSHOT=""
PKG_ADDON_TYPE=""
PKG_DISCLAIMER=""
PKG_MAINTAINER=""
if [ -n "$1" ]; then
_PKG_ROOT_NAME=${1%:*}
_ALL_DIRS=""
_FOUND=0
_ANCHOR="@?+?@"
PKG_DIR=""
# If the package caches are unset, then populate them
if [ -z "${_CACHE_PACKAGE_LOCAL+x}" -o -z "${_CACHE_PACKAGE_GLOBAL+x}" ]; then
_CACHE_PACKAGE_LOCAL=""
_CACHE_PACKAGE_GLOBAL=""
# cache project folder for a package
for DIR in $(find $ROOT/projects/$PROJECT/packages -type d 2>/dev/null); do
[ -r "$DIR/package.mk" ] && _CACHE_PACKAGE_LOCAL+="${DIR}${_ANCHOR}\n"
done
# cache packages folder
for DIR in $(find $ROOT/$PACKAGES -type d 2>/dev/null); do
[ -r "$DIR/package.mk" ] && _CACHE_PACKAGE_GLOBAL+="${DIR}${_ANCHOR}\n"
done
export _CACHE_PACKAGE_LOCAL _CACHE_PACKAGE_GLOBAL
fi
# Check for any available local package in preference to a global package
for DIR in $(echo -e "${_CACHE_PACKAGE_LOCAL}" | grep -F "/${_PKG_ROOT_NAME}${_ANCHOR}"); do
DIR="${DIR%${_ANCHOR}}"
# found first, set $PKG_DIR
PKG_DIR="$DIR"
# keep track of dirs with package.mk for detecting multiple folders
_ALL_DIRS+="${DIR}\n"
_FOUND=$((_FOUND+1))
done
# If there's no local package available, use the global package
if [ $_FOUND -eq 0 ]; then
for DIR in $(echo -e "${_CACHE_PACKAGE_GLOBAL}" | grep -F "/${_PKG_ROOT_NAME}${_ANCHOR}"); do
DIR="${DIR%${_ANCHOR}}"
# found first, set $PKG_DIR
PKG_DIR="$DIR"
# keep track of dirs with package.mk for detecting multiple folders
_ALL_DIRS+="${DIR}\n"
_FOUND=$((_FOUND+1))
done
fi
# _FOUND multiple packages? fail
if [ $_FOUND -gt 1 ]; then
echo "Error - multiple package folders:"
echo -e "$_ALL_DIRS"
exit 1
fi
fi
if [ -n "$PKG_DIR" -a -r $PKG_DIR/package.mk ]; then
. $PKG_DIR/package.mk
fi
if [ "$PKG_IS_ADDON" = "yes" ] ; then
[ -z $PKG_SECTION ] && PKG_ADDON_ID="$PKG_NAME" || PKG_ADDON_ID="`echo $PKG_SECTION | sed 's,/,.,g'`.$PKG_NAME"
PKG_NEED_UNPACK="${PKG_NEED_UNPACK} $(get_pkg_directory $MEDIACENTER)"
fi
# Automatically set PKG_SOURCE_NAME unless it is already defined.
# PKG_SOURCE_NAME will be automatically set to a name based on
# the $PKG_NAME-$PKG_VERSION convention.
#
# Any $PKG_URL that references more than a single url will abort
# the build as these are no longer supported - use mkpkg instead.
if [ -n "$PKG_URL" -a -z "$PKG_SOURCE_NAME" -a -z "$PKG_GIT_URL" ]; then
if [[ $PKG_URL =~ .*\ .* ]]; then
echo "Error - packages with multiple urls are no longer supported, use mkpkg:"
echo "$PKG_URL"
exit 1
fi
PKG_SOURCE_NAME="$(basename "$PKG_URL")"
case $PKG_SOURCE_NAME in
${PKG_NAME}-${PKG_VERSION}.*)
PKG_SOURCE_NAME=$PKG_SOURCE_NAME
;;
*.tar | *.tbz | *.tgz | *.txz | *.7z | *.zip)
PKG_SOURCE_NAME=${PKG_NAME}-${PKG_VERSION}.${PKG_SOURCE_NAME##*\.}
;;
*.tar.bz2 | *.tar.gz | *.tar.xz)
PKG_SOURCE_NAME=${PKG_NAME}-${PKG_VERSION}.tar.${PKG_SOURCE_NAME##*\.}
;;
*.diff | *.patch | *.diff.bz2 | *.patch.bz2 | patch-*.bz2 | *.diff.gz | *.patch.gz | patch-*.gz)
PKG_SOURCE_NAME=$PKG_SOURCE_NAME
;;
*)
PKG_SOURCE_NAME=${PKG_NAME}-${PKG_VERSION}.${PKG_SOURCE_NAME##*\.}
;;
esac
fi
if [ -n "$PKG_GIT_URL" -a -z "$PKG_SOURCE_NAME" ]; then
PKG_SOURCE_NAME=${PKG_NAME}-${PKG_VERSION}.tar.xz
fi
PKG_BUILD="$BUILD/${PKG_NAME}-${PKG_VERSION}"
XORG_PATH_DRI=/usr/lib/dri
XORG_PATH_XKB=/usr/share/X11/xkb
XORG_PATH_XKB_OUTPUT=/var/lib/xkb
XORG_PATH_RGB=/usr/lib/X11/rgb
XORG_PATH_MODULES=/usr/lib/xorg/modules
XORG_PATH_DRIVERS=/usr/lib/xorg/modules/drivers
. config/optimize
if [ -z "$CCACHE_DIR" ]; then
export CCACHE_DIR=$BUILD/.ccache
fi
export MAKEFLAGS=-j$CONCURRENCY_MAKE_LEVEL
export PKG_CONFIG=$TOOLCHAIN/bin/pkg-config
if [[ -z "$PATH" || ( "$PATH" != "$TOOLCHAIN/bin:$TOOLCHAIN/sbin" && "$PATH" = "${PATH#$TOOLCHAIN/bin:$TOOLCHAIN/sbin:}" ) ]]; then
export PATH="$TOOLCHAIN/bin:$TOOLCHAIN/sbin${PATH:+":$PATH"}"
fi
if [[ -z "$LD_LIBRARY_PATH" || ( "$LD_LIBRARY_PATH" != "$TOOLCHAIN/lib" && "$LD_LIBRARY_PATH" = "${LD_LIBRARY_PATH#$TOOLCHAIN/lib:}" ) ]]; then
export LD_LIBRARY_PATH="$TOOLCHAIN/lib${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}"
fi
VERSION_SUFFIX=$TARGET_ARCH
check_path
check_config
SILENT_OUT=3
VERBOSE_OUT=4
if [ "$VERBOSE" = yes ]; then
exec 3>&1
exec 4>&2
else
exec 3>&2
exec 4>/dev/null
fi
BUILD_INDENT_SIZE=4
# define colors
black="\e[0;30m"
boldblack="\e[1;30m"
red="\e[0;31m"
boldred="\e[1;31m"
green="\e[0;32m"
boldgreen="\e[1;32m"
yellow="\e[0;33m"
boldyellow="\e[1;33m"
blue="\e[0;34m"
boldblue="\e[1;34m"
magenta="\e[0;35m"
boldmagenta="\e[1;35m"
cyan="\e[0;36m"
boldcyan="\e[1;36m"
white="\e[0;37m"
boldwhite="\e[1;37m"
endcolor="\e[0m"
# multilib? nah
unset CONFIG_SITE
# meh suse
unset PYTHONSTARTUP
unset PYTHONPATH
You can’t perform that action at this time.