From cc7d1086c5db0174fdf06791e5a4fad2f2d416dc Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Thu, 15 Sep 2016 15:46:50 +0200 Subject: [PATCH 1/5] bake.py: add warning if building on unsupported os Print a warning if building on unsupported os. The warning triggers a prompt asking to continue or abort build. Use '-s' (--skip-os-check) option to automatically continue build. To add a supported OS see core/setup directory. Files can also be added in a setup folder in local meta layer. To unsupport an OS add a setup file with only the distro-release line (keep only the first line). It would be handy to have a feature to disable all other setup folders but the one in local layer. But so far this has not been implemented. --- lib/oelite/cmd/bake.py | 45 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/lib/oelite/cmd/bake.py b/lib/oelite/cmd/bake.py index 24d48083..4e1cd116 100644 --- a/lib/oelite/cmd/bake.py +++ b/lib/oelite/cmd/bake.py @@ -1,7 +1,9 @@ import oebakery import oelite.baker import logging - +import setup +import os +import sys description = "Build something" @@ -14,6 +16,9 @@ def add_parser_options(parser): parser.add_option("--debug-loglines", action="store", default=42, metavar="N", help="Show last N lines of logfiles of failed tasks (default: 42)") + parser.add_option("-s", "--skip-os-check", + action="store_true", default=False, metavar="skip_os_check", + help="Skip supported OS check") return @@ -23,8 +28,46 @@ def parse_args(options, args): else: logging.getLogger().setLevel(logging.INFO) +def os_check(config): + distro, release = setup.get_host_distro() + if distro and release: + setup_file, supported = setup.get_setup_file(config, distro, release) + if supported: + return True + + if distro and release: + print('WARNING: Host distribution (%s %s) has not been validated'%(distro, release)) + else: + print("WARNING: Cannot determine host distribution") + + response = 'n' + + if os.isatty(sys.stdin.fileno()): + while True: + try: + response = raw_input( + "Do you want to continue [Y/n]? ") + except KeyboardInterrupt: + print + response = 'n' + response = response.lower() + if response == '': + response = 'y' + if response in ('y', 'n'): + print + break + + if response == 'n': + print "Maybe another time" + return False + return True def run(options, args, config): + + if not options.skip_os_check: + if not os_check(config): + return 1 + try: baker = oelite.baker.OEliteBaker(options, args, config) except oelite.parse.ParseError as e: From c9e02cca4ba3217f69375d0295916e11f2ca8e3f Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Fri, 30 Sep 2016 15:40:52 +0200 Subject: [PATCH 2/5] setup: add ubuntu_16_04 --- setup/ubuntu_16.04 | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 setup/ubuntu_16.04 diff --git a/setup/ubuntu_16.04 b/setup/ubuntu_16.04 new file mode 100644 index 00000000..8690f130 --- /dev/null +++ b/setup/ubuntu_16.04 @@ -0,0 +1,2 @@ +# Ubuntu 16.04 +sudo apt-get --yes install python python-magic python-pycurl python-pkg-resources python-dev coreutils sed git-core cvs subversion mercurial quilt gawk texinfo automake autoconf autopoint libtool curl texi2html diffstat openjade groff mtd-utils build-essential make gcc g++ binutils bison flex bc ncurses-dev zip unzip lzma gtk-doc-tools docbook-utils libxml2-utils xmlto help2man libglib2.0-dev lzop gperf python-svn libacl1-dev fakeroot cpio From 651154f197939bfce403a1d124018e6b37bc065a Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Fri, 30 Sep 2016 16:00:56 +0200 Subject: [PATCH 3/5] setup: add ubuntu 15.10 --- setup/ubuntu_15.10 | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 setup/ubuntu_15.10 diff --git a/setup/ubuntu_15.10 b/setup/ubuntu_15.10 new file mode 100644 index 00000000..cc35e4fe --- /dev/null +++ b/setup/ubuntu_15.10 @@ -0,0 +1,2 @@ +# Ubuntu 15.04 +sudo apt-get --yes install python-support python-magic python-pycurl python-pkg-resources python-dev coreutils sed git-core cvs subversion mercurial quilt gawk texinfo automake autoconf autopoint libtool curl texi2html diffstat openjade groff mtd-utils build-essential make gcc g++ binutils bison flex bc ncurses-dev zip unzip lzma gtk-doc-tools docbook-utils libxml2-utils xmlto help2man libglib2.0-dev lzop gperf python-svn libacl1-dev From c448e6ed8c702f8ea0c01592e450c34af6bb973f Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Mon, 7 Nov 2016 14:54:12 +0100 Subject: [PATCH 4/5] setup: add debian 8 --- setup/debian_8 | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 setup/debian_8 diff --git a/setup/debian_8 b/setup/debian_8 new file mode 100644 index 00000000..3adfc383 --- /dev/null +++ b/setup/debian_8 @@ -0,0 +1,2 @@ +# Debian 8.x +sudo apt-get install -y apt-utils sudo ssh-client git subversion python-ply python-setuptools python-pysqlite2 python-magic python-pycurl python-svn python-dev build-essential wget bzip2 zip unzip quilt autoconf automake libtool pkg-config gawk bison flex texinfo curl ncurses-dev groff-base cpio intltool liblzo2-2 bc gperf tree From c6a528a9818086b2eff035f3177f38d38fb467bd Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Fri, 11 Nov 2016 10:25:46 +0100 Subject: [PATCH 5/5] setup: add fallback check for multiple host distros If lsb-release is not present on system try to get host distro from distro specific release or version files. Add check for: * Ubuntu 16.04 * Ubuntu 15.10 * Ubuntu 15.04 * Debian 8 * Debian 7 --- lib/oelite/cmd/setup.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/oelite/cmd/setup.py b/lib/oelite/cmd/setup.py index 27093007..9c914412 100644 --- a/lib/oelite/cmd/setup.py +++ b/lib/oelite/cmd/setup.py @@ -114,8 +114,22 @@ def retval(f): setup_file = oelite.path.which(oepath, os.path.join('setup', distro)) return retval(setup_file) +def check_release_from_file(file, pattern=""): + try: + logging.debug("Checking for distro %s in %s", pattern, file) + if (os.path.exists(file) and + os.path.isfile(file)): + if (len(pattern) == 0): return True + release_info = open(file, 'r').read() + return (re.findall(pattern, release_info) > 0) + except: + logging.debug("Error while handling release file") + + return False + def get_host_distro(): logging.debug("Running host distribution detection") + logging.debug("Searching for lsb_release information") # try lsb-release which is the most widely available method logging.debug("Checking for the lsb_release binary") @@ -145,6 +159,27 @@ def get_host_distro(): logging.debug("No lsb_release information available") logging.debug("Checking for other known host distributions") + + logging.debug("Checking for Ubuntu 16.04") + if (check_release_from_file("/etc/lsb-release", "Ubuntu 16.04")): + return "ubuntu", "16.04" + + logging.debug("Checking for Ubuntu 15.10") + if (check_release_from_file("/etc/lsb-release", "Ubuntu 15.10")): + return "ubuntu", "15.10" + + logging.debug("Checking for Ubuntu 15.04") + if (check_release_from_file("/etc/lsb-release", "Ubuntu 15.04")): + return "ubuntu", "15.04" + + logging.debug("Checking for Debian 8") + if (check_release_from_file("/etc/debian_version", "8\..*")): + return "debian", "8" + + logging.debug("Checking for Debian 7") + if (check_release_from_file("/etc/debian_version", "7\..*")): + return "debian", "7" + logging.debug("Checking for Exherbo") if (os.path.exists("/etc/exherbo-release") and os.path.isfile("/etc/exherbo-release")):