~private-ps-quality-team/pbuilderjenkins/trunk

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
#!/bin/bash -e

# We cannot use whole build_result_path_logic in A-hooks as the build and the
# result directories do not necessesarily exist yet. We only need the WORK dir
# in A-hooks anyways, so lets do that part on our own.

# WORK_DIR contains the root of the package, debian must be a sub-dir
if [ -z "$WORK_DIR" ]; then
    WORK_DIR=$(readlink -f /tmp/buildd/*/debian/..)
    if ! [ -d "$WORK_DIR" ]; then
        WORK_DIR=""
    fi
fi
test -d "$WORK_DIR"

cd $WORK_DIR

# Make sure devscripts is installed
apt-get install --yes devscripts

# Pat: As a result of the question about the html theme and the core
# apps, legal has revised the text for code contributed under the CLA,
# the key part is the additional line regarding license grant
#
# Copyright 2013 [Copyright holder (contributor)]
# License granted by Canonical Limited
#

includefiles="\.(c(c|pp|xx)?|h(h|pp|xx)?|p(l|m)|php|py(|x)|java|js|vala|qml)$"
notallowed="(No copyright|UNKNOWN)"
# TODO: required="(License granted by Canonical Limited)"
issuescount=`licensecheck --noconf -r * --copyright -m -c $includefiles | {{ egrep "$notallowed" || true; }} | wc -l`

if [ $issuescount -eq 0 ]; then
    echo No license problems found.
    exit 0
else
    echo Found $issuescount license problems:
    licensecheck --noconf -r * --copyright -m -c $includefiles | {{ egrep "$notallowed" || true; }}
    exit 1
fi