Ubuntu Pastebin

Paste from balogh at Thu, 27 Oct 2016 10:29:07 +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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright (C) 2016 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""This plugin pack up the content of the staging to a tar.gz file

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.

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:

    - exclude:
      (list of strings)
      additional options to pass to the tar command.
    - name:
      string what will be used as name of the tar.gz archive
"""

import os

import snapcraft

import logging

logger = logging.getLogger(__name__)

class TarStagePlugin(snapcraft.BasePlugin):

    @classmethod
    def schema(cls):
        schema = super().schema()
        schema['properties']['exclude'] = {
            'type': 'array',
            'minitems': 0,
            'uniqueItems': True,
            'items': {
                'type': 'string',
            },
            'default': [],
        }
        schema['properties']['name'] = {
            'type': 'string',
            'default': ''
        }
        # The name must be specified
        schema['required'].append('name')
        return schema

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

        logger.warning("EXPERIMENTAL: The 'tarstage' plugin's "
                       "functionality is under development and all features"
                       "are experimental.")

    def enable_cross_compilation(self):
        pass

    def build(self):
        super().build()
        archive_name = self.options.name
        logger.warning("self.project.stage_dir %s" % self.project.stage_dir)
        self.run(['/bin/tar', 'czvf', archive_name, self.project.stage_dir])
Download as text