File: check_msword_import.sh

package info (click to toggle)
calligra 1%3A2.9.11%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 189,332 kB
  • sloc: cpp: 919,806; xml: 27,759; ansic: 10,472; python: 8,190; perl: 2,724; yacc: 2,557; sh: 1,675; lex: 1,431; java: 1,304; sql: 903; ruby: 734; makefile: 48
file content (89 lines) | stat: -rwxr-xr-x 2,193 bytes parent folder | download | duplicates (13)
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
#!/bin/bash
if ! kde4-config ; then
  echo 'kde4-config not found ! Aborting. You need a more recent KDE, or to fix your $PATH.'
  exit 1
fi
IFS=:

echo -n "KDE prefixes: "
kde4-config --prefix

# Check for the binary
found=0
exedirs=`kde4-config --path exe`
for dir in $exedirs; do
  if [ -f "$dir/words" ]; then
    echo "words found in $dir"
    found=1
  fi
done

if [ $found -eq 0 ]; then
    echo "ERROR: words not found - looked at $exedirs"
fi

mimelnks=`kde4-config --path mime`
# Relevant existing mimetypes
mimes=""

for dir in $mimelnks; do
  filename="application/msword.desktop"
  if [ -f "$dir$filename" ]; then
      echo -n "Found: $dir$filename... "
      hidden=`grep ^Hidden $dir$filename`
      if [ "$hidden" == "true" ]; then
          echo "deleted";
      else
          mimetype=`grep ^MimeType $dir$filename|sed -e 's/.*=//'`
          mimes="$mimes:$mimetype"; # using ':' because of IFS
          patterns=`grep ^Patterns $dir$filename|sed -e 's/.*=//'`
          if [ -n "$patterns" ]; then
              echo -n "(associated with $patterns)"
          fi
          echo
      fi
  fi
  filename="application/msword2.desktop"
  if [ -f "$dir$filename" ]; then
      echo -n "Found: $dir$filename... "
      hidden=`grep ^Hidden $dir$filename`
      if [ "$hidden" == "true" ]; then
          echo "deleted";
      else
          mimetype=`grep ^MimeType $dir$filename|sed -e 's/.*=//'`
          mimes="$mimes:$mimetype"; # using ':' because of IFS
          patterns=`grep ^Patterns $dir$filename|sed -e 's/.*=//'`
          if [ -n "$patterns" ]; then
              echo -n "(associated with $patterns)"
          fi
          echo
      fi
  fi
done

IFS=" "
mimes=`echo $mimes | sed -e 's/^://g'`
echo "Relevant mimetypes found: $mimes"

IFS=:
foundmagicfile=0
for dir in $mimelnks; do
  magic=$dir/magic
  if [ -f "$magic" ]; then
    echo "$magic says: "
    grep 'Microsoft\\ Word' $magic
    foundmagicfile=1
  fi
done

if [ $foundmagicfile -eq 0 ]; then
    echo "ERROR: Magic file not found $magic"
fi

for dir in `kde4-config --path services`; do
  echo Services dir $dir
  for mime in $mimes; do
     grep "Import=.*$mime" $dir/*.desktop
  done
done