[elbe-devel] [PATCH 5/5] debianize: add u-boot support
Torben Hohn
torben.hohn at linutronix.de
Tue Oct 23 15:43:43 CEST 2018
From: Philipp Rosenberger <p.rosenberger at linutronix.de>
This debianization should work for u-boot >= 2014.04.
Tested with u-boot 2017.11.
Signed-off-by: Philipp Rosenberger <p.rosenberger at linutronix.de>
[torbenh: rebased onto 61bd91ee8d76 ("quickstart: describe how to
generate a key for a custom repository"),
applied Reviewcomments from manut from Jun 17th 2018,
fixed usage of classattributes,
replaced print with notify,
use copyright_fname]
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/debianize/uboot.py | 94 +++++++++++++++++++---
elbepack/makofiles/debianize/u-boot/control.mako | 28 +++++++
elbepack/makofiles/debianize/u-boot/format.mako | 6 ++
elbepack/makofiles/debianize/u-boot/rules.mako | 49 +++++++++++
.../debianize/u-boot/u-boot-image.install | 1 +
.../debianize/u-boot/u-boot-tools.install | 1 +
.../makofiles/debianize/u-boot/u-boot-tools.links | 1 +
7 files changed, 170 insertions(+), 10 deletions(-)
create mode 100644 elbepack/makofiles/debianize/u-boot/control.mako
create mode 100644 elbepack/makofiles/debianize/u-boot/format.mako
create mode 100755 elbepack/makofiles/debianize/u-boot/rules.mako
create mode 100644 elbepack/makofiles/debianize/u-boot/u-boot-image.install
create mode 100644 elbepack/makofiles/debianize/u-boot/u-boot-tools.install
create mode 100644 elbepack/makofiles/debianize/u-boot/u-boot-tools.links
diff --git a/elbepack/debianize/uboot.py b/elbepack/debianize/uboot.py
index ea2fc805..767281ce 100644
--- a/elbepack/debianize/uboot.py
+++ b/elbepack/debianize/uboot.py
@@ -1,31 +1,105 @@
# ELBE - Debian Based Embedded Rootfilesystem Builder
-# Copyright (c) 2016-2017 Manuel Traut <manut at linutronix.de>
-# Copyright (c) 2017 Torben Hohn <torben.hohn at linutronix.de>
+# Copyright (c) 2018 Philipp Rosenberger <p.rosenberger at linutronix.de>
+# Copyright (c) 2018 Torben Hohn <torben.hohn at linutronix.de>
#
# SPDX-License-Identifier: GPL-3.0-or-later
-import sys
+import os
-from elbepack.debianize.base import DebianizeBase
+from time import sleep
+from shutil import copyfile
+from subprocess import check_call
-# this is just a template to show how debianizing another component should work
+from npyscreen import TitleText, notify
+
+from elbepack.directories import mako_template_dir
+from elbepack.debianize.base import DebianizeBase, template
+
+from pkg_resources import parse_version as V
class UBoot (DebianizeBase):
name = "uboot"
- files = ['Kbuild', 'Kconfig', 'MAINTAINERS', 'config.mk']
+ files = ['Makefile', 'Kbuild', 'Kconfig', 'MAINTAINERS', 'config.mk']
+ copyright_fname = 'Licenses/README'
def __init__(self):
- print("debianization of uboot is not supported at the moment")
- sys.exit(-2)
+ self.verstr = None
+ self.defconfig = None
+ self.imgname = None
+ self.cross = None
+ self.k_version = None
+
DebianizeBase.__init__(self)
+ def get_version(self):
+ with open('Makefile', 'r') as f:
+ for line in f:
+ if line.startswith('VERSION = '):
+ version = line.split('=')[1].strip()
+ elif line.startswith('PATCHLEVEL = '):
+ patchlevel = line.split('=')[1].strip()
+ break
+
+ self.verstr = version + '.' + patchlevel
+ # With v2014.04 the u-boot Makefile knows the 'tools-only' target.
+ if V(self.verstr) < V('2014.04'):
+ notify("Only U-Boot >= 2014.04 is supported.\n"
+ "This is version '%s'" % self.verstr,
+ title='Warning')
+ sleep(10)
+
+ if V(self.verstr) >= V('2017.09'):
+ self.deb['envtools'] = 'envtools'
+ else:
+ self.deb['envtools'] = 'env'
+
def gui(self):
- pass
+ self.get_version()
+ self.defconfig = self.add_widget_intelligent(
+ TitleText, name="defconfig:", value="mx7dsabresd_defconfig")
+
+ self.imgname = self.add_widget_intelligent(
+ TitleText,
+ name="Imagename:",
+ value="u-boot-dtb.imx")
+
+ self.cross = self.add_widget_intelligent(
+ TitleText, name="CROSS_COMPILE:", value="arm-linux-gnueabihf-")
+
+ self.k_version = self.add_widget_intelligent(
+ TitleText, name="U-Boot Version:", value=self.verstr)
def debianize(self):
- pass
+ self.deb['k_arch'] = self.get_k_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/u-boot')
+ 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 u-boot-' + pkg_name + \
+ ' -v ' + self.deb['p_version'] + \
+ ' --create -M -D ' + self.deb['release'] + \
+ ' "generated by elbe debianize"'
+ check_call(cmd, shell=True)
+
+ copyfile(os.path.join(self.tmpl_dir, 'u-boot-image.install'),
+ 'debian/u-boot-image-' + pkg_name + '.install')
+ copyfile(os.path.join(self.tmpl_dir, 'u-boot-tools.install'),
+ 'debian/u-boot-tools-' + pkg_name + '.install')
+
+ self.hint = "use 'dpkg-buildpackage -a%s' to build the package" % (
+ self.deb['p_arch'])
DebianizeBase.register(UBoot)
diff --git a/elbepack/makofiles/debianize/u-boot/control.mako b/elbepack/makofiles/debianize/u-boot/control.mako
new file mode 100644
index 00000000..11b8c3e2
--- /dev/null
+++ b/elbepack/makofiles/debianize/u-boot/control.mako
@@ -0,0 +1,28 @@
+## ELBE - Debian Based Embedded Rootfilesystem Builder
+## Copyright (c) 2018 Philipp Rosenberger <p.rosenberger at linutronix.de>
+##
+## SPDX-License-Identifier: GPL-3.0-or-later
+##
+Source: u-boot-${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.denx.de/wiki/U-Boot/
+
+Package: u-boot-image-${p_name}-${k_version}
+Provides: u-boot-image
+Architecture: ${p_arch}
+Description: A boot loader for embedded systems
+ Das U-Boot is a cross-platform bootloader for embedded systems, used as the default boot loader by several board
+ vendors. It is intended to be easy to port and to debug, and runs on many supported architectures, including PPC,
+ ARM, MIPS, x86, m68k, NIOS, and Microblaze.
+
+Package: u-boot-tools-${p_name}-${k_version}
+Provides: u-boot-tools
+Architecture: ${p_arch}
+Description: companion tools for Das U-Boot bootloader
+ This package includes the mkimage program, which allows generation of U-Boot
+ images in various formats, and the fw_printenv and fw_setenv programs to read
+ and modify U-Boot's environment.
diff --git a/elbepack/makofiles/debianize/u-boot/format.mako b/elbepack/makofiles/debianize/u-boot/format.mako
new file mode 100644
index 00000000..8f87974d
--- /dev/null
+++ b/elbepack/makofiles/debianize/u-boot/format.mako
@@ -0,0 +1,6 @@
+## ELBE - Debian Based Embedded Rootfilesystem Builder
+## Copyright (c) 2018 Philipp Rosenberger <p.rosenberger at linutronix.de>
+##
+## SPDX-License-Identifier: GPL-3.0-or-later
+##
+3.0 (${source_format})
diff --git a/elbepack/makofiles/debianize/u-boot/rules.mako b/elbepack/makofiles/debianize/u-boot/rules.mako
new file mode 100755
index 00000000..fd1c987e
--- /dev/null
+++ b/elbepack/makofiles/debianize/u-boot/rules.mako
@@ -0,0 +1,49 @@
+## ELBE - Debian Based Embedded Rootfilesystem Builder
+## Copyright (c) 2018 Philipp Rosenberger <p.rosenberger at linutronix.de>
+##
+## SPDX-License-Identifier: GPL-3.0-or-later
+##
+#!/usr/bin/make -f
+
+BOOT_PATH=`pwd`/debian/tmp/boot
+TOOL_PATH=`pwd`/debian/tmp/usr/bin
+
+BUILD_DIR=`pwd`/debian/build
+
+MAKE_OPTS= \
+ARCH=${k_arch} \
+CROSS_COMPILE=${cross_compile} \
+KERNELRELEASE=${k_version}-${p_name} \
+O=$(BUILD_DIR)
+
+#export DH_VERBOSE=1
+export LDFLAGS=
+
+override_dh_auto_test:
+ # skip tests.
+
+override_dh_auto_clean:
+ mkdir -p $(BUILD_DIR)
+ rm -f debian/files
+ rm -rf debian/tmp
+ make $(MAKE_OPTS) clean
+
+override_dh_auto_configure:
+ mkdir -p $(BUILD_DIR)
+ make $(MAKE_OPTS) ${defconfig}
+
+override_dh_auto_build:
+ make -j`nproc` $(MAKE_OPTS)
+ make -j`nproc` $(MAKE_OPTS) ${envtools}
+ make -j`nproc` $(MAKE_OPTS) CROSS_BUILD_TOOLS=y tools-only
+
+override_dh_auto_install:
+ mkdir -p $(TOOL_PATH) $(BOOT_PATH)
+ cp $(BUILD_DIR)/${imgname} $(BOOT_PATH)
+ -cp $(BUILD_DIR)/tools/dumpimage $(TOOL_PATH)
+ -cp $(BUILD_DIR)/tools/mkenvimage $(TOOL_PATH)
+ -cp $(BUILD_DIR)/tools/mkimage $(TOOL_PATH)
+ -cp $(BUILD_DIR)/tools/env/fw_printenv $(TOOL_PATH)
+
+%%:
+ dh $@
diff --git a/elbepack/makofiles/debianize/u-boot/u-boot-image.install b/elbepack/makofiles/debianize/u-boot/u-boot-image.install
new file mode 100644
index 00000000..a79c136d
--- /dev/null
+++ b/elbepack/makofiles/debianize/u-boot/u-boot-image.install
@@ -0,0 +1 @@
+./boot/*
diff --git a/elbepack/makofiles/debianize/u-boot/u-boot-tools.install b/elbepack/makofiles/debianize/u-boot/u-boot-tools.install
new file mode 100644
index 00000000..94924c6d
--- /dev/null
+++ b/elbepack/makofiles/debianize/u-boot/u-boot-tools.install
@@ -0,0 +1 @@
+./usr/bin/*
diff --git a/elbepack/makofiles/debianize/u-boot/u-boot-tools.links b/elbepack/makofiles/debianize/u-boot/u-boot-tools.links
new file mode 100644
index 00000000..92f5a6cb
--- /dev/null
+++ b/elbepack/makofiles/debianize/u-boot/u-boot-tools.links
@@ -0,0 +1 @@
+/usr/bin/fw_printenv /usr/bin/fw_setenv
--
2.11.0
More information about the elbe-devel
mailing list