[elbe-devel] [PATCH 4/5] debianize: add barebox debianizer implementation

Torben Hohn torben.hohn at linutronix.de
Wed Mar 8 10:53:23 CET 2017


---
 elbepack/debianize/barebox.py                      | 88 ++++++++++++++++++++++
 elbepack/debianize/debianize.py                    |  1 +
 .../debianize/barebox/barebox-image.install        |  1 +
 .../debianize/barebox/barebox-tools.install        |  1 +
 elbepack/makofiles/debianize/barebox/control.mako  | 19 +++++
 elbepack/makofiles/debianize/barebox/format.mako   |  1 +
 elbepack/makofiles/debianize/barebox/rules.mako    | 36 +++++++++
 7 files changed, 147 insertions(+)
 create mode 100644 elbepack/debianize/barebox.py
 create mode 100644 elbepack/makofiles/debianize/barebox/barebox-image.install
 create mode 100644 elbepack/makofiles/debianize/barebox/barebox-tools.install
 create mode 100644 elbepack/makofiles/debianize/barebox/control.mako
 create mode 100644 elbepack/makofiles/debianize/barebox/format.mako
 create mode 100755 elbepack/makofiles/debianize/barebox/rules.mako

diff --git a/elbepack/debianize/barebox.py b/elbepack/debianize/barebox.py
new file mode 100644
index 0000000..fc32930
--- /dev/null
+++ b/elbepack/debianize/barebox.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+#
+# ELBE - Debian Based Embedded Rootfilesystem Builder
+# Copyright (C) 2016  Linutronix GmbH
+#
+# This file is part of ELBE.
+#
+# ELBE is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# ELBE 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 ELBE.  If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import sys
+
+from npyscreen import TitleText, TitleSelectOne
+
+from shutil import copyfile
+
+from elbepack.directories import mako_template_dir
+from elbepack.debianize.base import DebianizeBase, template
+
+class BareBox (DebianizeBase):
+
+    name  = "barebox"
+    files = ['Kbuild', 'Kconfig', 'README', 'TODO']
+
+    def __init__ (self):
+        DebianizeBase.__init__ (self)
+
+    def gui (self):
+        self.defconfig = self.add_widget_intelligent (TitleText,
+                name="defconfig:", value="imx_v7_defconfig")
+
+        self.imgname = self.add_widget_intelligent (TitleText,
+                name="Imagename:", value="barebox-phytec-phycore-imx6dl-som-nand-256mb.img")
+
+        self.cross = self.add_widget_intelligent (TitleText,
+                name="CROSS_COMPILE:", value="arm-linux-gnueabihf-")
+
+        self.k_version = self.add_widget_intelligent (TitleText,
+                name="BareboxVersion:", value="2016.10")
+
+    def debianize (self):
+        if self.deb['p_arch'] == 'armhf':
+            self.deb['k_arch'] = 'arm'
+        elif self.deb['p_arch'] == 'armel':
+            self.deb['k_arch'] = 'arm'
+        elif self.deb['p_arch'] == 'amd64':
+            self.deb['k_arch'] = 'x86_64'
+        else:
+            self.deb['k_arch'] = self.deb['p_arch']
+
+        self.deb['defconfig']     = self.defconfig.get_value ()
+        self.deb['cross_compile'] = self.cross.get_value ()
+        self.deb['k_version']     = self.k_version.get_value ()
+        self.deb['imgname']       = self.imgname.get_value ()
+
+        self.tmpl_dir = os.path.join(mako_template_dir, 'debianize/barebox')
+        pkg_name = self.deb['p_name']+'-'+self.deb['k_version']
+
+        for tmpl in ['control', 'rules']:
+            with open (os.path.join('debian/', tmpl), 'w') as f:
+                mako = os.path.join(self.tmpl_dir, tmpl+'.mako')
+                f.write (template(mako, self.deb))
+
+        cmd = 'dch --package barebox-' + pkg_name + \
+                   ' -v ' + self.deb['p_version'] + \
+                   ' --create -M -D ' + self.deb['release'] + \
+                   ' "generated by elbe debianize"'
+        os.system (cmd)
+
+        copyfile (os.path.join(self.tmpl_dir, 'barebox-image.install'),
+                  'debian/barebox-image-'+pkg_name+'.install')
+        copyfile (os.path.join(self.tmpl_dir, 'barebox-tools.install'),
+                  'debian/barebox-tools-'+pkg_name+'.install')
+
+        self.hint = "use 'dpkg-buildpackage -a%s' to build the package" % self.deb['p_arch']
+
+DebianizeBase.register (BareBox)
diff --git a/elbepack/debianize/debianize.py b/elbepack/debianize/debianize.py
index b6cf5a9..a86d19e 100644
--- a/elbepack/debianize/debianize.py
+++ b/elbepack/debianize/debianize.py
@@ -28,6 +28,7 @@ from shutil import copyfile
 
 from elbepack.debianize.kernel import Kernel
 from elbepack.debianize.uboot  import UBoot
