diff options
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/runbitbake.py | 148 | ||||
-rw-r--r-- | helpers/startOstroScript.sh | 42 |
2 files changed, 0 insertions, 190 deletions
diff --git a/helpers/runbitbake.py b/helpers/runbitbake.py deleted file mode 100644 index 96c55dc..0000000 --- a/helpers/runbitbake.py +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/python - -# runbitbake.py -# -# Copyright (C) 2016 Intel Corporation -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import argparse -import subprocess -import os -import tempfile -import shutil -import sys -import signal - -bitbake_process = None - -old_handler = {} -old_handler[str(signal.SIGINT)] = signal.getsignal(signal.SIGINT) -old_handler[str(signal.SIGTERM)] = signal.getsignal(signal.SIGTERM) - - -def addextra(tempdir, builddir, name, extralist): - myf = "{}/conf/{}".format(builddir, name) - myf_orig = "{}/{}.orig".format(tempdir, name) - tmpfile = "{}/{}.orig.tmp".format(tempdir, name) - - # copy isn't atomic so make sure that orig is created atomically so that - # file.orig is always correct even if file gets hosed. So that - # means if a user ever sees file.orig, they can be assured that it - # is the same as the original file with no corruption. - shutil.copyfile(myf, tmpfile) - with open(tmpfile, "r") as f: - fd = f.fileno() - os.fdatasync(fd) - - # Remember first sync the file AND directory to make sure data - # is written out - fd = os.open(os.path.dirname(tmpfile), os.O_RDONLY) - os.fsync(fd) - os.close(fd) - - # Rename should be atomic with respect to disk, yes all of this assumes - # linux and possibly non-network filesystems. - os.rename(tmpfile, myf_orig) - - with open(myf, "a") as f: - if extralist: - for conf in extralist: - with open(conf) as f2: - content = f2.readlines() - for l in content: - f.write("%s\n" % format(l.strip())) - - -def restore_files(tempdir, builddir, conffiles): - for f in conffiles: - dest = os.path.join(builddir, "conf", f) - src = os.path.join(tempdir, f + ".orig") - - if os.path.exists(src): - os.rename(src, dest) - - -# If bitbake is around let it do all the signal handling -def handler(signum, frame): - if bitbake_process: - # SIGINT is special if there is a tty. Because with a tty SIGINT will - # automatically get sent to all processes in the process group. So we - # don't need to send it ourselves. - if signum == signal.SIGINT and sys.stdin.isatty(): - pass - else: - # If there is a bitbake process we want to let it tear down all - # its children itself so send the signal to bitbake. - bitbake_process.send_signal(signum) - else: - old_handler[str(signum)](signum, frame) - - -if __name__ == '__main__': - signal.signal(signal.SIGINT, handler) - signal.signal(signal.SIGTERM, handler) - - parser = argparse.ArgumentParser() - - parser.add_argument("--extraconf", action='append', help="File containing" - "extra configuration") - parser.add_argument("--extralayers", action='append', - help="File containing extra bblayers") - - parser.add_argument("--pokydir", default="/home/yoctouser/poky", - required=True, help="Directory containing poky") - parser.add_argument("--target", "-t", required=True, - help="What bitbake should build") - parser.add_argument("--builddir", "-b", required=True, - help="Directory to build in") - - args = parser.parse_args() - - builddir = args.builddir - - if not os.path.isdir(builddir): - os.makedirs(builddir) - - # tempdir is a subdirectory of builddir in case builddir and local.conf - # already existed. Then if something goes wrong with local.conf the user - # can restore it by using builddir/tempdir/local.conf.orig - tempdir = tempfile.mkdtemp(prefix="runbitbake-tmpdir", dir=builddir) - - # Have to use bash since the default on ubuntu is dash which is garbage - try: - cmd = 'bash -c ". {}/oe-init-build-env {}"'.format(args.pokydir, - builddir) - subprocess.check_call(cmd, stdout=sys.stdout, stderr=sys.stderr, - shell=True) - - try: - addextra(tempdir, builddir, "local.conf", args.extraconf) - addextra(tempdir, builddir, "bblayers.conf", args.extralayers) - - cmd = '. {}/oe-init-build-env {} && '.format(args.pokydir, - builddir) - cmd += 'exec bitbake {}'.format(args.target) - bitbake_process = subprocess.Popen(['/bin/bash', '-c', cmd], - stdout=sys.stdout, - stderr=sys.stderr, shell=False) - bitbake_process.wait() - finally: - restore_files(tempdir, builddir, ["local.conf", "bblayers.conf"]) - - except subprocess.CalledProcessError as e: - print e - - finally: - shutil.rmtree(tempdir, ignore_errors=True) diff --git a/helpers/startOstroScript.sh b/helpers/startOstroScript.sh deleted file mode 100644 index 49a1dd1..0000000 --- a/helpers/startOstroScript.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -POKY_DIR=/ostro/ostro-os/ -EXTRA_CONF=/ostro/ostro-shared/conf/ostro.conf -BUILD_DIR=/ostro/build/ -EXTRA_LAYERS=/ostro/ostro-shared/conf/ostro.layers - -H_UID=$(ls -al /ostro/ostro-shared/ | egrep "\."|egrep -v "\.\." | awk '{print $3}') -H_USER=$(getent passwd "$H_UID" | cut -d: -f1) -if [ "$H_USER" == "" ]; then - H_USER="yoctobuilder" - /usr/sbin/useradd -m -u ${H_UID} ${H_USER} -fi - -# provide the ostro.conf if there isn't one yet -if [ ! -f ${EXTRA_CONF} ]; then - mkdir -p /ostro/ostro-shared/conf - cp /ostro/sample-conf/ostro.conf ${EXTRA_CONF} -fi - -# provide ostro.layers if there isn't one yet -if [ ! -f ${EXTRA_LAYERS} ]; then - mkdir -p /ostro/ostro-shared/conf - cp /ostro/sample-conf/ostro.layers ${EXTRA_LAYERS} -fi - -mkdir -p /ostro/ostro-shared/images/ -chmod a+rwx /ostro/ostro-shared/images/ -chmod a+rwx /ostro/ostro-shared/conf -chmod a+rw ${EXTRA_CONF} - - -# switch into user to build -sudo --user ${H_USER} /ostro/bin/runbitbake.py --pokydir $POKY_DIR --extraconf $EXTRA_CONF --extralayers $EXTRA_LAYERS -b $BUILD_DIR -t $* -echo "copying images to shared folder" - -# we need to source the bitbake env in order to use the bitbake script to find the images -cd ${BUILD_DIR} -source ${POKY_DIR}/oe-init-build-env >> /dev/null -CON_DIR=`bitbake -e | egrep "DEPLOY_DIR_IMAGE\="|tr "\=" " " | tr -d "\""| awk '{print $2}'` -rsync -a ${CON_DIR} /ostro/ostro-shared/images/ > /dev/null 2>&1 - - |