aboutsummaryrefslogtreecommitdiff
path: root/lt-qcom-ubuntu-images.yaml
blob: e5cfb4263ee5983effa0c3ff3e60b8b5018b0666 (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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
- job:
    name: lt-qcom-ubuntu-images
    project-type: freestyle
    defaults: global
    logrotate:
        daysToKeep: 30
        numToKeep: 30
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
                - job-workspace
    parameters:
        - password:
            name: PUBLISH_KEY
            default: ${PUBLISH_KEY}
        - file:
            name: lt-qcom-ubuntu-images_parameters
        - string:
            name: UBUNTU_FLAVOUR
            default: 'utopic'
        - string:
            name: PLATFORM_NAME
            default: 'qcom-snapdragon'
        - string:
            name: ROOTFS
            default: 'developer gnome'
    disabled: false
    node: precise_cloud
    display-name: 'Qualcomm Ubuntu based images'
    wrappers:
        - timestamps
        - copy-to-slave:
            includes:
                - linaro-cp.py
            relative-to: userContent
    builders:
        - copyartifact:
            project: LT-QCOM-working-tree
            flatten: true
            optional: true
        - shell: |
            #!/bin/bash

            set -e

            trap cleanup_exit INT TERM EXIT

            cleanup_exit()
            {
              cd ${WORKSPACE}
            # MOVED TEMPORARY
            #  sudo rm -rf binary out qcom-firmware
              rm -f linaro-${UBUNTU_FLAVOUR}-*.tar.gz *.dtb *.deb
            }

            sudo rm -rf binary out qcom-firmware initrd.img-*

            # added KERNEL_FLAVOUR to filter out -dbg package when CONFIG_DEBUG_INFO is set
            linux_image=`ls linux-image-*-linaro-${KERNEL_FLAVOUR}_*-linaro-${KERNEL_FLAVOUR}-*.deb`
            version=`date +%Y%m%d`-${BUILD_NUMBER}

            cat > README.txt << EOF
            This build is using artifacts from the following builds:
            Kernel build: ${KERNEL_BUILD_JENKINS}
            EOF


            for rootfs in ${ROOTFS}; do
              # Remove artifacts from previous builds
              sudo rm -f linaro-${UBUNTU_FLAVOUR}-${rootfs}*
              sudo rm -rf binary

              # Get rootfs
              export ROOTFS_BUILD_NUMBER=`wget -q --no-check-certificate -O - https://ci.linaro.org/jenkins/job/ubuntu-armhf-rootfs/label=build,rootfs=${rootfs}/lastSuccessfulBuild/buildNumber`
              export ROOTFS_BUILD_TIMESTAMP=`wget -q --no-check-certificate -O - https://ci.linaro.org/jenkins/job/ubuntu-armhf-rootfs/label=build,rootfs=${rootfs}/lastSuccessfulBuild/buildTimestamp?format=yyyyMMdd`
              export ROOTS_BUILD_URL="http://snapshots.linaro.org/ubuntu/images/${rootfs}/${ROOTFS_BUILD_NUMBER}/linaro-${UBUNTU_FLAVOUR}-${rootfs}-${ROOTFS_BUILD_TIMESTAMP}-${ROOTFS_BUILD_NUMBER}.tar.gz"
              wget --progress=dot -e dotbytes=2M ${ROOTS_BUILD_URL} -O linaro-${UBUNTU_FLAVOUR}-${rootfs}.tar.gz

              case "${rootfs}" in
                developer)
                  # Create initrd using the -developer rootfs
                  # once initrd is finished, we clean up to avoid left-over from schroot
                  sudo tar --numeric-owner -zxf linaro-${UBUNTU_FLAVOUR}-${rootfs}.tar.gz
                  sudo cp -a ${linux_image} binary/

                  schroot -c ifc6410-lt -d / -u root -- dpkg -i ${linux_image}
                  cp -a binary/boot/initrd.img-* .
                  sudo rm -rf binary
                  ;;
              esac

              # now, we are ready to make the final rootfs
              sudo tar --numeric-owner -zxf linaro-${UBUNTU_FLAVOUR}-${rootfs}.tar.gz

              # for both -dev and -gnome, other in -gnome date is not correct at boot. probably an 
              # issue to investigate with ntp/ntpdate/network-manager
              cat << EOF | sudo tee -a binary/etc/network/interfaces

            auto lo
            iface lo inet loopback

            auto eth0
            iface eth0 inet dhcp
            EOF

              # Inject kernel modules
              sudo dpkg-deb -x ${linux_image} binary/
              sudo find binary/boot -type f -delete
              sudo rm -f binary/linux-image-*.deb

              sudo rm -rf binary/dev
              sudo mkdir binary/dev
              sudo mkdir -p binary/lib/firmware

              cat << EOF | sudo tee -a binary/etc/fstab
            LABEL=qcom-firmware /lib/firmware ext4 defaults 0 0
            EOF

              # Generate sparse image to reduce .img file size
              sudo make_ext4fs -o -L rootfs -l 2G -s linaro-${UBUNTU_FLAVOUR}-${rootfs}-${PLATFORM_NAME}-${version}.img binary/
              gzip -9 linaro-${UBUNTU_FLAVOUR}-${rootfs}-${PLATFORM_NAME}-${version}.img

              cat >> README.txt << EOF
            Linaro Ubuntu ${rootfs} build: http://snapshots.linaro.org/ubuntu/images/${rootfs}/${ROOTFS_BUILD_NUMBER}
            EOF

            done

            # create the boot partition
            cat > bootimg.cfg << EOF
            bootsize = 0x900000
            pagesize = 0x800
            kerneladdr = 0x80208000
            ramdiskaddr = 0x83000000
            secondaddr = 0x81100000
            tagsaddr = 0x80200100
            name = linaro-${PLATFORM_NAME}
            cmdline = console=tty0 console=${KERNEL_SERIAL_CONSOLE} root=/dev/mmcblk0p13 rootwait rw text
            EOF

            # create one boot image for each DTB we have around, since we need to append DTB to zImage
            # fixup.bin used to fixup loader to boot mainline on Qualcomm platforms that needs adjustment of
            # ATAG MEM.
            for f in `find . -maxdepth 1 -name '*.dtb' -print` ; do
              target=`basename $f .dtb`
              if [ -f fixup-$target.bin ]; then
                cat fixup-$target.bin zImage $f > zImage-dtb
              else
                  cat zImage $f > zImage-dtb
              fi
              abootimg --create boot-${target}-${PLATFORM_NAME}-${version}.img -f bootimg.cfg -k zImage-dtb -r initrd.img-*
              gzip -9 boot-${target}-${PLATFORM_NAME}-${version}.img 
            done

            # create an empty partition, placeholder for proprietary firmware
            # do no create sparse file, so that the file can be easily loop mounted
            rm -rf qcom-firmware firmware-${PLATFORM_NAME}.img
            fakeroot mkdir qcom-firmware
            fakeroot make_ext4fs -L qcom-firmware -l 64M firmware-${PLATFORM_NAME}-${version}.img qcom-firmware/
            gzip -9 firmware-${PLATFORM_NAME}-${version}.img 

            # Publish to snapshots
            mkdir out
            sudo mv *.cfg *.img.gz *.deb zImage kernel_config README.txt `find . -maxdepth 1 -name 'fixup-*.bin' -print`  out/

            # create MD5SUMS file
            (cd out && md5sum * > MD5SUMS.txt)

            python ${WORKSPACE}/linaro-cp.py out ubuntu/pre-built/snapdragon/${BUILD_NUMBER}
        - shell: |
            VERSION=`date +%Y%m%d`-${BUILD_NUMBER}

            export BOOT_URL=${BUILD_URL}/artifact/out/boot-qcom-apq8064-ifc6410-${PLATFORM_NAME}-${VERSION}.img.gz
            export DATA_URL=${BUILD_URL}/artifact/out/linaro-${UBUNTU_FLAVOUR}-developer-${PLATFORM_NAME}-${VERSION}.img.gz
            export SYSTEM_URL=${BUILD_URL}/artifact/out/firmware-${PLATFORM_NAME}-${VERSION}.img.gz

            export DEVICE_TYPE=ifc6410
            export BUNDLE_STREAM_NAME=/public/team/linaro/lt-qualcomm/
            export LAVA_SERVER=validation.linaro.org/RPC2/

            rm -rf configs lci-build-tools
            git clone --depth 1 http://git.linaro.org/ci/lci-build-tools.git
            git clone --depth 1 http://git.linaro.org/ci/job/configs.git
            ./lci-build-tools/yaml-to-json.py configs/lt-qcom-ubuntu-images/lava-job-definitions/${DEVICE_TYPE}/template.yaml > custom_lava_job_definition.json

            cat << EOF > post_build_lava_parameters
            DEVICE_TYPE=${DEVICE_TYPE}
            BUNDLE_STREAM_NAME=${BUNDLE_STREAM_NAME}
            CUSTOM_JSON_URL=${JOB_URL}/ws/custom_lava_job_definition.json
            LAVA_SERVER=${LAVA_SERVER}
            EOF
        - trigger-builds:
            - project: 'post-build-lava'
              property-file: post_build_lava_parameters
    publishers:
        - archive:
            artifacts: 'out/*'
            latest-only: true
        - email:
            recipients: 'nicolas.dechesne@linaro.org fathi.boudra@linaro.org'
        - ircbot:
            channels:
                - name: '#linaro-lt-qcomm'
                  password: ${LT_QCOM_KEY}