~canonical-ci-engineering/pbuilderjenkins/unity8-hooks

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
#!/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
# XXX - fginther 20150617
# devscripts 2.15.5 is broken
# https://bugs.launchpad.net/ubuntu/+source/devscripts/+bug/1466098
# Install 2.15.4 while running this script, remove it when it's done
apt-get install wget
ARCH=$(dpkg --print-architecture)
wget http://10.100.0.4:8080/userContent/packages/devscripts/devscripts_2.15.4_${ARCH}.deb
dpkg -i devscripts_2.15.4_${ARCH}.deb
rm devscripts_2.15.4_${ARCH}.deb

includefiles="\.(c(c|pp|xx)?|h(h|pp|xx)?|p(l|m)|php|py(|x)|java|js|vala|qml)$"
excludedirs="(3rd_party|_build)"
allowedlicenses="(Canonical|Android|Google|Digia|Jolla|GENERATED)"

issuescount=`licensecheck --noconf -r * --copyright -m -c $includefiles -i $excludedirs | egrep -v $allowedlicenses | wc -l`

if [ $issuescount -eq 0 ]; then
    echo No license problems found.

    # Revert to the current version of devscripts for the rest of the build
    apt-get install --yes devscripts
    exit 0
else
    echo Found $issuescount license problems:
    # Run it a second time to print a nice list of issues
    licensecheck --noconf -r * --copyright -m -c $includefiles -i $excludedirs | egrep -v $allowedlicenses

    # Revert to the current version of devscripts for the rest of the build
    apt-get install --yes devscripts
    exit 1
fi