diff options
Diffstat (limited to 'tools/Linux')
20 files changed, 737 insertions, 0 deletions
diff --git a/tools/Linux/firewalld-services/kodi-eventserver.xml b/tools/Linux/firewalld-services/kodi-eventserver.xml new file mode 100644 index 0000000..68cdb3c --- /dev/null +++ b/tools/Linux/firewalld-services/kodi-eventserver.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<service> + <short>Kodi EventServer</short> + <description>Kodi is a free cross-platform media-player jukebox and entertainment hub. Enable this option to remotely control Kodi via its EventServer API.</description> + <port protocol="udp" port="9777"/> +</service> diff --git a/tools/Linux/firewalld-services/kodi-http.xml b/tools/Linux/firewalld-services/kodi-http.xml new file mode 100644 index 0000000..863c251 --- /dev/null +++ b/tools/Linux/firewalld-services/kodi-http.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<service> + <short>Kodi web interface</short> + <description>Kodi is a free cross-platform media-player jukebox and entertainment hub. Enable this option to remotely control Kodi via its web interface.</description> + <port protocol="tcp" port="8080"/> +</service> diff --git a/tools/Linux/firewalld-services/kodi-jsonrpc.xml b/tools/Linux/firewalld-services/kodi-jsonrpc.xml new file mode 100644 index 0000000..08ed2af --- /dev/null +++ b/tools/Linux/firewalld-services/kodi-jsonrpc.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<service> + <short>Kodi JSON-RPC</short> + <description>Kodi is a free cross-platform media-player jukebox and entertainment hub. Enable this option to remotely control Kodi via its JSON-RPC API.</description> + <port protocol="tcp" port="9090"/> +</service> diff --git a/tools/Linux/kodi-standalone.sh.in b/tools/Linux/kodi-standalone.sh.in new file mode 100644 index 0000000..956e193 --- /dev/null +++ b/tools/Linux/kodi-standalone.sh.in @@ -0,0 +1,54 @@ +#!/bin/sh + +# Copyright (C) 2009-2015 Team XBMC +# http://kodi.tv +# +# This Program 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, or (at your option) +# any later version. +# +# This Program 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 XBMC; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +# http://www.gnu.org/copyleft/gpl.html + +prefix="@prefix@" +exec_prefix="@exec_prefix@" +bindir="@bindir@" +bin_name=@APP_NAME_LC@ +APP="${bindir}/${bin_name} --standalone $@" + +@XBMC_STANDALONE_SH_PULSE@ + +LOOP=1 +CRASHCOUNT=0 +LASTSUCCESSFULSTART=$(date +%s) + +while [ $LOOP -eq 1 ] +do + $APP + RET=$? + NOW=$(date +%s) + if [ $RET -ge 64 ] && [ $RET -le 66 ] || [ $RET -eq 0 ]; then # clean exit + LOOP=0 + else # crash + DIFF=$((NOW-LASTSUCCESSFULSTART)) + if [ $DIFF -gt 60 ]; then # Not on startup, ignore + LASTSUCESSFULSTART=$NOW + CRASHCOUNT=0 + else # at startup, look sharp + CRASHCOUNT=$((CRASHCOUNT+1)) + if [ $CRASHCOUNT -ge 3 ]; then # Too many, bail out + LOOP=0 + echo "${APP} has exited in an unclean state 3 times in the last ${DIFF} seconds." + echo "Something is probably wrong" + fi + fi + fi +done diff --git a/tools/Linux/kodi-standalone.sh.pulse b/tools/Linux/kodi-standalone.sh.pulse new file mode 100644 index 0000000..e77efe8 --- /dev/null +++ b/tools/Linux/kodi-standalone.sh.pulse @@ -0,0 +1,4 @@ +PULSE_START="$(command -v start-pulseaudio-x11)" +if [ -n "$PULSE_START" ]; then + $PULSE_START +fi diff --git a/tools/Linux/kodi-xsession.desktop.in b/tools/Linux/kodi-xsession.desktop.in new file mode 100644 index 0000000..c9f8c43 --- /dev/null +++ b/tools/Linux/kodi-xsession.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=@APP_NAME@ +Comment=This session will start @APP_NAME@ media center +Exec=@APP_NAME_LC@-standalone +TryExec=@APP_NAME_LC@-standalone +Type=Application +Keywords=audio;video;media;center;tv;movies;series;songs;remote; +Icon=@APP_NAME_LC@ diff --git a/tools/Linux/kodi.desktop.in b/tools/Linux/kodi.desktop.in new file mode 100644 index 0000000..71d3f7d --- /dev/null +++ b/tools/Linux/kodi.desktop.in @@ -0,0 +1,25 @@ +[Desktop Entry] +Version=1.0 +Name=@APP_NAME@ +GenericName=Media Center +GenericName[zh_CN]=媒体中心 +Comment=Manage and view your media +Comment[ru]=Просмотр и управление мультимедиа +Comment[zh_CN]=管理和查看您的媒体 +Exec=@APP_NAME_LC@ +Icon=@APP_NAME_LC@ +Terminal=false +Type=Application +Categories=AudioVideo;Video;Player;TV; + +Actions=Fullscreen;Standalone; + +[Desktop Action Fullscreen] +Name=Open in fullscreen +Name[zh_CN]=全屏打开 +Exec=@APP_NAME_LC@ -fs + +[Desktop Action Standalone] +Name=Open in standalone mode +Name[zh_CN]=在独立模式下打开 +Exec=@APP_NAME_LC@ --standalone diff --git a/tools/Linux/kodi.metainfo.xml.in b/tools/Linux/kodi.metainfo.xml.in new file mode 100644 index 0000000..998c631 --- /dev/null +++ b/tools/Linux/kodi.metainfo.xml.in @@ -0,0 +1,137 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component type="desktop-application"> + <id>@APP_PACKAGE@</id> + <name>@APP_NAME@</name> + <project_license>GPL-2.0-only GPL-2.0-or-later LGPL-2.1-or-later MIT BSD-3-Clause BSD-4-Clause</project_license> + <metadata_license>CC0-1.0</metadata_license> + <developer_name>Team Kodi</developer_name> + <summary>Ultimate entertainment center</summary> + <url type="homepage">https://kodi.tv/</url> + <url type="donation">https://kodi.tv/contribute/donate</url> + <url type="bugtracker">https://github.com/xbmc/xbmc/issues</url> + <url type="faq">https://kodi.wiki/view/FAQs</url> + <url type="help">https://forum.kodi.tv/</url> + <url type="translate">https://kodi.weblate.cloud/</url> + <url type="contribute">https://github.com/xbmc/xbmc/blob/master/docs/CONTRIBUTING.md</url> + <url type="vcs-browser">https://github.com/xbmc/xbmc/</url> + <description> + <p>Kodi allows users to play and view videos, music, podcasts, + and other digital media files from local storage, network storage + and the internet. It's optimized for a 10-foot user interface to be + used with televisions and remote controls.</p> + + <p>Kodi spawned from the love of media. It is an entertainment hub + that brings all your digital media together into a beautiful + and user friendly package. It is 100% free and open source, + very customisable and runs on a wide variety of devices. It is + supported by a dedicated team of volunteers and a huge community.</p> + </description> + <keywords> + <keyword>Kodi</keyword> + <keyword>xbmc</keyword> + <keyword>audio</keyword> + <keyword>video</keyword> + <keyword>media</keyword> + <keyword>media center</keyword> + <keyword>music</keyword> + <keyword>tv</keyword> + <keyword>television</keyword> + <keyword>remote control</keyword> + </keywords> + <launchable type="desktop-id">@APP_NAME_LC@.desktop</launchable> + <screenshots> + <screenshot type="default"> + <image>https://mirrors.kodi.tv/screenshots/kodi-recently-added.jpg</image> + <caption>The homescreen keeps your media organized</caption> + </screenshot> + <screenshot> + <image>https://mirrors.kodi.tv/screenshots/kodi-videolibrary.jpg</image> + <caption>Easily browse your movies and series</caption> + </screenshot> + <screenshot> + <image>https://mirrors.kodi.tv/screenshots/kodi-video-info.jpg</image> + <caption>Get additional infos about your movies or series</caption> + </screenshot> + <screenshot> + <image>https://mirrors.kodi.tv/screenshots/kodi-tvshow.jpg</image> + <caption>Browse TV shows by seasons</caption> + </screenshot> + <screenshot> + <image>https://mirrors.kodi.tv/screenshots/kodi-music-info.jpg</image> + <caption>Use the music library to organize and read about your artists</caption> + </screenshot> + <screenshot> + <image>https://mirrors.kodi.tv/screenshots/kodi-epg.jpg</image> + <caption>Use the EPG to manage your TV stations</caption> + </screenshot> + <screenshot> + <image>https://mirrors.kodi.tv/screenshots/kodi-addons.jpg</image> + <caption>Extend what Kodi can do, just use addons</caption> + </screenshot> + <screenshot> + <image>https://mirrors.kodi.tv/screenshots/kodi-weather.jpg</image> + <caption>Keep the weather in check</caption> + </screenshot> + <screenshot> + <image>https://mirrors.kodi.tv/screenshots/kodi-webinterface.jpg</image> + <caption>The webinterface enables you to manage your Kodi from other devices</caption> + </screenshot> + </screenshots> + <releases> + <release date="2024-02-10" version="20.4-Nexus" type="stable"><url>https://kodi.tv/article/kodi-20-4-nexus-release/</url></release> + <release date="2024-01-09" version="20.3-Nexus" type="stable"><url>https://kodi.tv/article/kodi-20-3-nexus-release/</url></release> + <release date="2023-06-29" version="20.2-Nexus" type="stable"><url>https://kodi.tv/article/kodi-20-2-nexus-release/</url></release> + <release date="2023-03-11" version="20.1-Nexus" type="stable"><url>https://kodi.tv/article/kodi-20-1-nexus-release/</url></release> + <release date="2023-01-15" version="20.0-Nexus" type="stable"><url>https://kodi.tv/article/kodi-20-0-nexus-release/</url></release> + <release date="2022-12-21" version="20.0~rc2-Nexus" type="development"><url>https://kodi.tv/article/kodi-nexus-rc-2/</url></release> + <release date="2022-12-10" version="20.0~rc1-Nexus" type="development"><url>https://kodi.tv/article/kodi-nexus-rc-1/</url></release> + <release date="2022-11-08" version="20.0~b1-Nexus" type="development"><url>https://kodi.tv/article/kodi-nexus-beta-1/</url></release> + <release date="2022-09-08" version="20.0~a3-Nexus" type="development"><url>https://kodi.tv/article/kodi-nexus-alpha-3/</url></release> + <release date="2022-07-09" version="20.0~a2-Nexus" type="development"><url>https://kodi.tv/article/kodi-nexus-alpha-2/</url></release> + <release date="2022-05-16" version="20.0~a1-Nexus" type="development"><url>https://kodi.tv/article/kodi-nexus-alpha-1/</url></release> + <release date="2022-03-03" version="19.4-Matrix"/> + <release date="2021-10-24" version="19.3-Matrix"/> + <release date="2021-10-08" version="19.2-Matrix"/> + <release date="2021-05-09" version="19.1-Matrix"/> + <release date="2021-02-19" version="19.0-Matrix"/> + <release date="2020-10-24" version="18.9-Leia"/> + <release date="2020-07-28" version="18.8-Leia"/> + <release date="2020-05-21" version="18.7-Leia"/> + <release date="2020-02-29" version="18.6-Leia"/> + <release date="2019-11-18" version="18.5-Leia"/> + <release date="2019-08-31" version="18.4-Leia"/> + <release date="2019-06-27" version="18.3-Leia"/> + <release date="2019-04-22" version="18.2-Leia"/> + <release date="2019-02-17" version="18.1-Leia"/> + </releases> + <content_rating type="oars-1.0"> + <content_attribute id="violence-cartoon">none</content_attribute> + <content_attribute id="violence-fantasy">none</content_attribute> + <content_attribute id="violence-realistic">none</content_attribute> + <content_attribute id="violence-bloodshed">none</content_attribute> + <content_attribute id="violence-sexual">none</content_attribute> + <content_attribute id="drugs-alcohol">none</content_attribute> + <content_attribute id="drugs-narcotics">none</content_attribute> + <content_attribute id="drugs-tobacco">none</content_attribute> + <content_attribute id="sex-nudity">none</content_attribute> + <content_attribute id="sex-themes">none</content_attribute> + <content_attribute id="language-profanity">none</content_attribute> + <content_attribute id="language-humor">none</content_attribute> + <content_attribute id="language-discrimination">none</content_attribute> + <content_attribute id="social-chat">none</content_attribute> + <content_attribute id="social-info">none</content_attribute> + <content_attribute id="social-audio">none</content_attribute> + <content_attribute id="social-location">none</content_attribute> + <content_attribute id="social-contacts">none</content_attribute> + <content_attribute id="money-purchasing">none</content_attribute> + <content_attribute id="money-gambling">none</content_attribute> + </content_rating> + <recommends> + <control>keyboard</control> + <control>pointing</control> + <control>touch</control> + <control>tv-remote</control> + <control>gamepad</control> + <control>tablet</control> + </recommends> +</component> diff --git a/tools/Linux/kodi.sh.in b/tools/Linux/kodi.sh.in new file mode 100644 index 0000000..11cace2 --- /dev/null +++ b/tools/Linux/kodi.sh.in @@ -0,0 +1,192 @@ +#!/bin/sh + +# Copyright (C) 2008-2017 Team XBMC +# http://kodi.tv +# +# This Program 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, or (at your option) +# any later version. +# +# This Program 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 XBMC; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +# http://www.gnu.org/copyleft/gpl.html + +APP=@APP_NAME@ +bin_name=@APP_NAME_LC@ +SAVED_ARGS="$@" +prefix="@prefix@" +exec_prefix="@exec_prefix@" +datarootdir="@datarootdir@" +LIBDIR="@libdir@" +APP_BINARY=$LIBDIR/${bin_name}/@APP_BINARY@ +CRASHLOG_DIR=${CRASHLOG_DIR:-$HOME} +KODI_DATA=${KODI_DATA:-"${HOME}/.${bin_name}"} # mapped to special://home/ + +# Workaround for high CPU load with nvidia GFX +export __GL_YIELD=USLEEP + +# Fix wasting RAM due to fragmentation +export MALLOC_MMAP_THRESHOLD_=131072 + +# Check for some options used by this script +while [ "$#" -gt "0" ] +do + case "$1" in + --setlibdir) + LIBDIR="$2" + shift; shift + ;; + *) + shift + ;; + esac +done + +KODI_BINARY=${APP_BINARY} + +if [ ! -x ${KODI_BINARY} ]; then + echo "Error: ${KODI_BINARY} not found" + exit 2 +fi + +APPORT_CORE="/var/crash/$(echo -n ${KODI_BINARY}|tr / _).$(id -u).crash" + +command_exists() +{ + command -pv $1 >/dev/null 2>&1 +} + +single_stacktrace() +{ + # core filename is either "core.$PID" or "core" + find "$1" -maxdepth $2 -name 'core*' | while read core; do + LC_ALL=C gdb --core="$core" --batch 2> /dev/null | grep -q "^Core was generated by \`${KODI_BINARY}" || continue + echo "=====> Core file: "$core" ($(stat -c%y "$core"))" >> $FILE + echo " =========================================" >> $FILE + gdb "${KODI_BINARY}" --core="$core" --batch -ex "thread apply all bt" 2> /dev/null >> $FILE + rm -f "$core" + done +} + +print_crash_report() +{ + FILE="$CRASHLOG_DIR/${bin_name}_crashlog-`date +%Y%m%d_%H%M%S`.log" + echo "############## $APP CRASH LOG ###############" >> $FILE + echo >> $FILE + echo "################ SYSTEM INFO ################" >> $FILE + printf " Date: " >> $FILE + date >> $FILE + echo " $APP Options: $*" >> $FILE + printf " Arch: " >> $FILE + uname -m >> $FILE + printf " Kernel: " >> $FILE + uname -rvs >> $FILE + printf " Release: " >> $FILE + if [ -f /etc/os-release ]; then + . /etc/os-release + echo $NAME $VERSION >> $FILE + elif command_exists lsb_release; then + echo >> $FILE + lsb_release -a 2> /dev/null | sed -e 's/^/ /' >> $FILE + else + echo "lsb_release not available" >> $FILE + fi + echo "############## END SYSTEM INFO ##############" >> $FILE + echo >> $FILE + echo "############### STACK TRACE #################" >> $FILE + if command_exists gdb; then + if command_exists systemd-coredumpctl; then + systemd-coredumpctl dump -o core $(basename ${KODI_BINARY}) > /dev/null 2>&1 + elif command_exists coredumpctl; then + coredumpctl dump -o core $(basename ${KODI_BINARY}) > /dev/null 2>&1 + elif command_exists apport-unpack && test -f "${APPORT_CORE}"; then + TMP_DIR="$(mktemp -d -p ${HOME})" + if [ -d "${TMP_DIR}" ]; then + rm -f "${HOME}/core" + apport-unpack "${APPORT_CORE}" "${TMP_DIR}" + mv "${TMP_DIR}/CoreDump" "${HOME}/core" + rm -rf "${TMP_DIR}" + fi + fi + single_stacktrace "$PWD" 1 + # Find in plugins directories + if [ $KODI_HOME ]; then + BASEDIR=$KODI_HOME + else + BASEDIR="$LIBDIR/${bin_name}/" + fi + single_stacktrace "$BASEDIR" 5 + # find in userdata dir + single_stacktrace "$HOME" 5 + # try /proc/sys/kernel/core_pattern + # Check if it does not contain a pipe to a program (see man 5 core) + if [ "$(cat /proc/sys/kernel/core_pattern | cut -c 1)" != "|" ]; then + [ -d "$(dirname $(cat /proc/sys/kernel/core_pattern))" ] && single_stacktrace "$(dirname $(cat /proc/sys/kernel/core_pattern))" 1 + fi + else + echo "gdb not installed, can't get stack trace." >> $FILE + fi + echo "############# END STACK TRACE ###############" >> $FILE + echo >> $FILE + echo "################# LOG FILE ##################" >> $FILE + echo >> $FILE + if [ -f $KODI_TEMP/@APP_NAME_LC@.log ] + then + cat $KODI_TEMP/@APP_NAME_LC@.log >> $FILE + echo >> $FILE + elif [ -f $KODI_DATA/temp/@APP_NAME_LC@.log ] + then + cat $KODI_DATA/temp/@APP_NAME_LC@.log >> $FILE + echo >> $FILE + else + echo "Logfile not found in the usual place." >> $FILE + echo "Please attach it separately." >> $FILE + echo "Use pastebin.com or similar for forums or IRC." >> $FILE + fi + echo >> $FILE + echo "############### END LOG FILE ################" >> $FILE + echo >> $FILE + echo "############ END $APP CRASH LOG #############" >> $FILE + echo "Crash report available at $FILE" +} + +propagate_sigterm() { + kill -TERM "$CHILD" 2>/dev/null +} + +trap propagate_sigterm TERM + +if command_exists gdb; then + # Output warning in case ulimit is unsupported by shell + eval ulimit -c unlimited + if [ ! $? = "0" ]; then + echo "${bin_name}: ulimit is unsupported by this shell" 1>&2 + fi +fi + +LOOP=1 +while [ $(( $LOOP )) = "1" ] +do + [ -f "${APPORT_CORE}" ] && rm -f "${APPORT_CORE}" + LOOP=0 + ${KODI_BINARY} $SAVED_ARGS & + CHILD=$! + wait "${CHILD}" + RET=$? + if [ $RET -eq 65 ] + then # User requested to restart app + LOOP=1 + elif [ $RET -ge 131 ] && [ $RET -le 136 ] || [ $RET -eq 139 ] + then # Crashed with core dump + print_crash_report + fi +done + +exit $RET diff --git a/tools/Linux/packaging/README.debian b/tools/Linux/packaging/README.debian new file mode 100644 index 0000000..5e217d3 --- /dev/null +++ b/tools/Linux/packaging/README.debian @@ -0,0 +1,31 @@ +--- How to build a Kodi Debian package --- + +There are two available build methods: +1.) debuild / debhelper + Requirements: debhelper, devscripts, all Kodi build deps + sudo apt-get install debhelper devscripts + sudo apt-get build-dep kodi (if you have one of our repos/ppas added, else read docs/README.Linux.md or docs/README.Ubuntu.md) + + Result: Debian package for your host distribution and architecture only + Recommended for local installs + + Example Usage: ./mk-debian-package.sh + +2.) pdebuild / pbuilder + Requirements: pbuilder, devscripts, proper pbuilder environment + For a comprehensive example how to setup pbuilder read: + https://wiki.ubuntu.com/PbuilderHowto + + Result: Debian package for arbitrary Debian based distributions and architectures. + Recommended for hosting your own apt repository or (clean room) compile testing for various distributions + + Example Usage: + RELEASEV=16 \ + DISTS=-"unstable" \ + ARCHS="i386 amd64" \ + BUILDER="pdebuild" \ + PDEBUILD_OPTS="--debbuildopts \"-j4\"" \ + PBUILDER_BASE="/home/$USER/xbmc-packaging/pbuilder" \ + DPUT_TARGET="local" \ + ./mk-debian-package.sh + diff --git a/tools/Linux/packaging/media/icon128x128.png b/tools/Linux/packaging/media/icon128x128.png Binary files differnew file mode 100644 index 0000000..8a25c4a --- /dev/null +++ b/tools/Linux/packaging/media/icon128x128.png diff --git a/tools/Linux/packaging/media/icon16x16.png b/tools/Linux/packaging/media/icon16x16.png Binary files differnew file mode 100644 index 0000000..9b27352 --- /dev/null +++ b/tools/Linux/packaging/media/icon16x16.png diff --git a/tools/Linux/packaging/media/icon22x22.png b/tools/Linux/packaging/media/icon22x22.png Binary files differnew file mode 100644 index 0000000..21f76e5 --- /dev/null +++ b/tools/Linux/packaging/media/icon22x22.png diff --git a/tools/Linux/packaging/media/icon24x24.png b/tools/Linux/packaging/media/icon24x24.png Binary files differnew file mode 100644 index 0000000..dad983b --- /dev/null +++ b/tools/Linux/packaging/media/icon24x24.png diff --git a/tools/Linux/packaging/media/icon256x256.png b/tools/Linux/packaging/media/icon256x256.png Binary files differnew file mode 100644 index 0000000..cc2ee49 --- /dev/null +++ b/tools/Linux/packaging/media/icon256x256.png diff --git a/tools/Linux/packaging/media/icon32x32.png b/tools/Linux/packaging/media/icon32x32.png Binary files differnew file mode 100644 index 0000000..c0a0534 --- /dev/null +++ b/tools/Linux/packaging/media/icon32x32.png diff --git a/tools/Linux/packaging/media/icon48x48.png b/tools/Linux/packaging/media/icon48x48.png Binary files differnew file mode 100644 index 0000000..898c023 --- /dev/null +++ b/tools/Linux/packaging/media/icon48x48.png diff --git a/tools/Linux/packaging/media/icon64x64.png b/tools/Linux/packaging/media/icon64x64.png Binary files differnew file mode 100644 index 0000000..700144b --- /dev/null +++ b/tools/Linux/packaging/media/icon64x64.png diff --git a/tools/Linux/packaging/mk-debian-package.sh b/tools/Linux/packaging/mk-debian-package.sh new file mode 100755 index 0000000..ad81be0 --- /dev/null +++ b/tools/Linux/packaging/mk-debian-package.sh @@ -0,0 +1,187 @@ +#!/bin/bash +# +# Copyright (C) 2013 Team XBMC +# http://kodi.tv +# +# This Program 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, or (at your option) +# any later version. +# +# This Program 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 XBMC; see the file COPYING. If not, see +# <http://www.gnu.org/licenses/>. +# + + +RELEASEV=${RELEASEV:-"auto"} +VERSION_PREFIX=${VERSION_PREFIX:-""} +TAG=${TAG} +TAGREV=${TAGREV:-""} +REPO_DIR=${WORKSPACE:-$(cd "$(dirname $0)/../../../" ; pwd)} +[[ $(which lsb_release) ]] && DISTS=${DISTS:-$(lsb_release -cs)} || DISTS=${DISTS:-"stable"} +ARCHS=${ARCHS:-$(dpkg --print-architecture)} +BUILDER=${BUILDER:-"debuild"} +DEBUILD_OPTS=${DEBUILD_OPTS:-""} +PDEBUILD_OPTS=${PDEBUILD_OPTS:-""} +PBUILDER_BASE=${PBUILDER_BASE:-"/var/cache/pbuilder"} +DPUT_TARGET=${DPUT_TARGET:-"local"} +DEBIAN=${DEBIAN:-"https://github.com/xbmc/xbmc-packaging/archive/master.tar.gz"} +BUILD_DATE=$(date '+%Y%m%d.%H%M') + +function usage { + echo "$0: This script builds a Kodi debian package from a git repository." + echo "The build is controlled by ENV variables, which can be overridden as appropriate:" + echo "BUILDER is either debuild(default) or pdebuild(needs a proper pbuilder setup)" + checkEnv +} + +function checkEnv { + echo "#------ build environment ------#" + echo "REPO_DIR: $REPO_DIR" + getVersion + echo "RELEASEV: $RELEASEV" + echo "REVISION: $TAGREV" + [[ -n $TAG ]] && echo "TAG: $TAG" + echo "DISTS: $DISTS" + echo "ARCHS: $ARCHS" + echo "DEBIAN: $DEBIAN" + echo "BUILDER: $BUILDER" + echo "CONFIGURATION: $Configuration" + + if ! [[ $(which $BUILDER) ]] + then + echo "Error: can't find ${BUILDER}, consider using full path to [debuild|pdebuild]" + exit 1 + fi + + if [[ "$BUILDER" =~ "pdebuild" ]] + then + if ! [[ -d $PBUILDER_BASE ]] ; then echo "Error: $PBUILDER_BASE does not exist"; exit 1; fi + echo "PBUILDER_BASE: $PBUILDER_BASE" + echo "PDEBUILD_OPTS: $PDEBUILD_OPTS" + else + echo "DEBUILD_OPTS: $DEBUILD_OPTS" + fi + + echo "#-------------------------------#" +} + +function getVersion { + getGitRev + if [[ $RELEASEV == "auto" ]] + then + local MAJORVER=$(grep VERSION_MAJOR $REPO_DIR/version.txt | awk '{ print $2 }') + local MINORVER=$(grep VERSION_MINOR $REPO_DIR/version.txt | awk '{ print $2 }') + RELEASEV=${MAJORVER}.${MINORVER} + else + PACKAGEVERSION="${RELEASEV}~git${BUILD_DATE}-${TAG}" + fi + + if [[ -n ${VERSION_PREFIX} ]] + then + PACKAGEVERSION="${VERSION_PREFIX}:${RELEASEV}~git${BUILD_DATE}-${TAG}" + else + PACKAGEVERSION="${RELEASEV}~git${BUILD_DATE}-${TAG}" + fi +} + +function getGitRev { + cd $REPO_DIR || exit 1 + REV=$(git log -1 --pretty=format:"%h") + [[ -z $TAG ]] && TAG=$REV + [[ -z $TAGREV ]] && TAGREV=0 +} + +function archiveRepo { + cd $REPO_DIR || exit 1 + git clean -xfd + echo $REV > VERSION + tools/depends/target/ffmpeg/autobuild.sh -d + DEST="kodi-${RELEASEV}~git${BUILD_DATE}-${TAG}" + [[ -d debian ]] && rm -rf debian + cd .. + tar -czf ${DEST}.tar.gz --exclude .git $(basename $REPO_DIR) + ln -s ${DEST}.tar.gz ${DEST/-/_}.orig.tar.gz + echo "Output Archive: ${DEST}.tar.gz" + + cd $REPO_DIR || exit 1 + getDebian +} + +function getDebian { + if [[ -d $DEBIAN ]] + then + cp -r $DEBIAN . + else + mkdir tmp && cd tmp + curl -L -s $DEBIAN -o debian.tar.gz + tar xzf debian.tar.gz + cd xbmc-packaging-* + for FILE in *.unified; do mv $FILE debian/${FILE%.unified}; done + mv debian $REPO_DIR + cd $REPO_DIR ; rm -rf tmp + fi +} + +function buildDebianPackages { + archiveRepo + cd $REPO_DIR || exit 1 + sed -e "s/#PACKAGEVERSION#/${PACKAGEVERSION}/g" -e "s/#TAGREV#/${TAGREV}/g" debian/changelog.in > debian/changelog.tmp + [ "$Configuration" == "Debug" ] && sed -i "s/XBMC_RELEASE = yes/XBMC_RELEASE = no/" debian/rules + + for dist in $DISTS + do + sed "s/#DIST#/${dist}/g" debian/changelog.tmp > debian/changelog + for arch in $ARCHS + do + cd $REPO_DIR + echo "building: DIST=$dist ARCH=$arch" + if [[ "$BUILDER" =~ "pdebuild" ]] + then + DIST=$dist ARCH=$arch $BUILDER $PDEBUILD_OPTS + [ $? -eq 0 ] && uploadPkg || exit 1 + else + $BUILDER $DEBUILD_OPTS + echo "output directory: $REPO_DIR/.." + fi + done + done +} + +function uploadPkg { + PKG="${PBUILDER_BASE}/${dist}-${arch}/result/${DEST/-/_}-${TAGREV}_${arch}.changes" + echo "signing package" + debsign $PKG + echo "uploading $PKG to $DPUT_TARGET" + dput $DPUT_TARGET $PKG + UPLOAD_DONE=$? +} + +function cleanup { + if [[ $UPLOAD_DONE -eq 0 ]] && [[ "$BUILDER" =~ "pdebuild" ]] + then + cd $REPO_DIR/.. || exit 1 + rm ${DEST}* + rm ${DEST/-/_}* + fi +} + +### +# main +### +if [[ $1 = "-h" ]] || [[ $1 = "--help" ]] +then + usage + exit +fi + +checkEnv +buildDebianPackages +cleanup + diff --git a/tools/Linux/packaging/package-kodi-launchpad.sh b/tools/Linux/packaging/package-kodi-launchpad.sh new file mode 100755 index 0000000..d6e7c51 --- /dev/null +++ b/tools/Linux/packaging/package-kodi-launchpad.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +releaseversion=${VERSION:-"AUTO"} +epoch=${EPOCH:-"2"} +gitrev=${GITREV:-"$(git log -1 --pretty=format:"%h")"} +tag=${TAG:-${gitrev}} +tagrev=${tagrev:-"0"} +dists=${DISTS:-"hirsute groovy focal bionic"} +gpgkey=${GPG_KEY:-"jenkins (jenkins build bot) <jenkins@kodi.tv>"} +ppa=${PPA:-"nightly"} +debianrepo="${DEBIAN:-"https://github.com/xbmc/xbmc-packaging"}" + +if [ "$releaseversion" = "AUTO" ]; then + majorversion="$(awk '/VERSION_MAJOR/ {print $2}' version.txt)" + minorversion="$(awk '/VERSION_MINOR/ {print $2}' version.txt)" + releaseversion="${majorversion}.${minorversion}" +fi + +version="${releaseversion}+git$(date '+%Y%m%d.%H%M')-${tag}" +debversion="${epoch}:${version}" +origtarball="kodi_${version}.orig.tar.gz" + +declare -A PPAS=( + ["nightly"]='ppa:team-xbmc/xbmc-nightly' + ["unstable"]='ppa:team-xbmc/unstable' + ["stable"]='ppa:team-xbmc/ppa' + ["wsnipex-nightly"]='ppa:wsnipex/kodi-git' + ["wsnipex-stable"]='ppa:wsnipex/kodi-stable' +) + +# clean up before creating the source tarball +git clean -xfd + +# set build info +date '+%Y%m%d' > BUILDDATE +echo $gitrev > VERSION + +# download packaging files +wget -O - ${debianrepo}/archive/master.tar.gz | tar xzv --strip-components=1 --exclude=".git*" -f - +[ -d debian ] || { echo "ERROR: directory debian does not exist"; exit 3; } + +# add tarballs for internal ffmpeg, libdvd +tools/depends/target/ffmpeg/autobuild.sh -d || { echo "Error downloading ffmpeg"; exit 2; } +make -C tools/depends/target/libdvdnav download || { echo "Error downloading libdvdnav"; exit 2; } +make -C tools/depends/target/libdvdread download || { echo "Error downloading libdvdread"; exit 2; } +make -C tools/depends/target/libdvdcss download || { echo "Error downloading libdvdcss"; exit 2; } +make -C tools/depends/target/dav1d download || { echo "Error downloading dav1d"; exit 2; } + +# create orig tarball if needed +if grep -q quilt debian/source/format; then + echo "origtarball: ${origtarball}" + git archive -o ../${origtarball} ${gitrev} +fi + + +# build source packages +for dist in ${dists//,/ }; do + echo "### Building for ${dist} ###" + sed \ + -e "s/#PACKAGEVERSION#/${debversion}/" \ + -e "s/#TAGREV#/${tagrev}/" \ + -e "s/#DIST#/${dist}/g" \ + debian/changelog.in > debian/changelog + + echo "Changelog:" + cat debian/changelog + echo + + debuild -d -S -k"${gpgkey}" + echo "### DONE ###" +done + +# upload to PPA +echo "### Uploading to PPA ${PPAS[${ppa}]} ###" +dput ${PPAS[${ppa}]} ../kodi_${version}*.changes +if [ $? -eq 0 ]; then + echo "### Successfully pushed ${version} to launchpad ###" +else + echo "### ERROR could not upload package ###" +fi + |