+from elbepack.debianize.barebox import BareBox
 
 from elbepack.debianize.base import DebianizeBase
 
diff --git a/elbepack/makofiles/debianize/barebox/barebox-image.install b/elbepack/makofiles/debianize/barebox/barebox-image.install
new file mode 100644
index 0000000..a79c136
--- /dev/null
+++ b/elbepack/makofiles/debianize/barebox/barebox-image.install
@@ -0,0 +1 @@
+./boot/*
diff --git a/elbepack/makofiles/debianize/barebox/barebox-tools.install b/elbepack/makofiles/debianize/barebox/barebox-tools.install
new file mode 100644
index 0000000..94924c6
--- /dev/null
+++ b/elbepack/makofiles/debianize/barebox/barebox-tools.install
@@ -0,0 +1 @@
+./usr/bin/*
diff --git a/elbepack/makofiles/debianize/barebox/control.mako b/elbepack/makofiles/debianize/barebox/control.mako
new file mode 100644
index 0000000..6207716
--- /dev/null
+++ b/elbepack/makofiles/debianize/barebox/control.mako
@@ -0,0 +1,19 @@
+Source: barebox-${p_name}-${k_version}
+Section: admin
+Priority: optional
+Maintainer: ${m_name} <${m_mail}>
+Build-Depends: debhelper (>= 9), bc
+Standards-Version: 3.8.4
+Homepage: http://www.barebox.org/
+
+Package: barebox-image-${p_name}-${k_version}
+Provides: barebox-image
+Architecture: ${p_arch}
+Description: Barebox, version ${p_name} ${k_version}
+ This package contains barebox
+
+Package: barebox-tools-${p_name}-${k_version}
+Provides: barebox-tools 
+Architecture: ${p_arch}
+Description: Barebox tools 
+ This package provides Barebox Userspace tools
diff --git a/elbepack/makofiles/debianize/barebox/format.mako b/elbepack/makofiles/debianize/barebox/format.mako
new file mode 100644
index 0000000..7b6bf9b
--- /dev/null
+++ b/elbepack/makofiles/debianize/barebox/format.mako
@@ -0,0 +1 @@
+3.0 (${source_format})
diff --git a/elbepack/makofiles/debianize/barebox/rules.mako b/elbepack/makofiles/debianize/barebox/rules.mako
new file mode 100755
index 0000000..353a29f
--- /dev/null
+++ b/elbepack/makofiles/debianize/barebox/rules.mako
@@ -0,0 +1,36 @@
+#!/usr/bin/make -f
+
+BOOT_PATH=`pwd`/debian/tmp/boot
+TOOL_PATH=`pwd`/debian/tmp/usr/bin
+
+MAKE_OPTS= \
+ARCH=${k_arch} \
+CROSS_COMPILE=${cross_compile} \
+KERNELRELEASE=${k_version}-${p_name} \
+O=debian/build
+
+#export DH_VERBOSE=1
+export LDFLAGS=
+
+override_dh_auto_clean:
+	mkdir -p debian/build
+	rm -f debian/files
+	rm -rf debian/tmp
+	make $(MAKE_OPTS) clean
+
+override_dh_auto_configure:
+	mkdir -p debian/build
+	make $(MAKE_OPTS) ${defconfig}
+
+override_dh_auto_build:
+	rm -rf include/config
+	make -j`nproc` $(MAKE_OPTS)
+
+override_dh_auto_install:
+	mkdir -p $(TOOL_PATH) $(BOOT_PATH)
+	cp debian/build/images/${imgname} $(BOOT_PATH)
+	-cp debian/build/scripts/bareboxcrc32-target $(TOOL_PATH)/bareboxcrc32
+	-cp debian/build/scripts/bareboxenv-target $(TOOL_PATH)/bareboxenv
+
+%%:
+	dh $@
-- 
2.1.4





More information about the elbe-devel mailing list