Warning, file /plasma/drkonqi/src/doc/examples/installdbgsymbols_debian.sh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 #!/bin/sh 0002 # 0003 # SPDX-FileCopyrightText: 2009 George Kiagiadakis <kiagiadakis.george@gmail.com> 0004 # 0005 # SPDX-License-Identifier: GPL-2.0-or-later 0006 0007 0008 # This function runs a command in a terminal 0009 # The first argument ($1) must be the full command to run. 0010 # It returns 0 if the command finished or 1 if the user closed 0011 # the terminal without waiting for the command to finish. 0012 # The return value of the command is saved in the $exit_status variable. 0013 run_in_terminal() 0014 { 0015 local fifo=/tmp/drkonqi-fifo-$$ 0016 mkfifo $fifo 0017 0018 # start terminal 0019 x-terminal-emulator -e sh -c "echo \$\$ > $fifo; $1; exit_status=\$?; sleep 1; rm $fifo; echo \$exit_status > $fifo" & 0020 0021 # wait for it to finish 0022 local pid=`cat $fifo` 0023 while [ "$?" = "0" ]; do 0024 sleep 1 0025 kill -0 $pid 2>/dev/null 0026 done 0027 0028 # check if terminal has finished succesfully and return the command's exit status 0029 local canceled=0 0030 if [ -p $fifo ]; then 0031 # terminal was closed before finishing execution 0032 canceled=1 0033 else 0034 exit_status=`cat $fifo` 0035 #echo "\"$1\" returned: $exit_status" 0036 fi 0037 rm $fifo 0038 return $canceled 0039 } 0040 0041 # check for availability of kdialog 0042 which kdialog >/dev/null 0043 if [ "$?" != "0" ]; then 0044 xmessage -center "Could not find kdialog (part of kdebase). Please install kdialog and try again." 0045 exit 1 0046 fi 0047 0048 # check misc script dependencies 0049 check_dep() 0050 { 0051 which $1 >/dev/null 0052 if [ "$?" != "0" ]; then 0053 kdialog --sorry "$1 was not found on your system. Please install $1 and try again." 0054 exit 1 0055 fi 0056 } 0057 0058 check_dep apt-file 0059 check_dep qdbus 0060 0061 # update apt-file database 0062 run_in_terminal "apt-file update" 0063 0064 if [ "$?" = "1" ]; then 0065 exit 3 0066 elif [ "$exit_status" != "0" ]; then 0067 kdialog --sorry "apt-file failed to update package lists." 0068 exit 1 0069 fi 0070 0071 # start searching for packages 0072 packages="" 0073 progress_counter=0 0074 dbus_handle=`kdialog --progressbar "Searching for packages that contain the requested debug symbols..." $#` 0075 0076 while [ "$1" != "" ]; 0077 do 0078 # dereference symlinks 0079 cur_file=$1 0080 while [ -L "$cur_file" ]; do 0081 cur_file="`dirname $cur_file`/`ls -l $cur_file | cut -d ' ' -f 10`" 0082 done 0083 0084 # look for the package 0085 expr match "$cur_file" ".*libQt.*" >/dev/null 0086 if [ "$?" = "0" ]; then 0087 # HACK for Qt, which doesn't install debug symbols in /usr/lib/debug like everybody else 0088 package="libqt4-dbg" 0089 else 0090 package=`apt-file search --non-interactive --package-only --fixed-string "/usr/lib/debug$cur_file"` 0091 fi 0092 packages="$packages $package" 0093 0094 # update progress dialog 0095 progress_counter=$(($progress_counter+1)) 0096 qdbus $dbus_handle Set org.kde.kdialog.ProgressDialog value $progress_counter 0097 0098 # check if dialog was closed 0099 if [ "$?" != "0" ]; then 0100 exit 3 0101 fi 0102 0103 shift 0104 done 0105 0106 # filter out duplicates 0107 packages=`echo "$packages" | tr " " "\n" | sort | uniq | tr "\n" " "` 0108 0109 # close the progress dialog 0110 qdbus $dbus_handle close 0111 0112 # if there are no packages to install, exit 0113 trimmed_packages=`echo $packages | tr -d "[:blank:]"` 0114 if [ -z "$trimmed_packages" ]; then 0115 exit 2 # note that we don't need to display an error message here. drkonqi will do it for us. 0116 fi 0117 0118 kdialog --yesno "You need to install the following packages: $packages 0119 Would you like drkonqi to attempt to install them now?" 0120 0121 if [ "$?" = "0" ]; then 0122 # determine package manager 0123 package_manager=aptitude 0124 which $package_manager >/dev/null 0125 if [ "$?" != "0" ]; then 0126 package_manager=apt-get 0127 fi 0128 0129 run_in_terminal "su-to-root -c '$package_manager install $packages'" 0130 0131 if [ "$?" = "1" ]; then 0132 exit 3 0133 elif [ "$exit_status" = "0" ]; then 0134 exit 0 0135 else 0136 exit 1 0137 fi 0138 else 0139 exit 3 0140 fi