devtool: upgrade feature
v3 cover devtool: upgrade feature
From: Leonardo Sandoval <[email protected]>
The following changes were made since V2:
- Some code packed into functions
- Change '_' to '-' on branch and tag names (per Paul suggestion
- New recipe under meta-selftest so unit tests (oe-selftest) do not depend on real recipes (also, Anibal/Paul suggestion)
The following changes since commit 393bd7496d71eb101f21234c1233a2d18fd2c73e:
oeqa/oetest.py: add better package search for hasPackage() (2015-08-26 08:28:06 +0100)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib lsandov1/devtool-upgrade
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=lsandov1/devtool-upgrade
Leonardo Sandoval (3):
devtool: upgrade feature
devtool-upgrade: sample recipe to test the devtool feature oeqa/selftest: new tests for devtool upgrage feature
.../recipes-test/devtool/devtool-upgrade_0.1.bb | 25 ++ ...-exit-with-EXIT_SUCCESS-instead-of-a-magi.patch | 27 ++ .../devtool/files/devtool-upgrade-0.1.tar.gz | Bin 0 -> 411 bytes .../devtool/files/devtool-upgrade-0.2.tar.gz | Bin 0 -> 411 bytes meta/lib/oeqa/selftest/devtool.py | 36 +++ scripts/lib/devtool/standard.py | 4 +- scripts/lib/devtool/upgrade.py | 356 +++++++++++++++++++++ 7 files changed, 447 insertions(+), 1 deletion(-) create mode 100644 meta-selftest/recipes-test/devtool/devtool-upgrade_0.1.bb create mode 100644 meta-selftest/recipes-test/devtool/files/0001-helloword.c-exit-with-EXIT_SUCCESS-instead-of-a-magi.patch create mode 100644 meta-selftest/recipes-test/devtool/files/devtool-upgrade-0.1.tar.gz create mode 100644 meta-selftest/recipes-test/devtool/files/devtool-upgrade-0.2.tar.gz create mode 100644 scripts/lib/devtool/upgrade.py
Signature · 1 line
1.8.4.5
PATCH v3 1/3 devtool: upgrade feature
From: Leonardo Sandoval <[email protected]>
Upgrades a recipe to a particular version and downloads the source code into a folder. User can avoid patching the source code.
These are the general steps of the upgrade function:
- Extract current recipe source code into srctree and create a branch
- Extract upgrade recipe source code into srctree and rebase with previous branch. In case the rebase is not correctly applied, source code will not be deleted, so user correct the patches
- Creates the new recipe under the workspace
[YOCTO #7642]
--- scripts/lib/devtool/standard.py | 4 +- scripts/lib/devtool/upgrade.py | 356 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 359 insertions(+), 1 deletion(-) create mode 100644 scripts/lib/devtool/upgrade.py
scripts/lib/devtool/standard.py +3 -1
@@ -205,6 +205,8 @@ def extract(args, config, basepath, workspace): srctree = os.path.abspath(args.srctree) initial_rev = _extract_source(srctree, args.keep_temp, args.branch, rd) + logger.info('Source tree extracted to %s' % srctree) + if initial_rev: return 0 else:
@@ -361,7 +363,6 @@ def _extract_source(srctree, keep_temp, devbranch, d): bb.process.run('git checkout patches', cwd=srcsubdir) shutil.move(srcsubdir, srctree) - logger.info('Source tree extracted to %s' % srctree) finally: bb.logger.setLevel(origlevel)
@@ -450,6 +451,7 @@ def modify(args, config, basepath, workspace): initial_rev = _extract_source(args.srctree, False, args.branch, rd) if not initial_rev: return 1 + logger.info('Source tree extracted to %s' % srctree) # Get list of commits since this revision (stdout, _) = bb.process.run('git rev-list --reverse %s..HEAD' % initial_rev, cwd=args.srctree) commits = stdout.split()
scripts/lib/devtool/upgrade.py new file +356 -0
356 lines not on this page · raw message
Signature · 1 line
1.8.4.5
PATCH v3 2/3 devtool-upgrade: sample recipe to test the devtool feature
In reply to [email protected]From: Leonardo Sandoval <[email protected]>
In order to have an 'upgradable' recipe, a base recipe is created (devtool-upgrade_0.1.bb). Under the files folder, source code of the base (0.1) and the upgrade (0.2) is located.
--- .../recipes-test/devtool/devtool-upgrade_0.1.bb | 25 +++++++++++++++++++ ...-exit-with-EXIT_SUCCESS-instead-of-a-magi.patch | 27 +++++++++++++++++++++ .../devtool/files/devtool-upgrade-0.1.tar.gz | Bin 0 -> 411 bytes .../devtool/files/devtool-upgrade-0.2.tar.gz | Bin 0 -> 411 bytes 4 files changed, 52 insertions(+) create mode 100644 meta-selftest/recipes-test/devtool/devtool-upgrade_0.1.bb create mode 100644 meta-selftest/recipes-test/devtool/files/0001-helloword.c-exit-with-EXIT_SUCCESS-instead-of-a-magi.patch create mode 100644 meta-selftest/recipes-test/devtool/files/devtool-upgrade-0.1.tar.gz create mode 100644 meta-selftest/recipes-test/devtool/files/devtool-upgrade-0.2.tar.gz
meta-selftest/recipes-test/devtool/devtool-upgrade_0.1.bb new file +25 -0
@@ -0,0 +1,25 @@ +# +# This file was derived from the 'Hello World!' example recipe in the +# Yocto Project Development Manual. +# + +DESCRIPTION = "Simple helloworld application used to test the devtool upgrade feature" +SECTION = "devtool" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +PR = "r0" + +SRC_URI = "file://${THISDIR}/files/${P}.tar.gz \ + file://0001-helloword.c-exit-with-EXIT_SUCCESS-instead-of-a-magi.patch \ + " + +S = "${WORKDIR}/${P}" + +do_compile() { + ${CC} helloworld.c -o helloworld +} + +do_install() { + install -d ${D}${bindir} + install -m 0755 helloworld ${D}${bindir} +}
meta-selftest/recipes-test/devtool/files/0001-helloword.c-exit-with-EXIT_SUCCESS-instead-of-a-magi.patch new file +27 -0
@@ -0,0 +1,27 @@ +From 0f37affbc6e6c71687301d99d7259f1968e57c48 Mon Sep 17 00:00:00 2001 +From: Leonardo Sandoval <[email protected]> +Date: Wed, 26 Aug 2015 12:42:23 +0000 +Subject: [PATCH] helloword.c: exit with EXIT_SUCCESS instead of a magic number + +--- + helloworld.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/helloworld.c b/helloworld.c +index 71f2e46..54bf50b 100644 +--- a/helloworld.c ++++ b/helloworld.c +@@ -1,8 +1,9 @@ + #include <stdio.h> ++#include <stdlib.h> + + int main(int argc, char **argv) + { + printf("Hello World!\n"); + +- return 0; ++ return EXIT_SUCCESS; + } +-- +1.8.4.5 +
meta-selftest/recipes-test/devtool/files/devtool-upgrade-0.1.tar.gz new file binary +0 -0
meta-selftest/recipes-test/devtool/files/devtool-upgrade-0.2.tar.gz new file binary +0 -0
Signature · 1 line
1.8.4.5
PATCH v3 3/3 oeqa/selftest: new tests for devtool upgrage feature
In reply to [email protected]From: Leonardo Sandoval <[email protected]>
Basic tests for the devtool's upgrade feature, including:
- Parameter check
- Upgrading an example recipe (devtool-upgrade_0.1.bb)
- Status after upgrade
--- meta/lib/oeqa/selftest/devtool.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
meta/lib/oeqa/selftest/devtool.py +36 -0
@@ -887,3 +887,39 @@ class DevtoolTests(DevtoolBase): result = runCmd('devtool undeploy-target -c %s root@%s' % (testrecipe, qemu.ip)) result = runCmd('ssh %s root@%s %s' % (sshargs, qemu.ip, testcommand), ignore_status=True) self.assertNotEqual(result, 0, 'undeploy-target did not remove command as it should have') + + def test_devtool_upgrade(self): + # Check preconditions + workspacedir = os.path.join(self.builddir, 'workspace') + self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory') + # Check parameters + result = runCmd('devtool upgrade -h') + for param in 'recipename srctree --version -V --branch -b --keep-temp --no-patch'.split(): + self.assertIn(param, result.output) + # For the moment, we are using a real recipe. + recipe='devtool-upgrade' + version='0.2' + tempdir = tempfile.mkdtemp(prefix='devtoolqa') + # Check that recipe is not already under devtool control + result = runCmd('devtool status') + self.assertNotIn(recipe, result.output) + # Check upgrade. Code does not check if new PV is older or newer that current PV, so, it may be that + # we are downgrading instead of upgrading. + result = runCmd('devtool upgrade %s %s -V %s' % (recipe, tempdir, version)) + # Check if srctree at least is populated + self.assertTrue(len(os.listdir(tempdir)) > 0, 'scrtree (%s) should be populated with new (%s) source code' % (tempdir, version)) + # Check new recipe folder is present + self.assertTrue(os.path.exists(os.path.join(workspacedir,'recipes',recipe)), 'Recipe folder should exist') + # Check new recipe file is present + self.assertTrue(os.path.exists(os.path.join(workspacedir,'recipes',recipe,"%s_%s.bb" % (recipe,version))), 'Recipe folder should exist') + # Check devtool status and make sure recipe is present + result = runCmd('devtool status') + self.assertIn(recipe, result.output) + self.assertIn(tempdir, result.output) + # Check devtool reset recipe + result = runCmd('devtool reset %s -n' % recipe) + result = runCmd('devtool status') + self.assertNotIn(recipe, result.output) + self.track_for_cleanup(tempdir) + self.track_for_cleanup(workspacedir) + self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
Signature · 1 line
1.8.4.5