~cjwatson/launchpad-buildd/currentlybuilding-permissions

« back to all changes in this revision

Viewing changes to lpbuildd/binarypackage.py

  • Committer: Colin Watson
  • Date: 2019-06-18 15:32:02 UTC
  • Revision ID: cjwatson@canonical.com-20190618153202-4nhzwphnswwam80n
Don't rely on /CurrentlyBuilding existing in base images.

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
                ['sudo', 'install', '-o', 'root', '-g', 'root', '-m', '0644',
147
147
                 schroot_file.name, self.schroot_config_path])
148
148
 
149
 
        currently_building_path = os.path.join(
150
 
            self.chroot_path, 'CurrentlyBuilding')
151
149
        currently_building_contents = (
152
150
            'Package: %s\n'
153
151
            'Component: %s\n'
157
155
               self.archive_purpose))
158
156
        if self.build_debug_symbols:
159
157
            currently_building_contents += 'Build-Debug-Symbols: yes\n'
160
 
        with open(currently_building_path, 'w') as currently_building:
 
158
        with tempfile.NamedTemporaryFile(mode='w+') as currently_building:
161
159
            currently_building.write(currently_building_contents)
 
160
            currently_building.flush()
 
161
            os.fchmod(currently_building.fileno(), 0o644)
 
162
            self.backend.copy_in(currently_building.name, '/CurrentlyBuilding')
162
163
 
163
164
        args = ["sbuild-package", self._buildid, self.arch_tag]
164
165
        args.append(self.suite)