Files
Arch-R/scripts/extract

79 lines
2.3 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2011-01-09 21:26:03 +01:00
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
2011-01-09 21:26:03 +01:00
#
# OpenELEC is free software: you can redistribute it and/or modify
2011-01-09 21:26:03 +01: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 21:26:03 +01:00
#
# OpenELEC is distributed in the hope that it will be useful,
2011-01-09 21:26:03 +01:00
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2011-01-09 21:26:03 +01: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 21:26:03 +01:00
################################################################################
2009-03-18 13:02:53 +01:00
. config/options $1
2009-03-18 13:02:53 +01:00
if [ -z "$2" ]; then
echo "usage: $0 package_name target_dir"
2009-03-18 13:02:53 +01:00
exit 1
fi
[ -z "$PKG_URL" -o -z "$PKG_SOURCE_NAME" ] && exit 1
[ ! -d "$SOURCES/$1" -o ! -d "$2" ] && exit 1
2009-03-18 13:02:53 +01:00
if [[ ${PKG_URL} =~ ^file:// ]]; then
FULL_SOURCE_PATH="$PKG_SOURCE_NAME"
else
FULL_SOURCE_PATH="$SOURCES/$1/$PKG_SOURCE_NAME"
fi
if [ ! -f "$FULL_SOURCE_PATH" -a ! -d "$FULL_SOURCE_PATH" ]; then
echo "error: File $PKG_SOURCE_NAME doesn't exist for package $1"
echo "Have you called scripts/extract before scripts/get ?"
exit 1
fi
case $PKG_SOURCE_NAME in
*.tar)
tar xf $FULL_SOURCE_PATH -C $2
;;
*.tar.bz2 | *.tbz)
tar xjf $FULL_SOURCE_PATH -C $2
;;
*.tar.gz | *.tgz)
tar xzf $FULL_SOURCE_PATH -C $2
;;
*.tar.xz | *.txz)
tar xJf $FULL_SOURCE_PATH -C $2
;;
*.7z)
mkdir -p $2/$1
7z x -o$2/$1 $FULL_SOURCE_PATH
;;
*.zip)
unzip -q $FULL_SOURCE_PATH -d $2
;;
*.diff | *.patch)
cat $FULL_SOURCE_PATH | patch -d $2 -p1
;;
*.diff.bz2 | *.patch.bz2 | patch-*.bz2)
bzcat $FULL_SOURCE_PATH | patch -d $2 -p1
;;
*.diff.gz | *.patch.gz | patch-*.gz)
zcat $FULL_SOURCE_PATH | patch -d $2 -p1
;;
*)
FULL_DEST_PATH="$2/$PKG_NAME-$PKG_VERSION"
mkdir $FULL_DEST_PATH
tar cf - -C $FULL_SOURCE_PATH $PKG_TAR_COPY_OPTS . | \
tar xf - -C $FULL_DEST_PATH
;;
esac