summaryrefslogtreecommitdiff
path: root/pipelines/debian.ick
blob: 0e62ae44f2ccc9a8d5578191835e79ff76fcf82b (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
# Lars Wirzenius.
# 
# Feel free to use this as you wish. It is simple enough that it is
# probably not even copyrightable.

pipelines:

  # Install APT signing keys from the apt_signing_pub_keys parameter.
  # The parameter should contain a dict, where each item is the name
  # of a signing key, and is used as the filename in
  # /etc/apt/trusted.gpg.d. The dict value is the actual public key,
  # in gpg --export --armore format.

  - pipeline: ick/add_apt_signing_keys
    parameters:
      - apt_signing_pub_keys
    actions:
      - python: |
          for name, key in params['apt_signing_pub_keys'].items():
            filename = '/etc/apt/trusted.gpg.d/{}.asc'.format(name)
            print('Writing key to', filename)
            with open(filename, 'w') as f:
              f.write(key)
        where: container

  # Install APT sources listed in the parameter apt_sources by
  # creating /etc/apt/sources.list.d/ick_apt_sources.list from the
  # list. Each list item must be a dict with fields url, codename,
  # section. For example:
  #
  #     apt_sources:
  #     - url: deb.example.com
  #       dist: unstable
  #       section: main
  #       key: CAFEBEEF
  #     - url: deb.example.com
  #       dist: unstable
  #       section: contrib
  #       key: CAFEBEEF

  - pipeline: ick/add_apt_sources
    parameters:
      - apt_sources
    actions:
      - python: |
          apts = params['apt_sources']
          filename = '/etc/apt/sources.list.d/ick_apt_sources.list'
          print('Creating', filename)
          with open(filename, 'w') as f:
            for apt in apts:
              f.write('deb {url} {dist} {section}\n'.format(**apt))
        where: container

      - shell: |
          apt-get update
        where: container

  # Install build-dependencies for a Debian build, by checking
  # debian/control for what's missing. The sources parameter is used
  # to find all the source trees: for each location, if debian/oontrol
  # exists as the location, look for missing build-dependencies.

  - pipeline: ick/install_debian_build_dependencies
    parameters:
      - sources
    actions:
      - python: |
          import os

          def is_package_name(s):
            ok = "abcdefghijklmnopqrstyuvwxyz"
            ok += ok.upper()
            ok += "0123456789.-"
            return all(c in ok for c in s)

          sources = params['sources']
          for source in sources:
            dirname = source['location']
            control = os.path.join(dirname, 'debian', 'control')
            if os.path.exists(control):
              RUN('apt', 'show', 'python-coverage-test-runner', check=False)
              RUN('apt', 'show', 'python3-coverage-test-runner', check=False)
              err = ERR('dpkg-checkbuilddeps', cwd=dirname)
              print('err', err)
              pat = 'Unmet build dependencies: '
              if pat in err:
                parts = err.split(pat)
                print('parts:', repr(parts))
                missing = [x for x in parts[1].split() if is_package_name(x)]
                print('missing', missing)
                for name in missing:
                  RUN('apt-get', 'install', '-y', name)
        where: container


  # Build Debian packages. This is a CI build, which means a new
  # debian/changelog entry is created, with a version number that
  # contains the build number. This way every build results in a new
  # package version.
  #
  # The build will be done in each location in the sources parameter,
  # where debian/control exists.

  - pipeline: ick/build_deb_ci
    parameters:
      - sources
      - distribution_ci
    actions:

      - where: container
        shell: |
          rm -rf ick-helpers
          git clone git://git.liw.fi/ick-helpers

      - python: |
          import sys
          sys.path.insert(0, '/workspace/ick-helpers')
          import ick_helpers
          ick_helpers.ci_build_debian(params)
        where: container

  # Upload all *.changes files at the root of the workspace.

  - pipeline: ick/upload_debs
    actions:
      - action: dput
        where: host


  # Build release .deb packages from new tags. For the first build,
  # only remember the tags. Note that the workspace must be saved and
  # restored for this to work. The release builds are stored in
  # .release-files in the workspace.
  #
  # Releases are built from release tags, which must be signed,
  # annotated tags, named as foo-1.2 (release 1.2 of project foo). The
  # tag signature must be made by one a key listed in the
  # release_signing_keys parameter.

  - pipeline: ick/build_debian_release
    parameters:
      - sources
      - release_signing_keys
      - distribution_rel
    actions:

      - where: container
        python: |
          for key in params['release_signing_keys']:
            open('key.asc', 'w').write(key)
            RUN('gpg', '--import', 'key.asc')

      - where: container
        shell: |
          rm -rf ick-helpers .release-files
          mkdir .release-files
          git clone git://git.liw.fi/ick-helpers

      - where: container
        python: |
          import sys
          sys.path.insert(0, '/workspace/ick-helpers')
          import ick_helpers
          resultsdir = '.release-files'
          ick_helpers.build_debian_releases(params, resultsdir)

  # Archive the release .debs and related files from .release-files in
  # the workspace. The deb_artifact parameter names the artifact.

  - pipeline: ick/archive_debian_release
    parameters:
      - deb_artifact
    actions:
      - archive: workspace
        where: host
        globs:
          - ".release-files"
        name_from: deb_artifact