# Path: elbepack/debianize/panels/base.py
# class Panel(Form):
# 
#     copyright_fname = "COPYING"
# 
#     def __init__(self, grid_elements):
# 
#         self.deb = {}
#         self.tmpl_dir = None
#         self.hint = None
# 
#         fullname = os.environ.get('DEBFULLNAME', "Max Mustermann")
#         email = os.environ.get('DEBEMAIL', "max@mustermann.org")
# 
#         p_name = Edit("Name", "elbe")
#         p_version = Edit("Version", "1.0")
#         p_arch = RadioGroup("Arch", Arch, Arch.ARM64)
#         src_fmt = RadioGroup("Format", Format, Format.NATIVE)
#         release = RadioGroup("Release", Release, Release.STABLE)
# 
#         m_name = Edit("Maintainer", fullname)
#         m_mail = Edit("Mail", email)
# 
#         grid = [
#             {"p_name":p_name, "p_version":p_version},
#             {"p_arch":p_arch,"release":release},
#             {"source_format":src_fmt},
#             {"m_name":m_name, "m_mail":m_mail},
#         ]
# 
#         for element in grid_elements:
#             grid.append(element)
# 
#         super(Panel, self).__init__(grid)
# 
# 
#     def get_k_arch(self):
#         """ get_k_arch() may be used in debianize() """
# 
#         if self.deb['p_arch'] == 'armhf':
#             return 'arm'
#         elif self.deb['p_arch'] == 'armel':
#             return 'arm'
#         elif self.deb['p_arch'] == 'amd64':
#             return 'x86_64'
#         else:
#             return self.deb['p_arch']
# 
#     def on_submit(self, datas):
# 
#         for key, value in datas.items():
#             self.deb[key] = str(value)
# 
#         self.deb['k_arch'] = self.get_k_arch()
# 
#         os.mkdir('debian')
#         os.mkdir('debian/source')
# 
#         self.debianize()
# 
#         with open('debian/source/format', 'w') as f:
#             mako = os.path.join(self.tmpl_dir, 'format.mako')
#             f.write(template(mako, self.deb))
# 
#         copyfile(self.copyright_fname, 'debian/copyright')
#         with open('debian/compat', 'w') as f:
#             f.write('9')
# 
#         TUI.quit()
# 
# Path: elbepack/debianize/widgets/edit.py
# def Edit(header='', default='', linebox=True, multiline=False):
#     this = urwid.Edit(("header", "{}\n".format(header)), default, multiline=multiline)
#     if linebox:
#         this = urwid.LineBox(this)
#     return this
# 
# Path: elbepack/directories.py
# def init_directories(elbe_relpath):
# def get_cmdlist():
# 
# Path: elbepack/templates.py
# def template(fname, d, linebreak=False):
#     try:
#         if linebreak:
#             return Template(
#                 filename=fname,
#                 preprocessor=fix_linebreak_escapes).render(
#                 **d)
# 
#         return Template(filename=fname).render(**d)
#     except BaseException:
#         print(exceptions.text_error_template().render())
#         raise
# 
# Path: elbepack/shellhelper.py
# def system(cmd, allow_fail=False, env_add=None):
#     """system() - Execute cmd in a shell.
# 
#     Throws a CommandError if cmd returns none-zero and allow_fail=False
# 
#     --
# 
#     >>> system("true")
# 
#     >>> system("false", allow_fail=True)
# 
#     >>> system("$FALSE", env_add={"FALSE":"false"}) # doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     elbepack.shellhelper.CommandError: ...
# 
#     """
#     new_env = os.environ.copy()
#     if env_add:
#         new_env.update(env_add)
# 
#     ret = call(cmd, shell=True, env=new_env)
# 
#     if ret != 0:
#         if not allow_fail:
#             raise CommandError(cmd, ret)


import os
import stat
from shutil import copyfile
from elbepack.debianize.panels.base import Panel
from elbepack.debianize.widgets.edit import Edit
from elbepack.directories import mako_template_dir
from elbepack.templates import template
from elbepack.shellhelper import system
# ELBE - Debian Based Embedded Rootfilesystem Builder
# Copyright (c) 2017 Torben Hohn <torben.hohn@linutronix.de>
# Copyright (c) 2017 Manuel Traut <manut@linutronix.de>
# Copyright (c) 2019 Olivier Dion <dion@linutronix.de>
#
# SPDX-License-Identifier: GPL-3.0-or-later






class BareBox(Panel):

    match_files = ['Kbuild', 'Kconfig', 'README', 'Documentation/barebox.svg']

    def __init__(self):

        imgname = Edit(
            "Image name", "barebox-phytec-phycore-imx6dl-som-nand-256mb.img")

