[elbe-devel] [PATCH v3 6/7] commands check-build: Add SDK checker
Olivier Dion
dion at linutronix.de
Thu Aug 20 18:02:14 CEST 2020
This checker finds all SDK scripts in a build and validates that they
work. This is done by extracting the scripts and building a small
auto-tools hello world project.
Signed-off-by: Olivier Dion <dion at linutronix.de>
Acked-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/commands/check-build.py | 81 ++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/elbepack/commands/check-build.py b/elbepack/commands/check-build.py
index b21d5060..d918b1cc 100644
--- a/elbepack/commands/check-build.py
+++ b/elbepack/commands/check-build.py
@@ -7,6 +7,7 @@ import glob
import logging
import optparse
import os
+import shutil
import tempfile
import traceback
@@ -531,3 +532,83 @@ class CheckImage(CheckBase):
return ret or child.exitstatus
+ at CheckBase.register("sdk")
+class CheckSDK(CheckBase):
+ """Check if SDK is working"""
+
+ script = b"""
+set -x
+
+mkdir project
+
+. $ELBE_SDK_ENV
+
+cd project || exit 1
+
+touch README
+
+cat -> hello.c <<EOF
+#include <stdio.h>
+int main(void)
+{
+ printf("Hello World!");
+ return 0;
+}
+EOF
+
+cat -> configure.ac <<EOF
+AC_INIT(hello,0.1)
+AM_INIT_AUTOMAKE([foreign])
+AC_PROG_CC
+AC_CONFIG_FILES(Makefile)
+AC_OUTPUT
+EOF
+
+cat -> Makefile.am <<EOF
+bin_PROGRAMS = hello
+hello_SOURCES = hello.c
+hello_LDFLAGS = -static
+EOF
+
+autoreconf -i
+
+./configure ${CONFIGURE_FLAGS}
+
+make
+make install DESTDIR=./tmp
+
+out=$(./hello)
+
+if [ $? -eq 0 ] && [ "$out" = "Hello World!" ] ;
+then
+ exit 0
+fi
+exit 1
+"""
+
+ def do_sdk(self, sdk):
+
+ with TmpdirFilesystem() as tmp:
+
+ # Make a copy of the installer
+ shutil.copyfile(sdk, tmp.fname(sdk))
+
+ # Let's work in our temp dir from now on
+ os.chdir(tmp.path)
+
+ # The script is self extracting; it needs to be executable
+ os.chmod(sdk, 0o744)
+
+ # Extract here with 'yes' to all answers
+ do("./%s -y -d ." % sdk)
+
+ # Get environment file
+ env = tmp.glob("environment-setup*")[0]
+
+ # NOTE! This script requires binfmt to be installed.
+ do("/bin/sh", stdin=self.script, env_add={"ELBE_SDK_ENV": env})
+
+ def run(self):
+ for sdk in glob.glob("setup-elbe-sdk*"):
+ self.do_sdk(sdk)
+
--
2.28.0
More information about the elbe-devel
mailing list