Lakka-LibreELEC/scripts/extract

74 lines
2.1 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 "$3" ]; then
echo "usage: $0 package_name file_pattern target_dir"
exit 1
fi
[ -z "$PKG_URL" -o -z "$PKG_SOURCE_NAME" ] && exit 1
[ ! -d "$SOURCES/$1" -o ! -d "$3" ] && exit 1
2009-03-18 12:02:53 +00:00
case $PKG_SOURCE_NAME in
2009-03-18 12:02:53 +00:00
$2)
f="$SOURCES/$1/$PKG_SOURCE_NAME"
2009-03-18 12:02:53 +00:00
if [ ! -f $f ]; then
echo "error: File $PKG_SOURCE_NAME doesn't exists in package $1 sources directory"
2009-03-18 12:02:53 +00:00
echo "have you called scripts/extract before scripts/get ?"
exit 1
fi
case $PKG_SOURCE_NAME in
2009-03-18 12:02:53 +00:00
*.tar)
tar xf $f -C $3
;;
*.tar.bz2 | *.tbz)
tar xjf $f -C $3
;;
*.tar.gz | *.tgz)
tar xzf $f -C $3
;;
*.tar.xz | *.txz)
tar xJf $f -C $3
;;
*.7z)
mkdir -p $3/$1
7z x -o$3/$1 $f
;;
*.zip)
unzip -q $f -d $3
;;
2009-03-18 12:02:53 +00:00
*.diff | *.patch)
cat $f | patch -d $3 -p1
;;
*.diff.bz2 | *.patch.bz2 | patch-*.bz2)
bzcat $f | patch -d $3 -p1
;;
*.diff.gz | *.patch.gz | patch-*.gz)
zcat $f | patch -d $3 -p1
;;
*)
cp -pPR $f $3
;;
esac
;;
esac