]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake.conf: Set AUTOREV to have a vardepvalue
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 5 Jan 2018 15:14:35 +0000 (15:14 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 6 Jan 2018 10:13:39 +0000 (10:13 +0000)
If you have a recipe which does not include SRCPV in PV but does set
SRCREV = "${AUTOREV}" and you run do_fetch, then change the repo to a
new commit then run do_unpack, do_unpack will fail since the new commit
doesn't exist in the repo that was fetched.

The problem is the revision chosen is not represented in the do_fetch
task hash. It if were, the fetch would rerun first and the commit would be
present. It works when PV includes SRCPV since that does contain the chosen
commit from the AUTOREV.

The solution is to include the SRCPV value into the representation of AUTOREV
used for checksum calculation purposes.

Add a selftest for this issue.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/conf/bitbake.conf
meta/lib/oeqa/selftest/cases/sstatetests.py

index 15feb573db09c8dbd2b725f61e4005f233f368f3..93afb131661ce8c0f408f5725fffc5589f0974ec 100644 (file)
@@ -663,6 +663,7 @@ FETCHCMD_hg = "/usr/bin/env hg"
 SRCDATE = "${DATE}"
 SRCREV ??= "INVALID"
 AUTOREV = "${@bb.fetch2.get_autorev(d)}"
+AUTOREV[vardepvalue] = "${SRCPV}"
 # Set Dynamically in base.bbclass
 # SRCPV = "${@bb.fetch2.get_srcrev(d)}"
 SRCPV[vardepvalue] = "${SRCPV}"
index 47900886a32232cc27e19c6bf128f594e185c1bd..673569426344d1de0b28e33d8a185500f6c72476 100644 (file)
@@ -2,15 +2,51 @@ import os
 import shutil
 import glob
 import subprocess
+import tempfile
 
 from oeqa.selftest.case import OESelftestTestCase
-from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer, create_temp_layer
 from oeqa.selftest.cases.sstate import SStateBase
 from oeqa.core.decorator.oeid import OETestID
 
 import bb.siggen
 
 class SStateTests(SStateBase):
+    def test_autorev_sstate_works(self):
+        # Test that a git repository which changes is correctly handled by SRCREV = ${AUTOREV}
+        # when PV does not contain SRCPV
+
+        tempdir = tempfile.mkdtemp(prefix='oeqa')
+        self.track_for_cleanup(tempdir)
+        create_temp_layer(tempdir, 'selftestrecipetool')
+        self.add_command_to_tearDown('bitbake-layers remove-layer %s' % tempdir)
+        runCmd('bitbake-layers add-layer %s' % tempdir)
+
+        # Use dbus-wait as a local git repo we can add a commit between two builds in
+        pn = 'dbus-wait'
+        srcrev = '6cc6077a36fe2648a5f993fe7c16c9632f946517'
+        url = 'git://git.yoctoproject.org/dbus-wait'
+        result = runCmd('git clone %s noname' % url, cwd=tempdir)
+        srcdir = os.path.join(tempdir, 'noname')
+        result = runCmd('git reset --hard %s' % srcrev, cwd=srcdir)
+        self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure.ac')), 'Unable to find configure script in source directory')
+
+        recipefile = os.path.join(tempdir, "recipes-test", "dbus-wait-test", 'dbus-wait-test_git.bb')
+        os.makedirs(os.path.dirname(recipefile))
+        srcuri = 'git://' + srcdir + ';protocol=file'
+        result = runCmd(['recipetool', 'create', '-o', recipefile, srcuri])
+        self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output)
+
+        with open(recipefile, 'a') as f:
+            f.write('SRCREV = "${AUTOREV}"\n')
+            f.write('PV = "1.0"\n')
+
+        bitbake("dbus-wait-test -c fetch")
+        with open(os.path.join(srcdir, "bar.txt"), "w") as f:
+            f.write("foo")
+        result = runCmd('git add bar.txt; git commit -asm "add bar"', cwd=srcdir)
+        bitbake("dbus-wait-test -c unpack")
+
 
     # Test sstate files creation and their location
     def run_test_sstate_creation(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True, should_pass=True):