import getpass
import shlex
import multiprocessing
+import textwrap
TEMPORARY_DIRECTORY = '/var/tmp'
for p in packages:
copyfile(p, os.path.join(output_dir, os.path.basename(devel_to_git(tree.git_commit, p))))
+
class SourceTarget(Target):
"""Build a source .tar.bz2"""
def __init__(self):
p = os.path.abspath('%s-%s.tar.bz2' % (name, tree.version))
copyfile(p, os.path.join(output_dir, os.path.basename(devel_to_git(tree.git_commit, p))))
+
+class SnapTarget(Target):
+ """Build a snap"""
+ def __init__(self):
+ super(SnapTarget, self).__init__('snap')
+
+ def command(self, c):
+ command('%s %s' % (self.variables_string(), c))
+
+ def cleanup(self):
+ rmtree(self.directory)
+
+ def package(self, project, checkout, output_dir, options):
+ makedirs(os.path.join(self.directory, 'plugins'))
+ f = open(os.path.join(self.directory, 'plugins', 'cdist.py'), 'w')
+ print("""
+import snapcraft
+
+class CdistPlugin(snapcraft.BasePlugin):
+ def build(self):
+ print('cdist plugin builds!')
+""", file=f)
+ f.close()
+
+ f = open(os.path.join(self.directory, 'snapcraft.yaml'), 'w')
+ print('name: %s' % project, file=f)
+ tree = globals.trees.get(project, checkout, self)
+ print('version: %s' % tree.version, file=f)
+ print('summary: %s' % tree.cscript['summary'], file=f)
+ print('description: |', file=f)
+ for l in textwrap.wrap(' '.join(tree.cscript['description'].split())):
+ print("\t%s" % l, file=f)
+ print('confinement: devmode', file=f)
+ print('base: core18', file=f)
+ print('parts:', file=f)
+ for t in tree.dependencies({}):
+ print("\t%s:" % t[0].name, file=f)
+ print("\t\tplugin: cdist", file=f)
+ print("\t\tsource-type: git", file=f)
+ print("\t\tsource: git://%s/%s" % (config.get('git_prefix'), t[0].name), file=f)
+ print("\t\tsource-commit: %s" % t[0].git_commit, file=f)
+
+
+
# @param s Target string:
# windows-{32,64}
# or ubuntu-version-{32,64}
# or source
# or flatpak
# or appimage
+# or snap
# @param debug True to build with debugging symbols (where possible)
def target_factory(args):
s = args.target
target = FlatpakTarget(args.project, args.checkout)
elif s == 'appimage':
target = AppImageTarget(args.work)
+ elif s == 'snap':
+ target = SnapTarget()
if target is None:
raise Error("Bad target `%s'" % s)