~morphis/bluez/fix-snapcraft-source

« back to all changes in this revision

Viewing changes to parts/plugins/x-autotools.py

  • Committer: Simon Fels
  • Date: 2016-04-13 13:36:57 UTC
  • Revision ID: simon.fels@canonical.com-20160413133657-0yyl67td3i0l9qjk
Update to new autotools plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
            'default': [],
56
56
        }
57
57
 
 
58
        schema['properties']['install-via'] = {
 
59
            'enum': ['destdir', 'prefix'],
 
60
            'default': 'destdir',
 
61
        }
 
62
 
 
63
        schema['properties']['patches-dir'] = {
 
64
            'type': 'string',
 
65
            'default': 'patches',
 
66
        }
 
67
 
 
68
        schema['properties']['force-autogen'] = {
 
69
            'type': 'boolean',
 
70
            'default': 'true',
 
71
        }
 
72
 
58
73
        return schema
59
74
 
60
75
    def __init__(self, name, options):
65
80
            'autopoint',
66
81
            'libtool',
67
82
            'make',
 
83
            'quilt',
68
84
        ])
69
85
 
 
86
        if options.install_via == 'destdir':
 
87
            self.install_via_destdir = True
 
88
        elif options.install_via == 'prefix':
 
89
            self.install_via_destdir = False
 
90
        else:
 
91
            raise RuntimeError('Unsupported installation method: "{}"'.format(
 
92
                options.install_via))
 
93
 
70
94
    def build(self):
71
95
        super().build()
72
96
 
73
 
        self.run(['pwd'])
74
 
        os.environ['QUILT_PATCHES'] = '../../../patches'
75
 
        self.run(['quilt', 'push', '-a'])
76
 
        
77
 
        if not os.path.exists(os.path.join(self.builddir, "configure")):
 
97
        patchdir = os.path.join(self.builddir, "../../..", self.options.patches_dir)
 
98
 
 
99
        if os.path.exists(patchdir):
 
100
            os.environ['QUILT_PATCHES'] = patchdir
 
101
            self.run(['quilt', 'push', '-a'])
 
102
 
 
103
        if not os.path.exists(os.path.join(self.builddir, "configure")) or self.options.force_autogen:
78
104
            autogen_path = os.path.join(self.builddir, "autogen.sh")
79
105
            if os.path.exists(autogen_path):
80
106
                # Make sure it's executable
88
114
            else:
89
115
                self.run(['autoreconf', '-i'])
90
116
 
91
 
        self.run(['./configure', '--prefix='] + self.options.configflags)
92
 
        self.run(['make'])
93
 
        self.run(['make', 'install', 'DESTDIR=' + self.installdir])
 
117
        configure_command = ['./configure']
 
118
        make_install_command = ['make', 'install']
 
119
 
 
120
        if self.install_via_destdir:
 
121
            # Use an empty prefix since we'll install via DESTDIR
 
122
            configure_command.append('--prefix=')
 
123
            make_install_command.append('DESTDIR=' + self.installdir)
 
124
        else:
 
125
            configure_command.append('--prefix=' + self.installdir)
 
126
 
 
127
        self.run(configure_command + self.options.configflags)
 
128
        self.run(['make', '-j{}'.format(
 
129
            snapcraft.common.get_parallel_build_count())])
 
130
        self.run(make_install_command)