~longsleep/snapcraft/snapcraft-debs-plugin

« back to all changes in this revision

Viewing changes to snapcraft/plugins/catkin.py

  • Committer: Snappy Tarmac
  • Author(s): Sergio Schvezov
  • Date: 2015-10-26 15:25:06 UTC
  • mfrom: (250.2.4 work)
  • Revision ID: snappy_tarmac-20151026152506-7hqsn1kftvqcuncl
Plugins raise exception instead of true/false by sergiusens approved by elopio

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
        self._deb_packages = []
66
66
 
67
67
    def pull(self):
68
 
        if not super().pull():
69
 
            return False
70
 
 
71
 
        try:
72
 
            self._setup_deb_packages()
73
 
        except snapcraft.repo.PackageNotFoundError as e:
74
 
            logger.error(e.message)
75
 
            return False
76
 
 
77
 
        return True
 
68
        super().pull()
 
69
        self._setup_deb_packages()
78
70
 
79
71
    def env(self, root):
80
72
        return [
186
178
            f.write('exec {}\n'.format(' '.join(commandlist)))
187
179
            f.flush()
188
180
 
189
 
            return self.run(['/bin/bash', f.name], cwd=cwd)
 
181
            self.run(['/bin/bash', f.name], cwd=cwd)
190
182
 
191
183
    def build(self):
192
184
        # Fixup ROS Cmake files that have hardcoded paths in them
193
 
        if not self.run([
 
185
        self.run([
194
186
            'find', self.rosdir, '-name', '*.cmake',
195
187
            '-exec', 'sed', '-i', '-e',
196
188
            r's|\(\W\)/usr/lib/|\1{0}/usr/lib/|g'.format(self.installdir),
197
189
            '{}', ';'
198
 
        ]):
199
 
            return False
 
190
        ])
200
191
 
201
192
        self._find_package_deps()
202
 
 
203
 
        if not self._build_packages_deps():
204
 
            return False
 
193
        self._build_packages_deps()
205
194
 
206
195
        # the hacks
207
196
        findcmd = ['find', self.installdir, '-name', '*.cmake', '-delete']
208
 
        if not self.run(findcmd):
209
 
            return False
 
197
        self.run(findcmd)
210
198
 
211
 
        if not self.run(
 
199
        self.run(
212
200
            ['rm', '-f',
213
201
             'opt/ros/' + self.options.rosversion + '/.catkin',
214
202
             'opt/ros/' + self.options.rosversion + '/.rosinstall',
215
203
             'opt/ros/' + self.options.rosversion + '/setup.sh',
216
204
             'opt/ros/' + self.options.rosversion + '/_setup_util.py'],
217
 
                cwd=self.installdir):
218
 
            return False
 
205
            cwd=self.installdir)
219
206
 
220
207
        os.remove(os.path.join(self.installdir, 'usr/bin/xml2-config'))
221
208
 
222
 
        return True
223
 
 
224
209
    def _build_packages_deps(self):
225
210
        # Ugly dependency resolution, just loop through until we can
226
211
        # find something to build. When we do, build it. Loop until we
233
218
            for pkg in self.packages - built:
234
219
                if len(self.package_local_deps[pkg] - built) > 0:
235
220
                    continue
236
 
 
237
 
                if not self._handle_package(pkg):
238
 
                    return False
 
221
                self._handle_package(pkg)
239
222
 
240
223
                built.add(pkg)
241
224
                built_pkg = True
242
225
 
243
226
        if not built_pkg:
244
 
            return False
245
 
 
246
 
        return True
 
227
            raise RuntimeError('some packages failed to build')
247
228
 
248
229
    def _handle_package(self, pkg):
249
230
        catkincmd = ['catkin_make_isolated']
278
259
                os.path.join(self.installdir, 'usr', 'bin', 'g++'))
279
260
        ])
280
261
 
281
 
        if not self._rosrun(catkincmd):
282
 
            return False
283
 
 
284
 
        return True
 
262
        self._rosrun(catkincmd)