mirror of
https://github.com/LibreELEC/LibreELEC.tv
synced 2025-09-24 19:46:01 +07:00
also add support for custom tar opt, eg to exclude files or directories when copying This can be set eg with PKG_TAR_COPY_OPTS="--exclude=.git"
79 lines
2.3 KiB
Bash
Executable File
79 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
################################################################################
|
|
# This file is part of OpenELEC - http://www.openelec.tv
|
|
# Copyright (C) 2009-2016 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 "$2" ]; then
|
|
echo "usage: $0 package_name target_dir"
|
|
exit 1
|
|
fi
|
|
|
|
[ -z "$PKG_URL" -o -z "$PKG_SOURCE_NAME" ] && exit 1
|
|
[ ! -d "$SOURCES/$1" -o ! -d "$2" ] && exit 1
|
|
|
|
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
|