aboutsummaryrefslogtreecommitdiff
path: root/build-package-test.yaml
blob: 1b6e4a6304fba516ffeb0ba83d53a56b6ab11682 (plain)
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
- job:
    name: build-package-test
    project-type: matrix
    defaults: global
    logrotate:
        daysToKeep: 30
        numToKeep: 30
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            linaro:
                - job-read
                - job-configure
                - job-delete
                - job-extended-read
                - job-build
                - job-cancel
        - least-load:
            disabled: False
    parameters:
        - string:
            name: codename
            default: 'jessie'
            description: 'distribution codename targeted: vivid, utopic or jessie'
        - string:
            name: source
            description: 'dsc source url or filename'
        - string:
            name: repo
            description: 'repository to upload to'
            default: 'linaro-staging'
        - bool:
            name: appendversion
            description: 'append version with linaro$dist'
            default: 'true'
    axes:
        - axis:
            type: slave
            name: label
            values:
                - docker-jessie-amd64
                - docker-jessie-arm64
                - docker-jessie-armhf
    execution-strategy:
        sequential: false
    disabled: false
    display-name: 'Build package'
    wrappers:
        - timestamps
        - build-name:
            name: '#${BUILD_NUMBER}-${ENV,var="codename"}: ${ENV,var="source"}'
        - matrix-tie-parent:
            node: master
    builders:
        - shell: |
            #!/bin/bash

            set -e
            cat > repo.parameters << EOF
            build_success=false
            pkg_job_url=${JOB_URL}
            EOF

            arch=`dpkg-architecture -qDEB_HOST_ARCH`
            dist=`lsb_release -sc`
            if [ "$dist" != "$codename" ]
            then
                echo "$codename requested while we are $dist, skip"
                exit 0
            fi
            # arm64 is the must build target with source uploads for all dists
            if [ $arch = arm64 ]
            then
                buildpackage_params="-sa"
            else
                buildpackage_params="-B"
            fi
            [ $arch = armhf ] && personality=linux32

            echo "arch: $arch"
            echo "dist: $dist"
            echo "source: $source"
            echo "repo: $repo"
            echo "appendversion: $appendversion"

            sudo rm -f *.changes repo work /etc/apt/sources.list.d/local.list
            # build a source repo for apt-get build-dep
            mkdir repo && cd repo
            dget -q -d -u $source
            dpkg-scansources . /dev/null > Sources.gz
            echo "deb-src file:$(pwd) /" > local.list
            echo "deb http://repo.linaro.org/ubuntu/linaro-overlay ${dist} main" >> local.list
            if [ "${repo}" != "linaro-overlay" ]; then
                echo "deb http://repo.linaro.org/ubuntu/${repo} ${dist} main" >> local.list
            fi
            sudo cp local.list /etc/apt/sources.list.d/
            if [ "$dist == jessie" ]
            then
               cat > backports.pref <<EOF
            Package: *
            Pin: release a=jessie-backports
            Pin-Priority: 500
            EOF
               sudo cp backports.pref /etc/apt/preferences.d/
            fi
            cd ..
            localdsc=`echo $source|sed -e "s,.*/,$(pwd)/repo/,"`
            sourcename=`basename ${localdsc}|sed -e 's,_.*,,'`

            dpkg-source -x ${localdsc} work/
            # Verify entries
            cd work
            dpkg-parsechangelog
            maint=`dpkg-parsechangelog -SMaintainer`
            if [[ $maint != *linaro* ]]; then
               echo "Error, not a linaro maintainer: $maint"
               exit 1
            fi
            echo email=$maint >> repo.parameters
            change=`dpkg-parsechangelog -SChanges`
            case $change in
                *Initial*release*)
                    deltatype="new package"
                    ;;
                *Backport*from*)
                    deltatype="backport"
                    ;;
                *Added*patch*)
                    deltatype="patched"
                    ;;
                *Upstream*snapshot*)
                    deltatype="snapshot"
                    ;;
                *HACK*)
                    deltatype="hack"
                    ;;
                *)
                    deltatype="other"
                    ;;
            esac
            # Changelog update
            if [ "$appendversion" = "true" ]; then
               dch --force-distribution -m -D $dist -llinaro$dist "Linaro CI build: $deltatype"
            elif [ `dpkg-parsechangelog -SDistribution` != $dist ]
               echo "wrong distribution in changelog, setting to: $dist"
               dch --force-distribution -m -D $dist -a "Linaro CI: set distribution to $dist"
            fi
            
            export DEBIAN_FRONTEND=noninteractive
            sudo apt-get update -q||true
            sudo apt-get install -q --no-install-recommends -y build-essential fakeroot
            sudo apt-get build-dep -q --no-install-recommends -y ${sourcename}

            $personality dpkg-buildpackage -rfakeroot -j`getconf _NPROCESSORS_ONLN` $buildpackage_params
            cd ..

            ls -l .
            change=`echo *changes`
            if [ ! -r $change ]
            then
                echo "no changes file"
                exit 1
            else
                cat $change
            fi
            exit 0 # avoid uploads during testing
            cat > repo.parameters << EOF
            build_success=true
            pkg_job_name=${JOB_NAME}
            key_id=B86C70FE
            pkg_changes=${change}
            host_ppa=${repo}
            pkg_job_url=${JOB_URL}
            email=$maint
            EOF
    publishers:
        - copy-to-master:
            includes:
                - '*.changes, *.dsc, *.gz, *.bz2, *.xz, *.deb, *.udeb, repo.parameters'
        - trigger-parameterized-builds:
            - project: post-build-repo
              property-file: "label/docker-${codename}-arm64/repo.parameters"
            - project: post-build-repo
              property-file: "label/docker-${codename}-armhf/repo.parameters"
            - project: post-build-repo
              property-file: "label/docker-${codename}-amd64/repo.parameters"
        - email:
            recipients: 'riku.voipio@linaro.org'