cmake: don't enforce that the name of an addon's repository must be identical to...
[vuplus_xbmc] / tools / Linux / xbmc.sh.in
1 #!/bin/sh
2
3 #      Copyright (C) 2008-2013 Team XBMC
4 #      http://xbmc.org
5 #
6 #  This Program is free software; you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation; either version 2, or (at your option)
9 #  any later version.
10 #
11 #  This Program is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with XBMC; see the file COPYING.  If not, write to
18 #  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 #  http://www.gnu.org/copyleft/gpl.html
20
21 SAVED_ARGS="$@"
22 prefix="@prefix@"
23 exec_prefix="@exec_prefix@"
24 datarootdir="@datarootdir@"
25 LIBDIR="@libdir@"
26 CRASHLOG_DIR=${CRASHLOG_DIR:-$HOME}
27
28 # Check for some options used by this script
29 while [ "$#" -gt "0" ]
30 do
31     case "$1" in
32         --setlibdir)
33             LIBDIR="$2"
34             shift; shift
35             ;;
36         *)
37             shift
38             ;;
39     esac
40 done
41
42 single_stacktrace()
43 {
44   # core filename is either "core.$PID" or "core"
45   find "$1" -maxdepth $2 -name 'core*' | while read core; do
46       LC_ALL=C gdb --core="$core" --batch 2> /dev/null | grep -q "^Core was generated by \`$LIBDIR/xbmc/xbmc.bin" || continue
47       echo "=====>  Core file: "$core" ($(stat -c%y "$core"))" >> $FILE
48       echo "        =========================================" >> $FILE
49       gdb "$LIBDIR/xbmc/xbmc.bin" --core="$core" --batch -ex "thread apply all bt" 2> /dev/null >> $FILE
50       rm -f "$core"
51   done
52 }
53
54 print_crash_report()
55 {
56   FILE="$CRASHLOG_DIR/xbmc_crashlog-`date +%Y%m%d_%H%M%S`.log"
57   echo "############## XBMC CRASH LOG ###############" >> $FILE
58   echo >> $FILE
59   echo "################ SYSTEM INFO ################" >> $FILE
60   echo -n " Date: " >> $FILE
61   date >> $FILE
62   echo " XBMC Options: $*" >> $FILE
63   echo -n " Arch: " >> $FILE
64   uname -m >> $FILE
65   echo -n " Kernel: " >> $FILE
66   uname -rvs >> $FILE
67   echo -n " Release: " >> $FILE
68   if [ -f /etc/os-release ]; then
69           . /etc/os-release
70           echo $NAME $VERSION >> $FILE
71   elif which lsb_release > /dev/null; then
72     echo >> $FILE
73     lsb_release -a 2> /dev/null | sed -e 's/^/    /' >> $FILE
74   else
75     echo "lsb_release not available" >> $FILE
76   fi
77   echo "############## END SYSTEM INFO ##############" >> $FILE
78   echo >> $FILE
79   echo "############### STACK TRACE #################" >> $FILE
80   if which gdb >/dev/null 2>&1; then
81     if which systemd-coredumpctl &> /dev/null; then
82       systemd-coredumpctl dump -o core xbmc.bin &> /dev/null
83     fi
84     single_stacktrace "$PWD" 1
85     # Find in plugins directories
86     if [ $XBMC_HOME ]; then
87       BASEDIR=$XBMC_HOME
88     else
89       BASEDIR="$LIBDIR/xbmc/"
90     fi
91     single_stacktrace "$BASEDIR" 5
92     # find in user xbmc dir
93     single_stacktrace $HOME/.xbmc/ 5
94   else
95     echo "gdb not installed, can't get stack trace." >> $FILE
96   fi
97   echo "############# END STACK TRACE ###############" >> $FILE
98   echo >> $FILE
99   echo "################# LOG FILE ##################" >> $FILE
100   echo >> $FILE
101   if [ -f ~/.xbmc/temp/xbmc.log ]
102   then
103     cat ~/.xbmc/temp/xbmc.log >> $FILE
104     echo >> $FILE
105   else
106     echo "Logfile not found in the usual place." >> $FILE
107     echo "Please attach it seperately." >> $FILE
108     echo "Use pastebin.com or similar for forums or IRC." >> $FILE
109   fi
110   echo >> $FILE
111   echo "############### END LOG FILE ################" >> $FILE
112   echo >> $FILE
113   echo "############ END XBMC CRASH LOG #############" >> $FILE
114   echo "Crash report available at $FILE"
115 }
116
117 python @datadir@/xbmc/FEH.py $SAVED_ARGS
118 RET=$?
119 if [ $RET -ne 0 ]; then
120   exit $RET
121 fi
122
123 if which gdb >/dev/null 2>&1; then
124   # Output warning in case ulimit is unsupported by shell
125   eval ulimit -c unlimited
126   if [ ! $? = "0" ]; then
127     echo "xbmc: ulimit is unsupported by this shell" 1>&2
128   fi
129 fi
130
131 LOOP=1
132 while [ $(( $LOOP )) = "1" ]
133 do
134   LOOP=0
135   "$LIBDIR/xbmc/xbmc.bin" $SAVED_ARGS
136   RET=$?
137   if [ $(( $RET == 65 )) = "1" ]
138   then # User requested to restart app
139     LOOP=1
140   elif [ $(( ($RET >= 131 && $RET <= 136) || $RET == 139 )) = "1" ]
141   then # Crashed with core dump
142     print_crash_report
143   fi
144 done
145
146 exit $RET