[yocto] [yocto-autobuilder][PATCH v1 4/4] GetDeployDir.py/PublishArtifacts.py: get deploy dir from bitbake
stefan at agner.ch
stefan at agner.ch
Thu May 8 09:44:28 PDT 2014
From: Stefan Agner <stefan at agner.ch>
Since the deploy dir is configureable (also through TMPDIR), we
need to have a more generic variant to get that path. Also the
Ångstrom distribution adds "-eglibc" to the TMPDIR. Hence, the
safest way to get the deployment dir is to parse buildbots
environment.
Signed-off-by: Stefan Agner <stefan at agner.ch>
---
.../autobuilder/buildsteps/GetDeployDir.py | 47 +++++++++++++++++++++
.../autobuilder/buildsteps/PublishArtifacts.py | 48 ++++++++++++----------
2 files changed, 73 insertions(+), 22 deletions(-)
create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/GetDeployDir.py
diff --git a/lib/python2.7/site-packages/autobuilder/buildsteps/GetDeployDir.py b/lib/python2.7/site-packages/autobuilder/buildsteps/GetDeployDir.py
new file mode 100644
index 0000000..944fcf0
--- /dev/null
+++ b/lib/python2.7/site-packages/autobuilder/buildsteps/GetDeployDir.py
@@ -0,0 +1,47 @@
+'''
+Created on Mai 8, 2014
+
+__author__ = "Stefan Agner"
+__copyright__ = "Copyright 2014, Toradex AG"
+__credits__ = ["Stefan Agner"]
+__license__ = "GPL"
+__version__ = "2.0"
+__maintainer__ = "Stefan Agner"
+__email__ = "stefan at agner.ch"
+'''
+from buildbot.steps.shell import ShellCommand
+from buildbot.status import progress
+from buildbot.status.results import SUCCESS, FAILURE, WARNINGS
+from buildbot.process.properties import WithProperties
+from twisted.python import log
+from autobuilder.config import *
+
+class GetDeployDir(ShellCommand):
+ haltOnFailure = False
+ flunkOnFailure = True
+ name = "GetDeployDir"
+ def __init__(self, factory, argdict=None, **kwargs):
+ for k, v in argdict.iteritems():
+ setattr(self, k, v)
+ self.description = "Get Deploy Directory"
+ self.deploydir = None
+ ShellCommand.__init__(self, **kwargs)
+
+ def start(self):
+ cmd = '. ./oe-init-build-env; bitbake -e | grep "^DEPLOY_DIR="'
+ self.command = cmd
+ ShellCommand.start(self)
+
+ def commandComplete(self, cmd):
+ if cmd.didFail():
+ return
+ result = cmd.logs['stdio'].getText()
+ if "=" not in result:
+ self.finished(FAILURE)
+ param, value = result.split("=")
+ deploydir = value.replace('"', '').strip()
+ self.setProperty('deploydir', deploydir, "Setting Deploy Directory")
+ self.finished(SUCCESS)
+
+ def getText(self, cmd, results):
+ return ShellCommand.getText(self, cmd, results)
diff --git a/lib/python2.7/site-packages/autobuilder/buildsteps/PublishArtifacts.py b/lib/python2.7/site-packages/autobuilder/buildsteps/PublishArtifacts.py
index ebc761f..303df36 100644
--- a/lib/python2.7/site-packages/autobuilder/buildsteps/PublishArtifacts.py
+++ b/lib/python2.7/site-packages/autobuilder/buildsteps/PublishArtifacts.py
@@ -19,10 +19,10 @@ class PublishArtifacts(ShellCommand):
haltOnFailure = False
flunkOnFailure = True
- name = "Publishing Artifacts"
+ name = "PublishArtifacts"
+ description = "Publishing Artifacts"
def __init__(self, factory, argdict=None, **kwargs):
self.factory = factory
- self.description = "Publishing Artifacts"
self.slavedir=os.path.join(os.path.join(YOCTO_ABBASE, "yocto-slave"))
for k, v in argdict.iteritems():
if type(v) is bool:
@@ -42,10 +42,14 @@ class PublishArtifacts(ShellCommand):
self.layerversion_yoctobsp = self.getProperty("layerversion_yoctobsp")
self.layerversion_yocto = self.getProperty("layerversion_yocto")
self.layerversion_core = self.getProperty("layerversion_core")
+ self.deploydir = self.getProperty("deploydir")
log.msg(layerversion_yoctobsp)
- self.basedir=os.path.join(os.path.join(
- self.slavedir, buildername),
- "build/build/")
+ self.basedir = os.path.join(self.slavedir, buildername, "build/build/")
+
+ # Deploydir might not be set in case the step did not run, fallback to default
+ if self.deploydir is None:
+ self.deploydir = os.path.join(self.basedir, "tmp/deploy/")
+
command=""
DATESTAMP=datetime.datetime.now().strftime("%Y%m%d")
if str(os.environ.get('PUBLISH_BUILDS')) == "True":
@@ -70,17 +74,17 @@ class PublishArtifacts(ShellCommand):
if artifact == "adt-installer":
command=command+"mkdir -p " + os.path.join(DEST, ADT_INST_PUBLISH_DIR) + ";"
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/sdk/") + \
+ os.path.join(self.deploydir, "sdk/") + \
"*adt* " + os.path.join(DEST, ADT_INST_PUBLISH_DIR) + ";"
elif artifact == "adt-installer-QA":
command=command+"mkdir -p " + os.path.join(DEST, ADTQA_INST_PUBLISH_DIR) + ";"
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/sdk/") + \
+ os.path.join(self.deploydir, "sdk/") + \
"*adt* " + os.path.join(DEST, ADTQA_INST_PUBLISH_DIR)+ ";"
elif artifact == "adtrepo-dev":
adt_dev_dest= os.environ.get("ADTREPO_DEV_PATH") + "/" + distroversion + "-" + got_revision_poky + '-' + self.getProperty("branch_poky")
command=command+"mkdir -p " + adt_dev_dest + "/adt-ipk;"
- command=command+"rsync -av " + os.path.join(self.basedir, "tmp/deploy/ipk/") + " " + adt_dev_dest + "/adt-ipk;"
+ command=command+"rsync -av " + os.path.join(self.deploydir, "ipk/") + " " + adt_dev_dest + "/adt-ipk;"
command=command+"rm -rf " + adt_dev_dest + "/rootfs; mkdir -p " + adt_dev_dest + "/rootfs;"
command=command+"for x in `ls " + DEST + "/machines/qemu/|grep -v tiny`; do ln -s " + DEST + "/machines/qemu/$x " + adt_dev_dest + "/rootfs/$x; done;"
if self.layerversion_yocto is not None and int(self.layerversion_yocto) < 2:
@@ -101,49 +105,49 @@ class PublishArtifacts(ShellCommand):
command=command+"mkdir -p " + DEST + "/" + BA_PUBLISH_DIR + ";"
if self.layerversion_core is not None and int(self.layerversion_core) > 2:
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/images/qemux86-64/*.zip") + \
+ os.path.join(self.deploydir, "images/qemux86-64/*.zip") + \
" " + DEST + "/" + BA_PUBLISH_DIR + ";"
else:
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/images/*.zip") + \
+ os.path.join(self.deploydir, "images/*.zip") + \
" " + DEST + "/" + BA_PUBLISH_DIR + ";"
elif artifact == "buildtools-tarball":
command=command+"mkdir -p " + DEST + "/buildtools;"
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/sdk/*.sh") + \
+ os.path.join(self.deploydir, "sdk/*.sh") + \
" " + DEST + "/buildtools;"
elif artifact == "rpm":
command=command+"mkdir -p " + os.path.join(DEST, RPM_PUBLISH_DIR) + ";"
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/rpm/* ") + \
+ os.path.join(self.deploydir, "rpm/* ") + \
os.path.join(DEST, RPM_PUBLISH_DIR) + ";"
elif artifact == "deb":
command=command+"mkdir -p " + os.path.join(DEST, DEB_PUBLISH_DIR) + ";"
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/deb/* ") + \
+ os.path.join(self.deploydir, "deb/* ") + \
os.path.join(DEST, DEB_PUBLISH_DIR) + ";"
elif artifact == "ipk":
command=command+"mkdir -p " + os.path.join(DEST, IPK_PUBLISH_DIR) + ";"
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/ipk/* ") + \
+ os.path.join(self.deploydir, "ipk/* ") + \
os.path.join(DEST, IPK_PUBLISH_DIR) + ";"
elif artifact == "toolchain":
command=command+"mkdir -p " + os.path.join(DEST, X86TC_PUBLISH_DIR) + ";"
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/sdk/poky-eglibc-i686* ") + \
+ os.path.join(self.deploydir, "sdk/poky-eglibc-i686* ") + \
os.path.join(DEST, X86TC_PUBLISH_DIR) + ";"
command=command+"mkdir -p " + os.path.join(DEST, X8664TC_PUBLISH_DIR) + ";"
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/sdk/poky-eglibc-x86_64* ") + \
+ os.path.join(self.deploydir, "sdk/poky-eglibc-x86_64* ") + \
os.path.join(DEST, X8664TC_PUBLISH_DIR) + ";"
elif artifact == "oe-toolchain":
command=command+"mkdir -p " + os.path.join(DEST, X86TC_PUBLISH_DIR) + ";"
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/sdk/oecore-i686* ") + \
+ os.path.join(self.deploydir, "sdk/oecore-i686* ") + \
os.path.join(DEST, X86TC_PUBLISH_DIR) + ";"
command=command+"mkdir -p " + os.path.join(DEST, X8664TC_PUBLISH_DIR) + ";"
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/sdk/oecore-x86_64* ") + \
+ os.path.join(self.deploydir, "sdk/oecore-x86_64* ") + \
os.path.join(DEST, X8664TC_PUBLISH_DIR) + ";"
elif "qemu" in artifact:
@@ -162,11 +166,11 @@ class PublishArtifacts(ShellCommand):
command=command+"mkdir -p " + DEST + "/" + QEMU_PUBLISH_DIR + "/qemu-tiny;"
if self.layerversion_core is not None and int(self.layerversion_core) > 2:
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/images/qemux86/* ") + \
+ os.path.join(self.deploydir, "images/qemux86/* ") + \
" " + DEST + "/" + QEMU_PUBLISH_DIR + "/qemu-tiny;"
else:
command=command+"cp -R --no-dereference --preserve=links " + \
- os.path.join(self.basedir, "tmp/deploy/images/*") + \
+ os.path.join(self.deploydir, "images/*") + \
DEST + "/" + QEMU_PUBLISH_DIR + "/qemu-tiny;"
elif artifact == "conf":
artifact_name, deploy_image_dir = self.getDeployNames(artifact, buildername)
@@ -208,9 +212,9 @@ class PublishArtifacts(ShellCommand):
if "-lsb" in buildername:
artifact_name = artifact_name + "-lsb"
if self.layerversion_core is not None and int(self.layerversion_core) > 2:
- deploy_dir_image = os.path.join(os.path.join(self.basedir, "tmp/deploy/images/"), artifact)
+ deploy_dir_image = os.path.join(os.path.join(self.deploydir, "images/"), artifact)
else:
- deploy_dir_image = os.path.join(self.basedir, "tmp/deploy/images/")
+ deploy_dir_image = os.path.join(self.deploydir, "images/")
return artifact_name, deploy_dir_image
def describe(self, done=False):
--
1.9.0
More information about the yocto
mailing list