File: pycheck

package info (click to toggle)
regina-normal 4.3.1-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 16,396 kB
  • ctags: 7,338
  • sloc: cpp: 55,359; sh: 17,392; ansic: 12,913; perl: 3,294; makefile: 918; python: 114
file content (110 lines) | stat: -rw-r--r-- 3,048 bytes parent folder | download
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
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
#
# Python version checker for Regina.
#
# Ensures that python versions are consistent between the binaries
# (specifically, the compiled python module regina.so), the
# regina-python startup script, and the debian control file.
#
# For use during the final stage of the debian package build.
#
set -e

tmp=debian/tmp
control=debian/control
python_script=/usr/bin/regina-python
python_script_src=python/regina-python
python_lib=/usr/lib/regina-normal/python/regina.so

echo "Checking python versions..."

pyver_script=`grep 'python[0-9]\.[0-9]' $tmp$python_script | \
  sed -e 's/^.*python\([0-9]\.[0-9]\).*$/\1/'`

pyver_lib=`ldd $tmp$python_lib | grep 'libpython[0-9]\.[0-9]\.so' | \
  sed -e 's/^.*libpython\([0-9]\.[0-9]\).so.*$/\1/'`

pyver_control_src=`grep ^XS-Python-Version $control | \
  sed -e 's/^XS-Python-Version: //'`

pyver_control_bin=`grep ^XB-Python-Version $control | \
  sed -e 's/^XB-Python-Version: //'`

case "$pyver_script" in
  ?.? )
    # Okay; we expect something of the form X.Y.
    ;;
  * )
    echo "ERROR: Could not determine the python version used in $python_script."
    exit 1
    ;;
esac

case "$pyver_lib" in
  ?.? )
    # Okay; we expect something of the form X.Y.
    ;;
  * )
    echo "ERROR: Could not determine the python version used in $python_lib."
    exit 1
    ;;
esac

case "$pyver_control_src" in
  ?.? )
    # Okay; we expect something of the form X.Y.
    ;;
  * )
    echo "ERROR: Could not determine the XS-Python-Version specified in $control."
    exit 1
    ;;
esac

case "$pyver_control_bin" in
  ?.? )
    # Okay; we expect something of the form X.Y.
    ;;
  * )
    echo "ERROR: Could not determine the XB-Python-Version specified in $control."
    exit 1
    ;;
esac

if ! test "$pyver_script" = "$pyver_lib"; then
  echo
  echo "ERROR: Mismatched python versions between binaries and startup script."
  echo
  echo "       $python_script uses python$pyver_script."
  echo "       $python_lib uses python$pyver_lib."
  echo
  echo "       This can be fixed in the sources by changing the python version "
  echo "           number in $python_script_src and $python_script_src.in"
  echo "           (find the section where \$which_python is initialised)."
  exit 1
fi

if ! test "$pyver_lib" = "$pyver_control_src"; then
  echo
  echo "ERROR: Mismatched python versions between binaries and $control."
  echo
  echo "       $python_lib uses python$pyver_lib."
  echo "       $control (source) specifies python$pyver_control."
  echo
  echo "       This can be fixed in the sources by changing the"
  echo "           XS-Python-Version field in $control."
  exit 1
fi

if ! test "$pyver_lib" = "$pyver_control_bin"; then
  echo
  echo "ERROR: Mismatched python versions between binaries and $control."
  echo
  echo "       $python_lib uses python$pyver_lib."
  echo "       $control (binary) specifies python$pyver_control."
  echo
  echo "       This can be fixed in the sources by changing the"
  echo "           XB-Python-Version field in $control."
  exit 1
fi

exit 0