Ubuntu Pastebin

Paste from ubuntu at Wed, 14 Jun 2017 19:37:53 +0000

Download as text
 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
"""The ruby plugin is useful for ruby based parts.
The plugin uses gem to install dependencies from a `Gemfile`.
This plugin uses the common plugin keywords as well as those for "sources".
For more information check the 'plugins' topic for the former and the
'sources' topic for the latter.
Additionally, this plugin uses the following plugin-specific keywords:
    - gems:
      (list)
      A list of gems to install.
    - ruby-version:
      (string)
      The version of ruby you want this snap to run.
"""
import contextlib
import logging
from shutil import rmtree
from os import makedirs
from os.path import exists, join, abspath

from snapcraft import BasePlugin
from snapcraft.sources import Tar

logger = logging.getLogger(__name__)

_RUBY_TMPL = 'https://cache.ruby-lang.org/pub/ruby/ruby-{version}.tar.gz'


class RubyPlugin(BasePlugin):

    @classmethod
    def schema(cls):
        schema = super().schema()

        schema['properties']['ruby-version'] = {
            'type': 'string',
            'default': "2.3.1"
        }
        return schema

    @classmethod
    def get_pull_properties(cls):
        # Inform Snapcraft of the properties associated with pulling. If these
        # change in the YAML Snapcraft will consider the build step dirty.
        return ['ruby-version']

    def __init__(self, name, options, project):
        super().__init__(name, options, project)

        #self._ruby_dir = join(self.partdir, 'ruby')
        #self._ruby_tar = Tar(ruby_download_url(self.options.ruby_version))

        pkgs = ['gcc', 'g++', 'make', 'zlib1g-dev',
                'libssl-dev', 'libreadline-dev']
        for pkg in pkgs:
            self.build_packages.append(pkg)

    #def pull(self):
    #    makedirs(self._ruby_dir, exist_ok=True)
    #    self._ruby_tar.download()
        #self._ruby_install(rootdir=self.sourcedir)


def ruby_download_url(ruby_version):
    return _RUBY_TMPL.format(version=ruby_version)
Download as text