Lakka-LibreELEC/scripts/unpack

176 lines
5.5 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2011-01-09 20:26:03 +00:00
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
2011-01-09 20:26:03 +00:00
#
# OpenELEC is free software: you can redistribute it and/or modify
2011-01-09 20:26:03 +00:00
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
2011-01-09 20:26:03 +00:00
#
# OpenELEC is distributed in the hope that it will be useful,
2011-01-09 20:26:03 +00:00
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2011-01-09 20:26:03 +00:00
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
2011-01-09 20:26:03 +00:00
################################################################################
2009-03-18 12:02:53 +00:00
. config/options $1
2009-03-18 12:02:53 +00:00
if [ -z "$1" ]; then
echo "usage: $0 package_name"
exit 1
fi
if [ ! -f $PKG_DIR/package.mk ]; then
printf "${boldred}$1: no package.mk file found${endcolor}\n"
exit 1
fi
2014-01-27 13:05:34 +00:00
$SCRIPTS/get $1
2016-06-08 07:13:39 +00:00
STAMP=$PKG_BUILD/.libreelec-unpack
2014-01-27 13:05:34 +00:00
2009-03-18 12:02:53 +00:00
mkdir -p $BUILD
[ ! -d "$SOURCES/$1" -a ! -d "$PKG_DIR/sources" ] && exit 0
2009-03-18 12:02:53 +00:00
STAMP_DEPENDS="$PKG_DIR $PKG_NEED_UNPACK $PROJECT_DIR/$PROJECT/patches/$PKG_NAME"
for i in $BUILD/$1-*; do
2016-06-08 07:13:39 +00:00
if [ -d $i -a -f "$i/.libreelec-unpack" ] ; then
. "$i/.libreelec-unpack"
if [ "$STAMP_PKG_NAME" = "$1" ]; then
2015-10-23 10:53:36 +00:00
PKG_DEEPMD5=$(find $STAMP_DEPENDS -exec md5sum {} \; 2>/dev/null | sort | md5sum | cut -d" " -f1)
if [ ! "$PKG_DEEPMD5" = "$STAMP_PKG_DEEPMD5" ] ; then
$SCRIPTS/clean $1
fi
fi
2009-03-18 12:02:53 +00:00
fi
done
if [ -d "$PKG_BUILD" -a ! -f "$STAMP" ]; then
# stale pkg build dir
$SCRIPTS/clean $1
fi
[ -f "$STAMP" ] && exit 0
2009-03-18 12:02:53 +00:00
printf "%${BUILD_INDENT}c ${boldcyan}UNPACK${endcolor} $1\n" ' '>&$SILENT_OUT
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
2009-03-18 12:02:53 +00:00
# unset functions
2015-08-03 12:58:14 +00:00
unset -f pre_unpack
unset -f unpack
unset -f post_unpack
unset -f pre_patch
unset -f post_patch
2009-03-18 12:02:53 +00:00
2015-08-03 12:58:14 +00:00
. $PKG_DIR/package.mk
2015-08-03 12:58:14 +00:00
if [ "$(type -t pre_unpack)" = "function" ]; then
pre_unpack
fi
2015-08-03 12:58:14 +00:00
if [ "$(type -t unpack)" = "function" ]; then
unpack
else
if [ -n "$PKG_URL" ]; then
$SCRIPTS/extract $1 "$1*.tar.bz2" $BUILD
$SCRIPTS/extract $1 "$1*.tbz" $BUILD
$SCRIPTS/extract $1 "$1*.tar.gz" $BUILD
$SCRIPTS/extract $1 "$1*.tar.xz" $BUILD
$SCRIPTS/extract $1 "$1*.txz" $BUILD
$SCRIPTS/extract $1 "$1*.tgz" $BUILD
$SCRIPTS/extract $1 "$1*.7z" $BUILD
$SCRIPTS/extract $1 "$1*.zip" $BUILD
fi
2015-08-03 12:58:14 +00:00
fi
if [ ! -d $BUILD/$PKG_NAME-$PKG_VERSION ]; then
if [ -n "$PKG_SOURCE_DIR" ]; then
mv $BUILD/$PKG_SOURCE_DIR $BUILD/$PKG_NAME-$PKG_VERSION
elif [ -d $BUILD/$PKG_NAME-$PKG_VERSION* ]; then
mv $BUILD/$PKG_NAME-$PKG_VERSION* $BUILD/$PKG_NAME-$PKG_VERSION
fi
2015-08-03 12:58:14 +00:00
fi
2015-08-03 12:58:14 +00:00
if [ -d "$PKG_DIR/sources" ]; then
[ ! -d "$BUILD/${PKG_NAME}-${PKG_VERSION}" ] && mkdir -p $BUILD/${PKG_NAME}-${PKG_VERSION}
cp -PRf $PKG_DIR/sources/* $BUILD/${PKG_NAME}-${PKG_VERSION}
fi
if [ -z "$PKG_URL" ]; then
mkdir -p "${BUILD}/${PKG_NAME}-${PKG_VERSION}"
fi
2015-08-03 12:58:14 +00:00
if [ "$(type -t post_unpack)" = "function" ]; then
post_unpack
fi
if [ "$(type -t pre_patch)" = "function" ]; then
pre_patch
fi
if [ "$TARGET_ARCH" = "x86_64" ]; then
PATCH_ARCH="x86"
else
PATCH_ARCH="$TARGET_ARCH"
fi
for i in $PKG_DIR/patches/$PKG_NAME-*.patch \
$PKG_DIR/patches/$PATCH_ARCH/$PKG_NAME-*.patch \
$PKG_DIR/patches/$PKG_VERSION/*.patch \
$PKG_DIR/patches/$PKG_VERSION/$PATCH_ARCH/*.patch \
2016-03-04 16:27:55 +00:00
$PROJECT_DIR/$PROJECT/patches/$PKG_NAME/*.patch \
$PROJECT_DIR/$PROJECT/patches/$PKG_NAME/$PKG_VERSION/*.patch; \
$PROJECT_DIR/$PROJECT/devices/$DEVICE/patches/$PKG_NAME/*.patch do
if [ $(dirname $i) = "$PKG_DIR/patches" ]; then
PATCH_DESC="(common)"
elif [ $(dirname $i) = "$PKG_DIR/patches/$PATCH_ARCH" ]; then
PATCH_DESC="(common - $PATCH_ARCH)"
elif [ $(dirname $i) = "$PKG_DIR/patches/$PKG_VERSION/$PATCH_ARCH" ]; then
PATCH_DESC="($PKG_VERSION - $PATCH_ARCH)"
elif [ $(dirname $i) = "$PROJECT_DIR/$PROJECT/patches/$PKG_NAME" ]; then
PATCH_DESC="(project)"
elif [ $(dirname $i) = "$PROJECT_DIR/$PROJECT/patches/$PKG_NAME/$PKG_VERSION" ]; then
PATCH_DESC="(project - $PKG_VERSION)"
2009-03-18 12:02:53 +00:00
fi
if [ -f "$i" ]; then
printf "%${BUILD_INDENT}c ${boldgreen}APPLY PATCH${endcolor} ${boldwhite}${PATCH_DESC}${endcolor} $i\n" ' '>&$SILENT_OUT
2015-01-14 23:06:10 +00:00
if [ -n "$(grep -E '^GIT binary patch$' $i)" ]; then
cat $i | git apply --directory=`echo "$PKG_BUILD" | cut -f1 -d\ ` -p1 --verbose --whitespace=nowarn >&$VERBOSE_OUT
else
cat $i | patch -d `echo "$PKG_BUILD" | cut -f1 -d\ ` -p1 >&$VERBOSE_OUT
fi
fi
done
if [ "$(type -t post_patch)" = "function" ]; then
post_patch
fi
for config in `find $BUILD/$1* -name config.guess | sed 's/config.guess//'`; do
if [ ! "$PKG_NAME" == "configtools" ] ; then
printf "%${BUILD_INDENT}c ${boldyellow}FIXCONFIG${endcolor} $config\n" ' '
[ -f "$config/config.guess" -a -f $ROOT/$TOOLCHAIN/configtools/config.guess ] && \
cp -f $ROOT/$TOOLCHAIN/configtools/config.guess $config
[ -f "$config/config.sub" -a -f $ROOT/$TOOLCHAIN/configtools/config.sub ] && \
cp -f $ROOT/$TOOLCHAIN/configtools/config.sub $config
fi
done
rm -f $STAMPS/$1/build_*
2015-10-23 10:53:36 +00:00
PKG_DEEPMD5=$(find $STAMP_DEPENDS -exec md5sum {} \; 2>/dev/null | sort | md5sum | cut -d" " -f1)
for i in PKG_NAME PKG_DEEPMD5; do
eval val=\$$i
echo "STAMP_$i=\"$val\"" >> $STAMP
done