mirror of
https://github.com/libretro/Lakka-LibreELEC.git
synced 2024-11-24 17:00:02 +00:00
f60ec98c4d
Signed-off-by: Stephan Raue <stephan@openelec.tv>
221 lines
7.2 KiB
Bash
Executable File
221 lines
7.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
################################################################################
|
|
# This file is part of OpenELEC - http://www.openelec.tv
|
|
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
|
#
|
|
# OpenELEC is free software: you can redistribute it and/or modify
|
|
# 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.
|
|
#
|
|
# OpenELEC is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# 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/>.
|
|
################################################################################
|
|
|
|
. config/options $1
|
|
|
|
if [ -z "$1" ]; then
|
|
echo "usage: $0 package_name"
|
|
exit 1
|
|
fi
|
|
|
|
$SCRIPTS/get $1
|
|
|
|
STAMP=$PKG_BUILD/.openelec-unpack
|
|
|
|
mkdir -p $BUILD
|
|
|
|
[ ! -d "$SOURCES/$1" -a ! -d "$PKG_DIR/sources" ] && exit 0
|
|
|
|
for i in $BUILD/$1-*; do
|
|
if [ -d $i -a -f "$i/.openelec-unpack" ] ; then
|
|
. "$i/.openelec-unpack"
|
|
if [ "$STAMP_PKG_NAME" = "$1" ]; then
|
|
# trigger unpack / full rebuild on any package.mk change
|
|
if [ -f $PKG_DIR/package.mk -a $PKG_DIR/package.mk -nt "$i/.openelec-unpack" ]; then
|
|
CLEAN_SOURCE=yes
|
|
break
|
|
# TODO: remove after converting ALL packages
|
|
elif [ -f $PKG_DIR/meta -a $PKG_DIR/meta -nt "$i/.openelec-unpack" ]; then
|
|
CLEAN_SOURCE=yes
|
|
break
|
|
fi
|
|
# handle $PKG_NEED_UNPACK
|
|
for file in $PKG_NEED_UNPACK; do
|
|
if [ -f "$file" -a "$file" -nt "$i/.openelec-unpack" ] ; then
|
|
CLEAN_SOURCE=yes
|
|
break
|
|
fi
|
|
done
|
|
# trigger unpack / full rebuild on any patch / script / etc.. change
|
|
# TODO: rewwork $PKG_DIR/scripts -> $PKG_DIR/filesystem/....
|
|
for file in $PKG_DIR/{patches,patches.upstream,scripts}/* ; do
|
|
if [ -f "$file" -a "$file" -nt "$i/.openelec-unpack" ]; then
|
|
CLEAN_SOURCE=yes
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
fi
|
|
done
|
|
|
|
if [ "$CLEAN_SOURCE" = "yes" ]; then
|
|
$SCRIPTS/clean $1
|
|
fi
|
|
|
|
[ -f "$STAMP" ] && exit 0
|
|
|
|
printf "%${BUILD_INDENT}c ${boldcyan}UNPACK${endcolor} $1\n" ' '>&$SILENT_OUT
|
|
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
|
|
|
|
if [ -f $PKG_DIR/package.mk ]; then
|
|
# unset functions
|
|
unset -f pre_unpack
|
|
unset -f unpack
|
|
unset -f post_unpack
|
|
|
|
. $PKG_DIR/package.mk
|
|
|
|
if [ "$(type -t pre_unpack)" = "function" ]; then
|
|
pre_unpack
|
|
fi
|
|
|
|
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
|
|
fi
|
|
|
|
if [ -n "$PKG_SOURCE_DIR" ]; then
|
|
mv $BUILD/$PKG_SOURCE_DIR $BUILD/$PKG_NAME-$PKG_VERSION
|
|
fi
|
|
|
|
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
|
|
else # todo: deprecated
|
|
if [ -f "$PKG_DIR/unpack" ]; then
|
|
$PKG_DIR/unpack $@ >&$VERBOSE_OUT
|
|
fi
|
|
|
|
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
|
|
|
|
if [ -n "$PKG_SOURCE_DIR" ]; then
|
|
mv $BUILD/$PKG_SOURCE_DIR $BUILD/$PKG_NAME-$PKG_VERSION
|
|
fi
|
|
|
|
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
|
|
fi
|
|
|
|
for i in $PKG_DIR/patches/$PKG_NAME-*.patch ; do
|
|
if [ -f "$i" ]; then
|
|
PATCH=`basename $i`
|
|
PT=`echo $PATCH | sed 's/.*\.\(.*\)$/\1/'`
|
|
if [ "$PT" != "patch" -a "$PT" != "$TARGET_ARCH" ]; then
|
|
printf "%${BUILD_INDENT}c ${boldyellow}SKIP PATCH${endcolor} ${boldwhite}(common)${endcolor} $i\n" ' '>&$SILENT_OUT
|
|
continue;
|
|
else
|
|
printf "%${BUILD_INDENT}c ${boldgreen}APPLY PATCH${endcolor} ${boldwhite}(common)${endcolor} $i\n" ' '>&$SILENT_OUT
|
|
apply_patch $i $PKG_BUILD || exit 1
|
|
fi
|
|
fi
|
|
done
|
|
|
|
for i in $PKG_DIR/patches/$PKG_VERSION/*.patch ; do
|
|
if [ -f "$i" ]; then
|
|
PATCH=`basename $i`
|
|
PT=`echo $PATCH | sed 's/.*\.\(.*\)$/\1/'`
|
|
if [ "$PT" != "patch" -a "$PT" != "$TARGET_ARCH" ]; then
|
|
printf "%${BUILD_INDENT}c ${boldyellow}SKIP PATCH${endcolor} ${boldwhite}($PKG_VERSION)${endcolor} $i\n" ' '>&$SILENT_OUT
|
|
continue;
|
|
else
|
|
printf "%${BUILD_INDENT}c ${boldgreen}APPLY PATCH${endcolor} ${boldwhite}($PKG_VERSION)${endcolor} $i\n" ' '>&$SILENT_OUT
|
|
apply_patch $i $PKG_BUILD || exit 1
|
|
fi
|
|
fi
|
|
done
|
|
|
|
for i in $PROJECT_DIR/$PROJECT/patches/$PKG_NAME/*.patch ; do
|
|
if [ -f "$i" ]; then
|
|
PATCH=`basename $i`
|
|
PT=`echo $PATCH | sed 's/.*\.\(.*\)$/\1/'`
|
|
if [ "$PT" != "patch" -a "$PT" != "$TARGET_ARCH" ]; then
|
|
printf "%${BUILD_INDENT}c ${boldyellow}SKIP PATCH${endcolor} ${boldwhite}(project)${endcolor} $i\n" ' '>&$SILENT_OUT
|
|
continue;
|
|
else
|
|
printf "%${BUILD_INDENT}c ${boldgreen}APPLY PATCH${endcolor} ${boldwhite}(project)${endcolor} $i\n" ' '>&$SILENT_OUT
|
|
apply_patch $i $PKG_BUILD || exit 1
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# post_unpack() :
|
|
# - Formerly used to replace $PKG_DIR/rename
|
|
# - now replaced by $PKG_SOURCE_DIR .
|
|
# - now moved after patching to replace the formerly 'unpack' script
|
|
if [ -f $PKG_DIR/package.mk ]; then
|
|
if [ "$(type -t post_unpack)" = "function" ]; then
|
|
post_unpack
|
|
fi
|
|
fi
|
|
|
|
for config in `find $BUILD/$1* -name config.guess | sed 's/config.guess//'`; do
|
|
printf "%${BUILD_INDENT}c ${boldyellow}FIXCONFIG${endcolor} $config\n" ' '>&$SILENT_OUT
|
|
|
|
[ -f "$config/config.guess" ] && cp -f $SCRIPTS/configtools/config.guess $config
|
|
[ -f "$config/config.sub" ] && cp -f $SCRIPTS/configtools/config.sub $config
|
|
[ -f "$config/configure.guess" ] && cp -f $SCRIPTS/configtools/config.guess $config/configure.guess
|
|
[ -f "$config/configure.sub" ] && cp -f $SCRIPTS/configtools/config.sub $config/configure.sub
|
|
done
|
|
|
|
rm -f $STAMPS/$1/build_*
|
|
|
|
if [ -f "$PKG_DIR/package.mk" ]; then
|
|
for i in PKG_NAME PKG_VERSION PKG_REV PKG_SHORTDESC PKG_LONGDESC PKG_SITE PKG_URL PKG_SECTION; do
|
|
eval val=\$$i
|
|
echo "STAMP_$i=\"$val"\" >> $STAMP
|
|
done
|
|
elif [ -f "$PKG_DIR/meta" ]; then
|
|
# Deprecated
|
|
. $PKG_DIR/meta
|
|
|
|
for i in PKG_NAME PKG_VERSION PKG_REV PKG_SHORTDESC PKG_LONGDESC PKG_SITE PKG_URL PKG_SECTION; do
|
|
eval val=\$$i
|
|
echo "STAMP_$i=\"$val"\" >> $STAMP
|
|
done
|
|
else
|
|
# Deprecated
|
|
for i in `sed -n "s/^\([^#].*\)=\".*$/\1/p" $PROJECT_DIR/$PROJECT/options | grep -v "#"`; do
|
|
eval val=\$$i
|
|
echo "STAMP_$i=\"$val"\" >> $STAMP
|
|
done
|
|
fi
|