summaryrefslogtreecommitdiffstats
path: root/tools/scripts/check_koffice_install.sh
blob: 8f7cf4f2eedd76301e2bcca34ec17a2ad07f5a51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
if ! tde-config ; then
  echo 'tde-config not found ! Aborting. You need a more recent KDE, or to fix your $PATH.'
  exit 1
fi

instance=kword
applnks=`tde-config --path apps`:`tde-config --path xdgdata-apps`
services=`tde-config --path services`
found=0

function checkname()
{
  f=`echo $1 | sed -e 's,//,/,g'`
  if [ -f $f ]; then
    echo -n "Found: $f... "
    mimetypes=`grep ^MimeType $f|sed -e 's/.*=//;s/;/,/g;'`
    servicetypes=`grep ^ServiceTypes $f|sed -e 's/.*=//;s/$/,/g'`
    fulllist="$mimetypes,$servicetypes"
    if echo $fulllist | grep "KOfficePart," >/dev/null 2>/dev/null; then
      echo "ok, this is a KOfficePart"
    else
      echo '**** KOfficePart not in list of types !'
      echo Service Types: $fulllist
      cat $f
      exit 1
    fi
    nativemime=`grep X-TDE-NativeMimeType $f`
    echo Native mimetype : $nativemime
    if echo $nativemime | grep "application/x-$instance" >/dev/null 2>/dev/null; then
      found=1
    fi
  fi
}

IFS=:
for dir in $services; do
  if test -n "$dir"; then
    echo Looking for ${instance}part.desktop under services dir: $dir
    f="$dir/${instance}part.desktop"
    checkname $f
  fi
done

if [ $found = 0 ]; then
  # The old way, as fallback
  for dir in $applnks; do
    if test -n "$dir"; then
      echo Looking under applnk dir: $dir
      f="$dir/Office/$instance.desktop"
      checkname $f
    fi
  done
fi

if [ $found = 0 ]; then
  echo
  echo Now looking by filename
  echo

  for dir in $applnks; do
    if test -n "$dir"; then
      echo Looking under applnk dir: $dir
      for f in `find $dir -name $instance.desktop`; do
        checkname $f
      done
    fi
  done
fi

if [ $found = 0 ]; then
  echo "***** No $instance.desktop with X-TDE-NativeMimetype in it was found! Installation problem."
  echo $applnks
fi

echo

stfound=0
for dir in `tde-config --path servicetypes`; do
  echo Service Types dir $dir
  f=`echo $dir/kofficepart.desktop | sed -e 's,//,/,g'`
  if [ -f $f ]; then
    echo Found $f
    grep Native $f
    stfound=1
  fi
done

if [ $stfound = 0 ]; then
  echo '****** kofficepart.desktop not found!'
  tde-config --path servicetypes
else
  echo
  if [ $found = 1 ]; then
    echo "Everything looks ok"
  fi
fi