File indexing completed on 2024-05-12 16:28:27

0001 #!/bin/bash
0002 if ! kde4-config ; then
0003   echo 'kde4-config not found ! Aborting. You need a more recent KDE, or to fix your $PATH.'
0004   exit 1
0005 fi
0006 
0007 instance=words
0008 applnks=`kde4-config --path apps`:`kde4-config --path xdgdata-apps`
0009 services=`kde4-config --path services`
0010 found=0
0011 
0012 function checkname()
0013 {
0014   f=`echo $1 | sed -e 's,//,/,g'`
0015   if [ -f $f ]; then
0016     echo -n "Found: $f... "
0017     mimetypes=`grep ^MimeType $f|sed -e 's/.*=//;s/;/,/g;'`
0018     servicetypes=`grep ^ServiceTypes $f|sed -e 's/.*=//;s/$/,/g'`
0019     fulllist="$mimetypes,$servicetypes"
0020     if echo $fulllist | grep "Calligra/Part," >/dev/null 2>/dev/null; then
0021       echo "ok, this is a Calligra/Part"
0022     else
0023       echo '**** Calligra/Part not in list of types !'
0024       echo Service Types: $fulllist
0025       cat $f
0026       exit 1
0027     fi
0028     nativemime=`grep X-KDE-NativeMimeType $f`
0029     echo Native mimetype : $nativemime
0030     if echo $nativemime | grep "application/x-$instance" >/dev/null 2>/dev/null; then
0031       found=1
0032     fi
0033   fi
0034 }
0035 
0036 IFS=:
0037 for dir in $services; do
0038   if test -n "$dir"; then
0039     echo Looking for ${instance}part.desktop under services dir: $dir
0040     f="$dir/${instance}part.desktop"
0041     checkname $f
0042   fi
0043 done
0044 
0045 if [ $found = 0 ]; then
0046   # The old way, as fallback
0047   for dir in $applnks; do
0048     if test -n "$dir"; then
0049       echo Looking under applnk dir: $dir
0050       f="$dir/Office/$instance.desktop"
0051       checkname $f
0052     fi
0053   done
0054 fi
0055 
0056 if [ $found = 0 ]; then
0057   echo
0058   echo Now looking by filename
0059   echo
0060 
0061   for dir in $applnks; do
0062     if test -n "$dir"; then
0063       echo Looking under applnk dir: $dir
0064       for f in `find $dir -name $instance.desktop`; do
0065         checkname $f
0066       done
0067     fi
0068   done
0069 fi
0070 
0071 if [ $found = 0 ]; then
0072   echo "***** No $instance.desktop with X-KDE-NativeMimetype in it was found! Installation problem."
0073   echo $applnks
0074 fi
0075 
0076 echo
0077 
0078 stfound=0
0079 for dir in `kde4-config --path servicetypes`; do
0080   echo Service Types dir $dir
0081   f=`echo $dir/calligra_part.desktop | sed -e 's,//,/,g'`
0082   if [ -f $f ]; then
0083     echo Found $f
0084     grep Native $f
0085     stfound=1
0086   fi
0087 done
0088 
0089 if [ $stfound = 0 ]; then
0090   echo '****** calligra_part.desktop not found!'
0091   kde4-config --path servicetypes
0092 else
0093   echo
0094   if [ $found = 1 ]; then
0095     echo "Everything looks ok"
0096   fi
0097 fi
0098