File: check.in

package info (click to toggle)
linbot 0.8-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 140 kB
  • ctags: 5
  • sloc: sh: 602; makefile: 126; perl: 7
file content (236 lines) | stat: -rw-r--r-- 4,732 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#!/bin/sh
#
# source:
#   /var/cvs/projects/debian/dpkg.common/check.in,v
#
# revision:
#   @(#) check.in,v 1.6 1998/09/12 21:39:45 jplejacq Exp
#
# copyright:
#   Copyright (C) 1998 Jean Pierre LeJacq <jplejacq@quoininc.com>
#
#   Distributed under the GNU GENERAL PUBLIC LICENSE.
#
# synopsis:
#   check -p <DH_DOPACKAGES> -P <DH_TMPDIR>
#
# description:
#   Check binary packages.
#
#   This program is package independent and should work unmodified
#   with any package.
#
# bugs:
#   This program will recheck source package for each binary package.
#
#   The test for broken links in the HTML documentation requires that
#   the package be installed and that there is a URL
#   "http://localhost/doc/<pkg>/index.html".  I haven't found a
#   reliable way of checking without going through an HTTP which
#   requires that the files be installed ahead of time.
#
#   The check_parameterization is fool proof.



check_parameterization()
# global variables:
#   DH_TMPDIR
#
# postcondition:
#   Return 0 if no errors found, 1 otherwise.
#
# description:
#   Checks if any autoconf style parameterization variables are
#   unintentionally left in Debian files.
{
  local f
  local f_orig
  local found=0


  echo "${0}: checking binary package's files for parameterization variables..."

  for f in $(find ${DH_TMPDIR} -type f -print)
  do
    f_orig="${f}"

    if $(file "${f}" | egrep -q "gzip compressed")
    then
      # found a compressed file.

      f=$(tempfile --directory "/tmp" --mode 0660)
      zcat "${f_orig}" > "${f}"
    fi

    if $(file "${f}" | egrep -q "ELF|archive")
    then
      # found binary file.

      if $(strings "${f}" | egrep -q "@@.*@@")
      then
        echo "${0}: found parameterization variable in: ${f_orig}"
        found=1
      fi
    else
      # hopefully found a text file.

      if $(egrep -q "@@.*@@" "${f}")
      then
        echo "${0}: found parameterization variable in: ${f_orig}"
        found=1
      fi
    fi

    if [ "${f}" != "${f_orig}" ]
    then
      rm -f "${f}"
    fi
  done

  return ${found}
}


check_lintian()
# global variables:
#   DH_DOPACKAGES
#
# postconditions:
#   Return 0.
#
# description:
#   Check with lintian.
#
# bugs:
#   Only works for standard directory layout
{
  if [ -x "/usr/bin/lintian"  -a  ! -e "debian/scheme-opt" ]
  then
    echo "${0}: checking source package with lintian..."
      tmp=$(dpkg-parsechangelog | grep "Source: ")
      readonly pkg_src=${tmp#Source: }

      tmp=$(dpkg-parsechangelog | grep "Version: ")
      readonly version=${tmp#Version: }

      lintian -v --check --source ../${pkg_src}_${version}.dsc


    echo "${0}: checking binary package with lintian..."
      lintian -v --check --binary ../${DH_DOPACKAGES}_${version}_*.deb
  fi

  return 0
}


check_html_dtd()
# global variables:
#   DH_DOPACKAGES
#
# postconditions:
#   Return 0 on error, non-zero otherwise.
#
# description:
#   Check HTML for compliance to DTD.
{
  if [ -x "/usr/bin/nsgmls" ]
  then
    echo "${0}: checking binary package's HTML pages with nsgmls..."
      for file in\
        $(find debian/${DH_DOPACKAGES}.tmp -type f -name *.htm* -print)
      do
        nsgmls -s -m /usr/lib/sgml/catalog ${file}
      done
  fi

  return 0
}


check_html_style()
# global variables:
#   DH_DOPACKAGES
#
# postconditions:
#   Return 0 on error, non-zero otherwise.
#
# description:
#   Check HTML for compliance to weblint style checker.
{
  if [ -x "/usr/bin/weblint" ]
  then
    echo "${0}: checking binary package's HTML pages with weblint..."
      for file in\
        $(find debian/${DH_DOPACKAGES}.tmp -type f -name *.htm* -print)
      do
        weblint ${file}
      done
  fi
}


check_html_links()
# global variables:
#   DH_DOPACKAGES
#
# postconditions:
#   Return 0.
#
# description:
#   Check for broken links.
#
# bugs:
#   Only works when package is installed.
{
  local linbot_out
  local linbot_sh

  if [ -x "/usr/bin/linbot" ]
  then
    readonly linbot_sh="/usr/bin/linbot"
  elif [ -x "/opt/linbot/bin/linbot" ]
  then
    readonly linbot_sh="/opt/linbot/bin/linbot"
  fi

  if [ -n "${linbot_sh}" ]
  then
    echo "${0}: checking binary package's HTML links with linbot..."
      readonly linbot_out="debian/${DH_DOPACKAGES}.stamp-check-linbot"

      if [ ! -d "${linbot_out}" ]
      then
        mkdir "${linbot_out}"
      fi

      "${linbot_sh}"\
        -o "${linbot_out}"\
        -b\
        "http://localhost/doc/${DH_DOPACKAGES}/"
  fi

  return 0
}



# main:
  set -e


  echo "${0}: parsing arguments..."
    PATH=debian:${PATH}:/usr/lib/debhelper

    . /usr/lib/debhelper/dh_lib


  check_parameterization
  check_lintian
  check_html_dtd
  check_html_style
  check_html_links


  exit 0