# Path: elbepack/debianize/panels/base.py
# class Panel(Form):
# 
#     copyright_fname = "COPYING"
# 
#     def __init__(self, grid_elements):
# 
#         self.deb = {}
#         self.tmpl_dir = None
#         self.hint = None
# 
#         fullname = os.environ.get('DEBFULLNAME', "Max Mustermann")
#         email = os.environ.get('DEBEMAIL', "max@mustermann.org")
# 
#         p_name = Edit("Name", "elbe")
#         p_version = Edit("Version", "1.0")
#         p_arch = RadioGroup("Arch", Arch, Arch.ARM64)
#         src_fmt = RadioGroup("Format", Format, Format.NATIVE)
#         release = RadioGroup("Release", Release, Release.STABLE)
# 
#         m_name = Edit("Maintainer", fullname)
#         m_mail = Edit("Mail", email)
# 
#         grid = [
#             {"p_name":p_name, "p_version":p_version},
#             {"p_arch":p_arch,"release":release},
#             {"source_format":src_fmt},
#             {"m_name":m_name, "m_mail":m_mail},
#         ]
# 
#         for element in grid_elements:
#             grid.append(element)
# 
#         super(Panel, self).__init__(grid)
# 
# 
#     def get_k_arch(self):
#         """ get_k_arch() may be used in debianize() """
# 
#         if self.deb['p_arch'] == 'armhf':
#             return 'arm'
#         elif self.deb['p_arch'] == 'armel':
#             return 'arm'
#         elif self.deb['p_arch'] == 'amd64':
#             return 'x86_64'
#         else:
#             return self.deb['p_arch']
# 
#     def on_submit(self, datas):
# 
#         for key, value in datas.items():
#             self.deb[key] = str(value)
# 
#         self.deb['k_arch'] = self.get_k_arch()
# 
#         os.mkdir('debian')
#         os.mkdir('debian/source')
# 
#         self.debianize()
# 
#         with open('debian/source/format', 'w') as f:
#             mako = os.path.join(self.tmpl_dir, 'format.mako')
#             f.write(template(mako, self.deb))
# 
#         copyfile(self.copyright_fname, 'debian/copyright')
#         with open('debian/compat', 'w') as f:
#             f.write('9')
# 
#         TUI.quit()
# 
# Path: elbepack/debianize/widgets/edit.py
# def Edit(header='', default='', linebox=True, multiline=False):
#     this = urwid.Edit(("header", "{}\n".format(header)), default, multiline=multiline)
#     if linebox:
#         this = urwid.LineBox(this)
#     return this
# 
# Path: elbepack/directories.py
# def init_directories(elbe_relpath):
# def get_cmdlist():
# 
# Path: elbepack/templates.py
# def template(fname, d, linebreak=False):
#     try:
#         if linebreak:
#             return Template(
#                 filename=fname,
#                 preprocessor=fix_linebreak_escapes).render(
#                 **d)
# 
#         return Template(filename=fname).render(**d)
#     except BaseException:
#         print(exceptions.text_error_template().render())
#         raise
# 
# Path: elbepack/shellhelper.py
# def system(cmd, allow_fail=False, env_add=None):
#     """system() - Execute cmd in a shell.
# 
#     Throws a CommandError if cmd returns none-zero and allow_fail=False
# 
#     --
# 
#     >>> system("true")
# 
#     >>> system("false", allow_fail=True)
# 
#     >>> system("$FALSE", env_add={"FALSE":"false"}) # doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     elbepack.shellhelper.CommandError: ...
# 
#     """
#     new_env = os.environ.copy()
#     if env_add:
#         new_env.update(env_add)
# 
#     ret = call(cmd, shell=True, env=new_env)
# 
#     if ret != 0:
#         if not allow_fail:
#             raise CommandError(cmd, ret)


# Path: elbepack/debianize/panels/barebox.py
import os
import stat
from shutil import copyfile
from elbepack.debianize.panels.base import Panel
from elbepack.debianize.widgets.edit import Edit
from elbepack.directories import mako_template_dir
from elbepack.templates import template
from elbepack.shellhelper import system

# ELBE - Debian Based Embedded Rootfilesystem Builder
# Copyright (c) 2017 Torben Hohn <torben.hohn@linutronix.de>
# Copyright (c) 2017 Manuel Traut <manut@linutronix.de>
# Copyright (c) 2019 Olivier Dion <dion@linutronix.de>
#
# SPDX-License-Identifier: GPL-3.0-or-later






class BareBox(Panel):

    match_files = ['Kbuild', 'Kconfig', 'README', 'Documentation/barebox.svg']

    def __init__(self):

        imgname = Edit(
            "Image name", "barebox-phytec-phycore-imx6dl-som-nand-256mb.img")

        defconfig = Edit("Def config", "imx_v7_defconfig")