2013-07-19 02:35:52 +02:00
|
|
|
#!/bin/bash
|
2011-01-09 23:32:01 +01:00
|
|
|
|
2018-07-16 20:45:36 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
|
2018-11-02 18:02:57 +00:00
|
|
|
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
|
2009-03-18 13:02:53 +01:00
|
|
|
|
2010-07-21 18:54:45 +02:00
|
|
|
. config/options $1
|
2009-03-18 13:02:53 +01:00
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
2018-11-02 18:02:57 +00:00
|
|
|
die "usage: $0 package_name"
|
2009-03-18 13:02:53 +01:00
|
|
|
fi
|
|
|
|
|
|
2014-01-27 03:34:44 +01:00
|
|
|
if [ ! -f $PKG_DIR/package.mk ]; then
|
2018-11-02 18:02:57 +00:00
|
|
|
die "$(print_color CLR_ERROR "$1: no package.mk file found")"
|
2014-01-27 03:34:44 +01:00
|
|
|
fi
|
|
|
|
|
|
2014-01-27 15:05:34 +02:00
|
|
|
$SCRIPTS/get $1
|
|
|
|
|
|
2018-11-02 18:02:57 +00:00
|
|
|
STAMP="$PKG_BUILD/.libreelec-unpack"
|
2014-01-27 15:05:34 +02:00
|
|
|
|
2009-03-18 13:02:53 +01:00
|
|
|
mkdir -p $BUILD
|
|
|
|
|
|
2017-03-23 14:59:46 +00:00
|
|
|
# Perform a wildcard match on the package to ensure old versions are cleaned too
|
2018-04-02 10:09:11 +01:00
|
|
|
PKG_DEEPHASH=
|
2017-03-23 14:33:17 +00:00
|
|
|
for i in $BUILD/$1-*; do
|
|
|
|
|
if [ -d $i -a -f "$i/.libreelec-unpack" ] ; then
|
|
|
|
|
. "$i/.libreelec-unpack"
|
2013-12-12 19:59:28 +02:00
|
|
|
if [ "$STAMP_PKG_NAME" = "$1" ]; then
|
2018-04-02 10:09:11 +01:00
|
|
|
[ -z "${PKG_DEEPHASH}" ] && PKG_DEEPHASH=$(calculate_stamp)
|
|
|
|
|
if [ ! "$PKG_DEEPHASH" = "$STAMP_PKG_DEEPHASH" ] ; then
|
2015-08-02 23:59:29 +03:00
|
|
|
$SCRIPTS/clean $1
|
2013-12-12 19:59:28 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
2009-03-18 13:02:53 +01:00
|
|
|
fi
|
2017-03-23 14:33:17 +00:00
|
|
|
done
|
buildsystem: big rework & cleanup - PART-1: split functions from 'config/path' to an seperate file 'config/functions', rework and cleanup some build scripts, remove references to $TARGET_PLATFORM, add support for more then one downloadurl for $PKG_URL (partially done), remove support for: $PKG_DIR/arch, $PKG_DIR/platform, $PKG_DIR/url files, remove support for *.diff patches, create download-stampfiles in sources/$PKG_NAME, create md5 files after download, add support to download all sources at once with './scripts/get'
Signed-off-by: Stephan Raue <stephan@openelec.tv>
2010-11-19 22:01:08 +01:00
|
|
|
|
2016-09-11 15:33:59 +02:00
|
|
|
if [ -d "$PKG_BUILD" -a ! -f "$STAMP" ]; then
|
|
|
|
|
# stale pkg build dir
|
|
|
|
|
$SCRIPTS/clean $1
|
|
|
|
|
fi
|
|
|
|
|
|
2010-12-18 22:55:20 +01:00
|
|
|
[ -f "$STAMP" ] && exit 0
|
2009-03-18 13:02:53 +01:00
|
|
|
|
2017-02-23 11:42:08 +00:00
|
|
|
if [ -d "$SOURCES/$1" -o -d "$PKG_DIR/sources" ]; then
|
2018-11-18 22:20:06 +00:00
|
|
|
build_msg "CLR_UNPACK" "UNPACK" "${1}" "indent"
|
2009-03-18 13:02:53 +01:00
|
|
|
|
2017-02-23 11:42:08 +00:00
|
|
|
# unset functions
|
|
|
|
|
unset -f pre_unpack
|
|
|
|
|
unset -f unpack
|
|
|
|
|
unset -f post_unpack
|
|
|
|
|
unset -f pre_patch
|
|
|
|
|
unset -f post_patch
|
2014-01-02 13:59:46 +02:00
|
|
|
|
2017-02-23 11:42:08 +00:00
|
|
|
. $PKG_DIR/package.mk
|
2009-03-18 13:02:53 +01:00
|
|
|
|
2018-11-28 15:38:24 +00:00
|
|
|
pkg_call_optional pre_unpack
|
2014-01-02 14:12:03 +01:00
|
|
|
|
2018-11-28 15:38:24 +00:00
|
|
|
if ! pkg_call unpack; then
|
2017-02-23 11:42:08 +00:00
|
|
|
if [ -n "$PKG_URL" ]; then
|
2017-09-14 06:51:41 +01:00
|
|
|
$SCRIPTS/extract $1 $BUILD
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
2016-03-29 22:51:55 +01:00
|
|
|
fi
|
2014-01-02 14:12:03 +01:00
|
|
|
|
2018-11-02 18:02:57 +00:00
|
|
|
if [ ! -d "$PKG_BUILD" ]; then
|
2017-02-23 11:42:08 +00:00
|
|
|
if [ -n "$PKG_SOURCE_DIR" ]; then
|
2018-11-02 18:02:57 +00:00
|
|
|
mv $BUILD/$PKG_SOURCE_DIR "$PKG_BUILD"
|
|
|
|
|
elif [ -d "$PKG_BUILD"* ]; then
|
|
|
|
|
mv "$PKG_BUILD"* "$PKG_BUILD"
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
|
|
|
|
fi
|
2015-08-03 15:58:14 +03:00
|
|
|
|
2017-02-23 11:42:08 +00:00
|
|
|
if [ -d "$PKG_DIR/sources" ]; then
|
2018-11-02 18:02:57 +00:00
|
|
|
[ ! -d "$PKG_BUILD" ] && mkdir -p "$PKG_BUILD"
|
|
|
|
|
cp -PRf "$PKG_DIR/sources/"* "$PKG_BUILD"
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
2016-02-22 14:12:07 +01:00
|
|
|
|
2017-02-23 11:42:08 +00:00
|
|
|
if [ -z "$PKG_URL" ]; then
|
2018-11-02 18:02:57 +00:00
|
|
|
mkdir -p "${PKG_BUILD}"
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
2014-01-02 14:12:03 +01:00
|
|
|
|
2018-11-28 15:38:24 +00:00
|
|
|
pkg_call_optional post_unpack
|
2014-01-05 20:14:45 +02:00
|
|
|
|
2018-02-25 11:39:58 +00:00
|
|
|
if [ "${PKG_SKIP_PATCHES}" != "yes" ]; then
|
2018-11-28 15:38:24 +00:00
|
|
|
pkg_call_optional pre_patch
|
2014-05-24 16:22:33 +02:00
|
|
|
|
2018-02-25 11:39:58 +00:00
|
|
|
if [ "$TARGET_ARCH" = "x86_64" ]; then
|
|
|
|
|
PATCH_ARCH="x86"
|
2017-02-23 11:42:08 +00:00
|
|
|
else
|
2018-02-25 11:39:58 +00:00
|
|
|
PATCH_ARCH="${TARGET_PATCH_ARCH:-$TARGET_ARCH}"
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
|
|
|
|
|
2018-02-25 11:39:58 +00:00
|
|
|
PATCH_DIRS_PKG=""
|
|
|
|
|
PATCH_DIRS_PRJ=""
|
|
|
|
|
if [ -n "$PKG_PATCH_DIRS" ]; then
|
|
|
|
|
for patch_dir in $PKG_PATCH_DIRS; do
|
|
|
|
|
[ -d $PKG_DIR/patches/$patch_dir ] && PATCH_DIRS_PKG="$PATCH_DIRS_PKG $PKG_DIR/patches/$patch_dir/*.patch"
|
|
|
|
|
[ -d $PROJECT_DIR/$PROJECT/patches/$PKG_NAME/$patch_dir ] && PATCH_DIRS_PRJ="$PATCH_DIRS_PRJ $PROJECT_DIR/$PROJECT/patches/$PKG_NAME/$patch_dir/*.patch"
|
|
|
|
|
[ -d $PROJECT_DIR/$PROJECT/devices/$DEVICE/patches/$PKG_NAME/$patch_dir ] && PATCH_DIRS_PRJ="$PATCH_DIRS_PRJ $PROJECT_DIR/$PROJECT/devices/$DEVICE/patches/$PKG_NAME/$patch_dir/*.patch"
|
|
|
|
|
done
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
|
|
|
|
|
2018-02-25 11:39:58 +00:00
|
|
|
for i in $PKG_DIR/patches/*.patch \
|
|
|
|
|
$PKG_DIR/patches/$PATCH_ARCH/*.patch \
|
|
|
|
|
$PATCH_DIRS_PKG \
|
|
|
|
|
$PKG_DIR/patches/$PKG_VERSION/*.patch \
|
|
|
|
|
$PKG_DIR/patches/$PKG_VERSION/$PATCH_ARCH/*.patch \
|
|
|
|
|
$PROJECT_DIR/$PROJECT/patches/$PKG_NAME/*.patch \
|
|
|
|
|
$PROJECT_DIR/$PROJECT/patches/$PKG_NAME/$PATCH_ARCH/*.patch \
|
|
|
|
|
$PATCH_DIRS_PRJ \
|
|
|
|
|
$PROJECT_DIR/$PROJECT/patches/$PKG_NAME/$PKG_VERSION/*.patch \
|
|
|
|
|
$PROJECT_DIR/$PROJECT/devices/$DEVICE/patches/$PKG_NAME/*.patch; do
|
|
|
|
|
|
|
|
|
|
thisdir="$(dirname "$i")"
|
|
|
|
|
|
|
|
|
|
if [ "$thisdir" = "$PKG_DIR/patches" ]; then
|
|
|
|
|
PATCH_DESC="(common)"
|
|
|
|
|
elif [ "$thisdir" = "$PKG_DIR/patches/$PATCH_ARCH" ]; then
|
|
|
|
|
PATCH_DESC="(common - $PATCH_ARCH)"
|
|
|
|
|
elif [ "$thisdir" = "$PKG_DIR/patches/$PKG_VERSION" ]; then
|
|
|
|
|
PATCH_DESC="(common - $PKG_VERSION)"
|
|
|
|
|
elif [ "$thisdir" = "$PKG_DIR/patches/$PKG_VERSION/$PATCH_ARCH" ]; then
|
|
|
|
|
PATCH_DESC="($PKG_VERSION - $PATCH_ARCH)"
|
|
|
|
|
elif [ "$thisdir" = "$PROJECT_DIR/$PROJECT/patches/$PKG_NAME" ]; then
|
|
|
|
|
PATCH_DESC="(project)"
|
|
|
|
|
elif [ "$thisdir" = "$PROJECT_DIR/$PROJECT/patches/$PKG_NAME/$PATCH_ARCH" ]; then
|
|
|
|
|
PATCH_DESC="(project - $PATCH_ARCH)"
|
|
|
|
|
elif [ "$thisdir" = "$PROJECT_DIR/$PROJECT/patches/$PKG_NAME/$PKG_VERSION" ]; then
|
|
|
|
|
PATCH_DESC="(project - $PKG_VERSION)"
|
|
|
|
|
elif [ "$thisdir" = "$PROJECT_DIR/$PROJECT/devices/$DEVICE/patches/$PKG_NAME" ]; then
|
|
|
|
|
PATCH_DESC="(device)"
|
|
|
|
|
else
|
|
|
|
|
if [[ "$thisdir" =~ ^$PKG_DIR/.* ]]; then
|
|
|
|
|
PATCH_DESC="(common - $(basename "$thisdir"))"
|
|
|
|
|
elif [[ "$thisdir" =~ ^$PROJECT_DIR/.*/devices/.* ]]; then
|
|
|
|
|
PATCH_DESC="(device - $(basename "$thisdir"))"
|
|
|
|
|
elif [[ "$thisdir" =~ ^$PROJECT_DIR/.* ]]; then
|
|
|
|
|
PATCH_DESC="(project - $(basename "$thisdir"))"
|
|
|
|
|
else
|
|
|
|
|
PATCH_DESC="(unknown - $(basename "$thisdir"))"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f "$i" ]; then
|
2018-11-18 22:20:06 +00:00
|
|
|
build_msg "CLR_APPLY_PATCH" "APPLY PATCH $(print_color "CLR_PATCH_DESC" "${PATCH_DESC}")" "${i#${ROOT}/}"
|
2018-02-25 11:39:58 +00:00
|
|
|
if grep -qE '^GIT binary patch$|^rename from|^rename to' $i; then
|
2018-11-02 18:02:57 +00:00
|
|
|
cat $i | git apply --directory=$(echo "$PKG_BUILD" | cut -f1 -d\ ) -p1 --verbose --whitespace=nowarn --unsafe-paths >&$VERBOSE_OUT
|
2018-02-25 11:39:58 +00:00
|
|
|
else
|
2018-11-02 18:02:57 +00:00
|
|
|
cat $i | patch -d $(echo "$PKG_BUILD" | cut -f1 -d\ ) -p1 >&$VERBOSE_OUT
|
2018-02-25 11:39:58 +00:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2018-11-28 15:38:24 +00:00
|
|
|
pkg_call_optional post_patch
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
|
|
|
|
|
2018-04-02 10:09:11 +01:00
|
|
|
if [ ! "$PKG_NAME" = "configtools" ] ; then
|
2018-11-02 18:02:57 +00:00
|
|
|
for config in $(find "$PKG_BUILD" -name config.guess | sed 's/config.guess//'); do
|
2018-11-18 22:20:06 +00:00
|
|
|
build_msg "CLR_FIXCONFIG" "FIXCONFIG" "${config}"
|
2017-02-23 11:42:08 +00:00
|
|
|
|
|
|
|
|
[ -f "$config/config.guess" -a -f $TOOLCHAIN/configtools/config.guess ] && \
|
|
|
|
|
cp -f $TOOLCHAIN/configtools/config.guess $config
|
|
|
|
|
[ -f "$config/config.sub" -a -f $TOOLCHAIN/configtools/config.sub ] && \
|
|
|
|
|
cp -f $TOOLCHAIN/configtools/config.sub $config
|
2017-02-23 11:42:08 +00:00
|
|
|
done
|
|
|
|
|
fi
|
2016-12-06 18:25:25 +00:00
|
|
|
fi
|
|
|
|
|
|
2017-02-23 11:42:08 +00:00
|
|
|
if [ "$PKG_SECTION" != "virtual" ]; then
|
2018-11-02 18:02:57 +00:00
|
|
|
mkdir -p "$PKG_BUILD"
|
2013-01-17 12:40:01 +01:00
|
|
|
|
2017-02-23 11:42:08 +00:00
|
|
|
rm -f $STAMPS/$1/build_*
|
2016-12-06 18:25:25 +00:00
|
|
|
|
2018-04-02 10:09:11 +01:00
|
|
|
PKG_DEEPHASH=$(calculate_stamp)
|
|
|
|
|
for i in PKG_NAME PKG_DEEPHASH; do
|
2017-02-23 11:42:08 +00:00
|
|
|
echo "STAMP_$i=\"${!i}\"" >> $STAMP
|
2017-02-23 11:42:08 +00:00
|
|
|
done
|
2013-12-21 07:53:41 +01:00
|
|
|
fi
|