Skip to content
This repository was archived by the owner on Jan 27, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion lib/oelite/cmd/bake.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import oebakery
import oelite.baker
import logging

import setup
import os
import sys

description = "Build something"

Expand All @@ -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


Expand All @@ -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")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this stuff does not really belong in bake. Let us make good use of OO and keep the responsibility for the logic about support host OS in the setup code.

What is needed is a refactor of the setup code, so you can simply ask it from bake "are we running on a supported host OS", probably something like a "is_supported()" method or the like. The rest of the setup code should of cause use that as well


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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this a duplication of the other place where we interactively ask if we should continue?

Let us not do that, we already have a mess of duplication and responsibility in the code. Please refactor this out to a place where it can be used by commands that need it.


def run(options, args, config):

if not options.skip_os_check:
if not os_check(config):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is basically what I would imagine should be needed in bake, but by calling into the setup code.

return 1

try:
baker = oelite.baker.OEliteBaker(options, args, config)
except oelite.parse.ParseError as e:
Expand Down
35 changes: 35 additions & 0 deletions lib/oelite/cmd/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")):
Expand Down
2 changes: 2 additions & 0 deletions setup/debian_8
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions setup/ubuntu_15.10
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions setup/ubuntu_16.04
Original file line number Diff line number Diff line change
@@ -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