mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
create_addon: add possibility to build more then one addon, with one call
This commit is contained in:
parent
7c7ec449ad
commit
e8c5cfabfe
@ -3,39 +3,85 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
|
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
|
||||||
|
|
||||||
. config/options $1
|
. config/options
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
# usage
|
||||||
echo "usage: $0 package_name"
|
usage() {
|
||||||
exit 1
|
cat - >&2 <<EOUSAGE
|
||||||
fi
|
SYNOPSIS
|
||||||
|
./script/create_addon [OPTION] [addons]...
|
||||||
|
|
||||||
if [ -n "$PKG_ARCH" ]; then
|
DESCRIPTION
|
||||||
listcontains "$PKG_ARCH" "!$TARGET_ARCH" && exit 0
|
create_addon builds one or more addons.
|
||||||
listcontains "$PKG_ARCH" "$TARGET_ARCH" || listcontains "$PKG_ARCH" "any" || exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
not_supported() {
|
--show-only
|
||||||
echo "*** ERROR: $PKG_ADDON_ID: '${DEVICE:-$PROJECT}' not supported ***"
|
output the list of packages, which are intented to build
|
||||||
exit 0
|
|
||||||
|
--help shows this message
|
||||||
|
|
||||||
|
[addons]
|
||||||
|
list of addons to build.
|
||||||
|
The addons can identified by:
|
||||||
|
- the name of the addon
|
||||||
|
- a group name of addons
|
||||||
|
* all - all addons found under packages and project/*/packages
|
||||||
|
* offical - all addons found under packages/addons
|
||||||
|
* binary - all addons found under packages/mediacenter/kodi-binary-addons
|
||||||
|
* retroplayer - all addons called game.libretro. under packages/mediacenter/kodi-binary-addons
|
||||||
|
- a regex term (grep styled), the term is automatic sorounded with string begin and end (^[term]$)
|
||||||
|
|
||||||
|
addons can removed from list with a leading minus.
|
||||||
|
|
||||||
|
EXAMPLE
|
||||||
|
build all addons
|
||||||
|
> ./script/create_addon all
|
||||||
|
|
||||||
|
build audio encoders and decoders, only
|
||||||
|
> ./script/create_addon audioencoder.* audiodecoder.*
|
||||||
|
|
||||||
|
build all, but not retroplayer
|
||||||
|
> ./script/create_addon all -retroplayer
|
||||||
|
|
||||||
|
EOUSAGE
|
||||||
|
exit ${1:0}
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -n "$PKG_ADDON_PROJECTS" ]; then
|
# functions
|
||||||
[ "${DEVICE}" = "RPi" ] && _DEVICE="RPi1" || _DEVICE="${DEVICE}"
|
function find_addons() {
|
||||||
|
local _paths=""
|
||||||
|
local _filter="."
|
||||||
|
case $1 in
|
||||||
|
binary) _paths="$ROOT/packages/mediacenter/kodi-binary-addons";;
|
||||||
|
offical) _paths="$ROOT/packages/addons";;
|
||||||
|
retroplayer) _paths="$ROOT/packages/mediacenter/kodi-binary-addons";
|
||||||
|
_filter='^game\.libretro\.*';;
|
||||||
|
all) _paths="$ROOT/packages $ROOT/projects/*/packages";;
|
||||||
|
*) _paths="$ROOT/packages $ROOT/projects/*/packages";
|
||||||
|
_filter="^$1$";;
|
||||||
|
esac
|
||||||
|
|
||||||
if listcontains "$PKG_ADDON_PROJECTS" "!${_DEVICE:-$PROJECT}" ||
|
local _addons=$(
|
||||||
listcontains "$PKG_ADDON_PROJECTS" "!${PROJECT}"; then
|
find $_paths -name 'package.mk' \
|
||||||
not_supported
|
`# select packages with PKG_IS_ADDON (can yes, no or unset at this moment)` \
|
||||||
|
| xargs grep -l 'PKG_IS_ADDON' \
|
||||||
|
`# extract package name from path` \
|
||||||
|
| sed 's|^.*/\([^/]*\)/package.mk$|\1|g' \
|
||||||
|
`# filter package list against the given filter` \
|
||||||
|
| grep -e "$_filter" \
|
||||||
|
`# make entries unique` \
|
||||||
|
| sort -u \
|
||||||
|
`# select packages with PKG_IS_ADDON=yes (slow, but is a short list, now)` \
|
||||||
|
| xargs -n1 -I{} $SHELL -c '. ./config/options {} &>/dev/null; [ "$PKG_IS_ADDON" == "yes" ] && echo $PKG_NAME'
|
||||||
|
)
|
||||||
|
|
||||||
|
local _count=$(wc -w <<< $_addons)
|
||||||
|
if [ "$_count" == 0 ]; then
|
||||||
|
printf "$(print_color CLR_ERROR "ERROR: '$1' matches nothing...")\n\n" ' '>&$SILENT_OUT
|
||||||
|
usage 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! listcontains "$PKG_ADDON_PROJECTS" "${_DEVICE:-$PROJECT}" &&
|
echo $_addons
|
||||||
! listcontains "$PKG_ADDON_PROJECTS" "${PROJECT}" &&
|
}
|
||||||
! listcontains "$PKG_ADDON_PROJECTS" "any"; then
|
|
||||||
not_supported
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
$SCRIPTS/checkdeps
|
|
||||||
|
|
||||||
pack_addon() {
|
pack_addon() {
|
||||||
scripts/install_addon $PKG_NAME $PKG_ADDON_ID || exit
|
scripts/install_addon $PKG_NAME $PKG_ADDON_ID || exit
|
||||||
@ -48,12 +94,12 @@ pack_addon() {
|
|||||||
if [ "$ADDON_OVERWRITE" = "yes" ]; then
|
if [ "$ADDON_OVERWRITE" = "yes" ]; then
|
||||||
rm $ADDON_INSTALL_DIR/$PKG_ADDON_ID-$ADDONVER.zip
|
rm $ADDON_INSTALL_DIR/$PKG_ADDON_ID-$ADDONVER.zip
|
||||||
else
|
else
|
||||||
echo "*** WARNING: $PKG_ADDON_ID-$ADDONVER.zip already exists. not overwriting it ***"
|
printf "%${BUILD_INDENT}c $(print_color CLR_WARNING "*** WARNING: $PKG_ADDON_ID-$ADDONVER.zip already exists. not overwriting it ***")\n" ' '>&$SILENT_OUT
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cd $ADDON_BUILD
|
cd $ADDON_BUILD
|
||||||
echo "*** compressing Addon $PKG_ADDON_ID ... ***"
|
printf "%${BUILD_INDENT}c $(print_color CLR_INFO "*** compressing Addon $PKG_ADDON_ID ... ***")\n" ' '>&$SILENT_OUT
|
||||||
$TOOLCHAIN/bin/7za a -l -mx9 -bsp0 -bso0 -tzip $PKG_ADDON_ID-$ADDONVER.zip $PKG_ADDON_ID
|
$TOOLCHAIN/bin/7za a -l -mx9 -bsp0 -bso0 -tzip $PKG_ADDON_ID-$ADDONVER.zip $PKG_ADDON_ID
|
||||||
cd - &>/dev/null
|
cd - &>/dev/null
|
||||||
|
|
||||||
@ -93,21 +139,54 @@ pack_addon() {
|
|||||||
( cd $ADDON_JENKINS_DIR
|
( cd $ADDON_JENKINS_DIR
|
||||||
sha256sum $ADDON_JENKINS_ADDON_NAME.zip > $ADDON_JENKINS_ADDON_NAME.zip.sha256
|
sha256sum $ADDON_JENKINS_ADDON_NAME.zip > $ADDON_JENKINS_ADDON_NAME.zip.sha256
|
||||||
)
|
)
|
||||||
echo "*** creating $ADDON_JENKINS_ADDON_NAME.zip for Jenkins complete ***"
|
printf "%${BUILD_INDENT}c $(print_color CLR_INFO "*** creating $ADDON_JENKINS_ADDON_NAME.zip for Jenkins complete ***")\n" ' '>&$SILENT_OUT
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$PKG_IS_ADDON" = "yes" ] ; then
|
not_supported_arch() {
|
||||||
setup_toolchain target
|
printf "%${BUILD_INDENT}c $(print_color CLR_WARNING "*** ERROR: $PKG_ADDON_ID: '${DEVICE:-$PROJECT}' not supported ***")\n" ' '>&$SILENT_OUT
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
$SCRIPTS/build $@
|
not_supported_device() {
|
||||||
|
printf "%${BUILD_INDENT}c $(print_color CLR_WARNING "*** ERROR: $PKG_ADDON_ID: '$TARGET_ARCH' not supported ***")\n" ' '>&$SILENT_OUT
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
printf "%${BUILD_INDENT}c CREATE ADDON (${DEVICE:-$PROJECT}/$TARGET_ARCH) $1\n" ' '>&$SILENT_OUT
|
# build addon function
|
||||||
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
|
build_addon() {
|
||||||
|
# addon build
|
||||||
|
. config/options $1
|
||||||
|
|
||||||
|
# check support
|
||||||
|
if [ -n "$PKG_ARCH" ]; then
|
||||||
|
listcontains "$PKG_ARCH" "!$TARGET_ARCH" && not_supported_arch
|
||||||
|
listcontains "$PKG_ARCH" "$TARGET_ARCH" || listcontains "$PKG_ARCH" "any" || not_supported_arch
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$PKG_ADDON_PROJECTS" ]; then
|
||||||
|
[ "${DEVICE}" = "RPi" ] && _DEVICE="RPi1" || _DEVICE="${DEVICE}"
|
||||||
|
|
||||||
|
if listcontains "$PKG_ADDON_PROJECTS" "!${_DEVICE:-$PROJECT}" ||
|
||||||
|
listcontains "$PKG_ADDON_PROJECTS" "!${PROJECT}"; then
|
||||||
|
not_supported_device
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! listcontains "$PKG_ADDON_PROJECTS" "${_DEVICE:-$PROJECT}" &&
|
||||||
|
! listcontains "$PKG_ADDON_PROJECTS" "${PROJECT}" &&
|
||||||
|
! listcontains "$PKG_ADDON_PROJECTS" "any"; then
|
||||||
|
not_supported_device
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# build addon
|
||||||
|
$SCRIPTS/build $1
|
||||||
|
|
||||||
|
# cleanup old install path
|
||||||
rm -rf $ADDON_BUILD
|
rm -rf $ADDON_BUILD
|
||||||
|
|
||||||
|
# install addon parts
|
||||||
if [ "$(type -t addon)" = "function" ]; then
|
if [ "$(type -t addon)" = "function" ]; then
|
||||||
addon
|
addon
|
||||||
else
|
else
|
||||||
@ -125,4 +204,75 @@ if [ "$PKG_IS_ADDON" = "yes" ] ; then
|
|||||||
else
|
else
|
||||||
pack_addon
|
pack_addon
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# need parameter
|
||||||
|
if [ $# == 0 ]; then
|
||||||
|
usage 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# collect list of addons for building
|
||||||
|
addons=()
|
||||||
|
addons_drop=()
|
||||||
|
show_only="false"
|
||||||
|
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
|
||||||
|
|
||||||
|
# read addons from parameter list
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
--help) usage 0;;
|
||||||
|
--show-only) show_only="true";;
|
||||||
|
-*) addons_drop+=" $(find_addons ${1:1})";;
|
||||||
|
*) addons+=" $(find_addons $1)";;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# check environment and create toolchain
|
||||||
|
$SCRIPTS/checkdeps
|
||||||
|
setup_toolchain target
|
||||||
|
|
||||||
|
# build addons, by calling function build_addon with one addon, after another
|
||||||
|
# (do not abort on build failure)
|
||||||
|
addons_failed=""
|
||||||
|
set +e
|
||||||
|
_count=''
|
||||||
|
for addon in $(tr " " "\n" <<< $addons | sort -u); do
|
||||||
|
# no build, when addon is in drop list / should not build
|
||||||
|
if listcontains "$addons_drop" "$addon"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# show-only: print name and continue with next addon
|
||||||
|
if [ $show_only == "true" ]; then
|
||||||
|
echo $addon
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# build package
|
||||||
|
printf "$(print_color CLR_BUILD "CREATE ADDON $addon") (${DEVICE:-$PROJECT}/$TARGET_ARCH)\n" ' '>&$SILENT_OUT
|
||||||
|
_count+='x'
|
||||||
|
( build_addon $addon )
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
addons_failed+="$addon "
|
||||||
|
printf "$(print_color CLR_ERROR "ADDON FAILED $addon")\n" ' '>&$SILENT_OUT
|
||||||
|
else
|
||||||
|
printf "$(print_color CLR_INFO "ADDON SUCCESS $addon")\n" ' '>&$SILENT_OUT
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# show-only hs no summary, can exit here
|
||||||
|
if [ $show_only == "true" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# print summary
|
||||||
|
if [ $_count != 'x' ]; then
|
||||||
|
if [ -z "$addons_failed" ]; then
|
||||||
|
printf "$(print_color CLR_INFO "ALL ADDONS BUILDS SUCCESSFUL")\n"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
printf "$(print_color CLR_ERROR "FAILED ADDONS: $addons_failed")\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user