Lakka-LibreELEC/scripts/unpack

125 lines
4.2 KiB
Plaintext
Raw Normal View History

2009-03-18 12:02:53 +00:00
#!/bin/sh
2011-01-09 20:26:03 +00:00
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
2011-01-09 20:26:03 +00:00
#
# This Program 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, or (at your option)
# any later version.
#
# This Program 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.tv; see the file COPYING. If not, write to
# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
2011-01-09 20:26:03 +00:00
# http://www.gnu.org/copyleft/gpl.html
################################################################################
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
$SCRIPTS/get $1
mkdir -p $BUILD
[ ! -d "$SOURCES/$1" -a ! -d "$PKG_DIR/sources" ] && exit 0
2009-03-18 12:02:53 +00:00
mkdir -p $STAMPS/$1
STAMP=$STAMPS/$1/unpack
[ -f "$STAMP" -a -f "$PKG_DIR/need_unpack" ] && $PKG_DIR/need_unpack $@
2009-03-18 12:02:53 +00:00
for patch in $PKG_DIR/patches/*; do
if [ "$patch" -nt "$STAMP" ]; then
2009-03-18 12:02:53 +00:00
rm -f $STAMP
break
fi
done
[ -f "$STAMP" ] && exit 0
2009-03-18 12:02:53 +00:00
printf "%${BUILD_INDENT}c UNPACK $1\n" ' '>&$SILENT_OUT
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
2009-03-18 12:02:53 +00:00
rm -rf $BUILD/$1[-_][0-9]*
rm -rf $BUILD/$1[-_]r[0-9]*
rm -rf $BUILD/$1[-_]cvs*
rm -rf $BUILD/$1[-_]svn*
rm -rf $BUILD/$1[-_]git*
if [ -n "$PKG_URL" ]; then
2009-03-18 12:02:53 +00:00
$SCRIPTS/extract $1 "$1*.tar.bz2" $BUILD
$SCRIPTS/extract $1 "$1*.tbz" $BUILD
2009-03-18 12:02:53 +00:00
$SCRIPTS/extract $1 "$1*.tar.gz" $BUILD
$SCRIPTS/extract $1 "$1*.tar.xz" $BUILD
$SCRIPTS/extract $1 "$1*.txz" $BUILD
2009-03-18 12:02:53 +00:00
$SCRIPTS/extract $1 "$1*.tgz" $BUILD
$SCRIPTS/extract $1 "$1*.7z" $BUILD
2009-03-18 12:02:53 +00:00
fi
[ -f "$PKG_DIR/rename" ] && $PKG_DIR/rename $@ >&$VERBOSE_OUT
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}
2009-03-18 12:02:53 +00:00
fi
[ -d $BUILD/${PKG_NAME}[-_.]${PKG_VERSION} ] && PKG_BUILD=`ls -d $BUILD/${PKG_NAME}[-_.]${PKG_VERSION}`
[ -d $BUILD/${PKG_NAME}${PKG_VERSION} ] && PKG_BUILD=`ls -d $BUILD/${PKG_NAME}${PKG_VERSION}`
[ -d $BUILD/${PKG_NAME} ] && PKG_BUILD=`ls -d $BUILD/${PKG_NAME}`
for i in $PKG_DIR/patches/$PKG_NAME-$PKG_VERSION*.patch ; do
if [ -f "$i" ]; then
2009-03-18 12:02:53 +00:00
PATCH=`basename $i`
PT=`echo $PATCH | sed 's/.*\.\(.*\)$/\1/'`
if [ "$PT" != "patch" -a "$PT" != "$TARGET_ARCH" ]; then
printf "%${BUILD_INDENT}c SKIP PATCH: $i\n" ' '>&$SILENT_OUT
2009-03-18 12:02:53 +00:00
continue;
else
printf "%${BUILD_INDENT}c APPLY PATCH: $i\n" ' '>&$SILENT_OUT
cat $i | patch -d `echo "$PKG_BUILD" | cut -f1 -d\ ` -p1 >&$VERBOSE_OUT
2009-03-18 12:02:53 +00:00
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 SKIP PROJECT PATCH: $i\n" ' '>&$SILENT_OUT
continue;
else
printf "%${BUILD_INDENT}c APPLY PROJECT PATCH: $i\n" ' '>&$SILENT_OUT
cat $i | patch -d `echo "$PKG_BUILD" | cut -f1 -d\ ` -p1 >&$VERBOSE_OUT
fi
fi
done
[ -f "$PKG_DIR/unpack" ] && $PKG_DIR/unpack $@ >&$VERBOSE_OUT
2009-03-18 12:02:53 +00:00
for config in `find $BUILD/$1* -name config.guess | sed 's/config.guess//'`; do
printf "%${BUILD_INDENT}c FIXCONFIG: $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
2009-03-18 12:02:53 +00:00
rm -f $STAMPS/$1/build
for i in `sed -n "s/^\([^#].*\)=\".*$/\1/p" $PROJECT_DIR/$PROJECT/options | grep -v "#"`; do
2009-03-18 12:02:53 +00:00
eval val=\$$i
echo "STAMP_$i=\"$val"\" >> $STAMP
done