@@ -1 +1 @@
-manifest_cmds = [ "bake", "show", "cherry" ]
+manifest_cmds = [ "bake", "setup", "show", "cherry" ]
new file mode 100644
@@ -0,0 +1,145 @@
+import oebakery
+from oelite import util
+from oebakery import info
+import logging
+import os
+import subprocess
+import oelite
+import bb
+import glob
+import sys
+
+description = "Host preparation tool"
+arguments = ()
+
+def add_parser_options(parser):
+ parser.add_option("-l", "--list",
+ action="store_true", default=False,
+ help="Show a list of known host configurations")
+ parser.add_option("-p", "--printcmd",
+ action="store_true", default=False,
+ help="Print the command needed to prepare the host for OE-lite")
+ parser.add_option("-d", "--debug",
+ action="store_true", default=False,
+ help="Verbose output")
+ return
+
+
+def parse_args(options, args):
+ if options.debug:
+ logging.getLogger().setLevel(logging.DEBUG)
+ else:
+ logging.getLogger().setLevel(logging.INFO)
+ if args:
+ options.head = args.pop(0)
+ else:
+ options.head = None
+ return
+
+def get_host_configs(distro, release, config):
+ if(release == "unknown"):
+ release = "none"
+ logging.debug("Reading host configuration for: %s-%s", distro, release)
+ oepath = config.get("OEPATH")
+ logging.debug("Searching for setup in paths; %s", oepath)
+ if(distro == "all"):
+ path = bb.utils.which(oepath, "setup/")
+ files = glob.glob(path+"*")
+ else:
+ files = bb.utils.which(oepath, "setup/"+distro+"_"+release)
+ logging.debug("Found file(s): "+str(files))
+ return files
+
+def determine_host(oeconfig):
+ logging.debug("Running host detection")
+ logging.debug("Searching for lsb_release information")
+ #try lsb-release which is the most widely available method
+ try:
+ logging.debug("checking for the lsb_release binary")
+ subprocess.call(["lsb_release"])
+ except OSError as e:
+ if e.errno == os.errno.ENOENT:
+ # handle file not found error.
+ logging.debug("lsb_release binary not available")
+ else:
+ logging.debug("unhandled exception when calling lsb_release")
+ raise
+ else:
+ try:
+ logging.debug("using lsb_release to get host information")
+ #strip newlines and make lowercase for later matching
+ distro = oelite.util.shcmd("lsb_release -si", quiet=True)[:-1].lower()
+ release = oelite.util.shcmd("lsb_release -sr", quiet=True)[:-1].lower()
+ except:
+ logging.debug("unhandled exception when calling lsb_release")
+ raise
+ else:
+ logging.debug("lsb_release: distro: %s | release: %s", distro, release)
+ return distro, release
+
+ logging.debug("No lsb_release information available - checking for other known host configurations")
+ logging.debug("Checking for Exherbo")
+ if(os.path.exists("/etc/exherbo-release") and os.path.isfile("/etc/exherbo-release")):
+ return "exherbo", "unknown"
+ logging.debug("No host information for this host")
+ return "unknown","unknown"
+
+def run(options, args, config):
+ logging.debug("setup.run %s", options)
+
+ if(options.list):
+ print "List of known host configurations:\n"
+ hosts = get_host_configs("all", "", config)
+ logging.debug("got following config files: ")
+ logging.debug(hosts)
+ for host in hosts:
+ file = host.split("/")[-1]
+ distro = file.split("_")[0]
+ release = file.split("_")[1]
+ print '{0:8}{1:15}{2:9}{3:15}{4:18}{5}'.format("Distro:", distro, "Release:", release, "Setup command in: ", host)
+ return 0
+
+ #try automatic host detection
+ distro, release = determine_host(config)
+ if(options.printcmd):
+ logging.debug("printing command for distro: %s release: %s", distro, release)
+ cmd_file = get_host_configs(distro, release, config)
+ cmd = open(cmd_file, 'r').read()[:-1]
+ logging.debug("Command: '%s'", cmd)
+ print cmd
+ return 0
+ if(distro == "unknown"):
+ info("Your host is not known by the oe setup tool.")
+ info("Try running 'oe setup -l' to see if a known configuration could match your host")
+ return 0
+
+ info("Your host configuration detected to be:\n")
+ info("Distro: "+distro+"\nRelease: "+release+"\n")
+ #try exact match
+ cmd_file = get_host_configs(distro, release, config)
+ if(not cmd_file):
+ #try major version match
+ cmd_file = get_host_configs(distro, release[0]+"*", config)
+ if(not cmd_file):
+ info("Your distribution is known, but the release can not be matched to any known configuration")
+ info("Try running 'oe setup -l' to see if a known configuration could match your host")
+ return 0
+ cmd = open(cmd_file, 'r').read()[:-1]
+ info("The following command will setup your host for OE-lite:\n")
+ info(cmd)
+ if os.isatty(sys.stdin.fileno()):
+ while True:
+ try:
+ response = raw_input("\nDo you want to run this command [Yes/yes/no]? ")
+ except KeyboardInterrupt:
+ response = "no"
+ if response in ("yes", "Yes"):
+ print ""
+ oelite.util.shcmd("set -ex", quiet=True)
+ oelite.util.shcmd(cmd, quiet=False)
+ break
+ else:
+ info("Not running command - answer strictly 'yes' or 'Yes' to run the command automatically")
+ return 0
+
+ return 0
new file mode 100644
@@ -0,0 +1,2 @@
+sudo yum groupinstall "Development Tools"
+sudo yum install python-sqlite2 python-magic python-pycurl python-devel fakeroot gettext-devel ncurses-devel libtool texinfo flex bison coreutils sed git-core cvs subversion mercurial quilt gawk texinfo automake autoconf curl openjade groff make gcc-c++ gcc binutils bc unzip gtk-doc docbook-utils xmlto glib2-devel intltool glibc-static gperf
new file mode 100644
@@ -0,0 +1 @@
+sudo cave resolve oe-bakery
new file mode 100644
@@ -0,0 +1 @@
+sudo apt-get install python python-support python-magic python-ply python-pycurl python-pysqlite2 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 unzip lzma gtk-doc-tools docbook-utils libxml2-utils xmlto help2man libglib2.0-dev lzop gperf python-svn
From: Kim Højgaard-Hansen <kiho@prevas.dk> The setup command can show/execute the command needed to prepare a host for OE-lite. A file for each supported host configuration must be added to the setup directory in the core metadata layer. The file should contain the command for installing the dependencies needed for using oe-lite. The file name should be: 'distro_release' as defined by the lsb_release tool. If no release exist it should be "none" The lsb_release tool is used for automatic host detection. A list of the known host configurations can be shown using 'oe setup -l' If only the setup command for the current host should be printed, run 'oe setup -p' Using this tool we can let the needed dependencies for oe-lite be recorded along meta/core versions. It is also possible that we need to explitly say that some host configuration will not work with oe-lite. To do this, add a host configuration file for that host with e.g.: 'echo "This host is not supported by this version of OE-lite. Use 'oe setup -l' to get a list of known host configurations"' --- lib/oelite/cmd/__init__.py | 2 +- lib/oelite/cmd/setup.py | 145 +++++++++++++++++++++++++++++++++++++++++++++ setup/centos_6.4 | 2 + setup/exherbo_none | 1 + setup/ubuntu_12.04 | 1 + 5 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 lib/oelite/cmd/setup.py create mode 100644 setup/centos_6.4 create mode 100644 setup/exherbo_none create mode 100644 setup/ubuntu_12.04