mirror of
https://github.com/libretro/Lakka-LibreELEC.git
synced 2024-11-30 12:00:41 +00:00
addons: provide install_addon script
This commit is contained in:
parent
4d28b80e71
commit
8896e1a283
@ -44,84 +44,12 @@ fi
|
||||
|
||||
|
||||
pack_addon() {
|
||||
IFS=" "
|
||||
for i in $PKG_ADDON_REQUIRES; do
|
||||
REQUIRES_ADDONNAME=`echo $i | cut -f1 -d ":"`
|
||||
REQUIRES_ADDONVERSION=`echo $i | cut -f2 -d ":"`
|
||||
REQUIRES="$REQUIRES\n <import addon=\"$REQUIRES_ADDONNAME\" version=\"$REQUIRES_ADDONVERSION\" />"
|
||||
done
|
||||
|
||||
unset IFS
|
||||
|
||||
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID
|
||||
|
||||
if [ ! -f $ADDON_BUILD/$PKG_ADDON_ID/addon.xml ]; then
|
||||
cp config/addon/${PKG_ADDON_TYPE}.xml $ADDON_BUILD/$PKG_ADDON_ID/addon.xml
|
||||
ADDONVER=$ADDON_VERSION.$PKG_REV
|
||||
else
|
||||
if [ ! $(which xmlstarlet) ]; then
|
||||
echo "*** ERROR: $ADDON has addon.xml shipped, you need 'xmlstarlet' ***"
|
||||
exit 255
|
||||
fi
|
||||
ADDONVER="$(xmlstarlet sel -t -v "/addon/@version" $ADDON_BUILD/$PKG_ADDON_ID/addon.xml).$PKG_REV"
|
||||
xmlstarlet ed --inplace -u "/addon[@version]/@version" -v "$ADDONVER" $ADDON_BUILD/$PKG_ADDON_ID/addon.xml
|
||||
fi
|
||||
|
||||
if [ -d $PKG_DIR/source ]; then
|
||||
cp -R $PKG_DIR/source/* $ADDON_BUILD/$PKG_ADDON_ID
|
||||
fi
|
||||
|
||||
if [ -f $PKG_DIR/icon/icon.png ]; then
|
||||
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/resources
|
||||
cp $PKG_DIR/icon/icon.png $ADDON_BUILD/$PKG_ADDON_ID/resources
|
||||
fi
|
||||
|
||||
if [ -f $DISTRO_DIR/$DISTRO/addons/fanart.png ]; then
|
||||
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/resources
|
||||
cp $DISTRO_DIR/$DISTRO/addons/fanart.png $ADDON_BUILD/$PKG_ADDON_ID/resources
|
||||
fi
|
||||
|
||||
for f in $PKG_DIR/source/resources/screenshot-*.{jpg,png}; do
|
||||
if [ -f "$f" ]; then
|
||||
PKG_ADDON_SCREENSHOT+="<screenshot>resources/$(basename $f)</screenshot>\n"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -f $PKG_DIR/changelog.txt ]; then
|
||||
sed -e "/@PKG_ADDON_NEWS@/ \
|
||||
{
|
||||
r $PKG_DIR/changelog.txt
|
||||
d
|
||||
}" -i $ADDON_BUILD/$PKG_ADDON_ID/addon.xml
|
||||
else
|
||||
sed -e "s|@PKG_ADDON_NEWS@||g" -i $ADDON_BUILD/$PKG_ADDON_ID/addon.xml
|
||||
fi
|
||||
|
||||
PROVIDER_NAME="libreelec.tv"
|
||||
if [ ! -z "$PKG_MAINTAINER" ] ; then
|
||||
PROVIDER_NAME="$PKG_MAINTAINER"
|
||||
fi
|
||||
ADDON_NAME="$PKG_NAME"
|
||||
if [ ! -z "$PKG_ADDON_NAME" ] ; then
|
||||
ADDON_NAME="$PKG_ADDON_NAME"
|
||||
fi
|
||||
$SED -e "s|@PKG_ADDON_ID@|$PKG_ADDON_ID|g" \
|
||||
-e "s|@ADDON_NAME@|$ADDON_NAME|g" \
|
||||
-e "s|@ADDON_VERSION@|$ADDON_VERSION.$PKG_REV|g" \
|
||||
-e "s|@REQUIRES@|$REQUIRES|g" \
|
||||
-e "s|@PKG_SHORTDESC@|$PKG_SHORTDESC|g" \
|
||||
-e "s|@OS_VERSION@|$OS_VERSION|g" \
|
||||
-e "s|@PKG_LONGDESC@|$PKG_LONGDESC|g" \
|
||||
-e "s|@PKG_DISCLAIMER@|$PKG_DISCLAIMER|g" \
|
||||
-e "s|@PROVIDER_NAME@|$PROVIDER_NAME|g" \
|
||||
-e "s|@PKG_ADDON_PROVIDES@|$PKG_ADDON_PROVIDES|g" \
|
||||
-e "s|@PKG_ADDON_SCREENSHOT@|$PKG_ADDON_SCREENSHOT|g" \
|
||||
-i $ADDON_BUILD/$PKG_ADDON_ID/addon.xml
|
||||
|
||||
debug_strip $ADDON_BUILD/$PKG_ADDON_ID
|
||||
scripts/install_addon $PKG_NAME $PKG_ADDON_ID || exit
|
||||
|
||||
if [ "$2" != "-test" ] ; then
|
||||
ADDON_INSTALL_DIR="$TARGET/$ADDONS/$ADDON_VERSION/${DEVICE:-$PROJECT}/$TARGET_ARCH/$PKG_ADDON_ID"
|
||||
ADDONVER="$(xmlstarlet sel -t -v "/addon/@version" $ADDON_BUILD/$PKG_ADDON_ID/addon.xml)"
|
||||
|
||||
if [ -f $ADDON_INSTALL_DIR/$PKG_ADDON_ID-$ADDONVER.zip ] ; then
|
||||
echo "*** WARNING: $PKG_ADDON_ID-$ADDONVER.zip already exists. not overwriting it ***"
|
||||
return 0
|
||||
|
99
scripts/install_addon
Executable file
99
scripts/install_addon
Executable file
@ -0,0 +1,99 @@
|
||||
#!/bin/bash
|
||||
|
||||
################################################################################
|
||||
# This file is part of LibreELEC - https://www.libreelec.tv
|
||||
# Copyright (C) 2017-present Team LibreELEC
|
||||
#
|
||||
# LibreELEC 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.
|
||||
#
|
||||
# LibreELEC 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 LibreELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||
################################################################################
|
||||
|
||||
. config/options $1
|
||||
|
||||
[ -n "$2" ] && PKG_ADDON_ID=$2
|
||||
|
||||
IFS=" "
|
||||
for i in $PKG_ADDON_REQUIRES; do
|
||||
REQUIRES_ADDONNAME=`echo $i | cut -f1 -d ":"`
|
||||
REQUIRES_ADDONVERSION=`echo $i | cut -f2 -d ":"`
|
||||
REQUIRES="$REQUIRES\n <import addon=\"$REQUIRES_ADDONNAME\" version=\"$REQUIRES_ADDONVERSION\" />"
|
||||
done
|
||||
|
||||
unset IFS
|
||||
|
||||
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID
|
||||
|
||||
if [ ! -f $ADDON_BUILD/$PKG_ADDON_ID/addon.xml ]; then
|
||||
cp config/addon/${PKG_ADDON_TYPE}.xml $ADDON_BUILD/$PKG_ADDON_ID/addon.xml
|
||||
ADDONVER=$ADDON_VERSION.$PKG_REV
|
||||
else
|
||||
if [ ! $(which xmlstarlet) ]; then
|
||||
echo "*** ERROR: $ADDON has addon.xml shipped, you need 'xmlstarlet' ***"
|
||||
exit 255
|
||||
fi
|
||||
ADDONVER="$(xmlstarlet sel -t -v "/addon/@version" $ADDON_BUILD/$PKG_ADDON_ID/addon.xml).$PKG_REV"
|
||||
xmlstarlet ed --inplace -u "/addon[@version]/@version" -v "$ADDONVER" $ADDON_BUILD/$PKG_ADDON_ID/addon.xml
|
||||
fi
|
||||
|
||||
if [ -d $PKG_DIR/source ]; then
|
||||
cp -R $PKG_DIR/source/* $ADDON_BUILD/$PKG_ADDON_ID
|
||||
fi
|
||||
|
||||
if [ -f $PKG_DIR/icon/icon.png ]; then
|
||||
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/resources
|
||||
cp $PKG_DIR/icon/icon.png $ADDON_BUILD/$PKG_ADDON_ID/resources
|
||||
fi
|
||||
|
||||
if [ -f $DISTRO_DIR/$DISTRO/addons/fanart.png ]; then
|
||||
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/resources
|
||||
cp $DISTRO_DIR/$DISTRO/addons/fanart.png $ADDON_BUILD/$PKG_ADDON_ID/resources
|
||||
fi
|
||||
|
||||
for f in $PKG_DIR/source/resources/screenshot-*.{jpg,png}; do
|
||||
if [ -f "$f" ]; then
|
||||
PKG_ADDON_SCREENSHOT+="<screenshot>resources/$(basename $f)</screenshot>\n"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -f $PKG_DIR/changelog.txt ]; then
|
||||
sed -e "/@PKG_ADDON_NEWS@/ \
|
||||
{
|
||||
r $PKG_DIR/changelog.txt
|
||||
d
|
||||
}" -i $ADDON_BUILD/$PKG_ADDON_ID/addon.xml
|
||||
else
|
||||
sed -e "s|@PKG_ADDON_NEWS@||g" -i $ADDON_BUILD/$PKG_ADDON_ID/addon.xml
|
||||
fi
|
||||
|
||||
PROVIDER_NAME="Team LibreELEC"
|
||||
if [ ! -z "$PKG_MAINTAINER" ] ; then
|
||||
PROVIDER_NAME="$PKG_MAINTAINER"
|
||||
fi
|
||||
ADDON_NAME="$PKG_NAME"
|
||||
if [ ! -z "$PKG_ADDON_NAME" ] ; then
|
||||
ADDON_NAME="$PKG_ADDON_NAME"
|
||||
fi
|
||||
$SED -e "s|@PKG_ADDON_ID@|$PKG_ADDON_ID|g" \
|
||||
-e "s|@ADDON_NAME@|$ADDON_NAME|g" \
|
||||
-e "s|@ADDON_VERSION@|$ADDON_VERSION.$PKG_REV|g" \
|
||||
-e "s|@REQUIRES@|$REQUIRES|g" \
|
||||
-e "s|@PKG_SHORTDESC@|$PKG_SHORTDESC|g" \
|
||||
-e "s|@OS_VERSION@|$OS_VERSION|g" \
|
||||
-e "s|@PKG_LONGDESC@|$PKG_LONGDESC|g" \
|
||||
-e "s|@PKG_DISCLAIMER@|$PKG_DISCLAIMER|g" \
|
||||
-e "s|@PROVIDER_NAME@|$PROVIDER_NAME|g" \
|
||||
-e "s|@PKG_ADDON_PROVIDES@|$PKG_ADDON_PROVIDES|g" \
|
||||
-e "s|@PKG_ADDON_SCREENSHOT@|$PKG_ADDON_SCREENSHOT|g" \
|
||||
-i $ADDON_BUILD/$PKG_ADDON_ID/addon.xml
|
||||
|
||||
debug_strip $ADDON_BUILD/$PKG_ADDON_ID
|
Loading…
Reference in New Issue
Block a user