bitbake.conf: Set AUTOREV to have a vardepvalue

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.

(From OE-Core rev: 7b8ee9285a197784d51e339f1603240f49435846)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2018-01-05 15:14:35 +00:00
parent ccdc770fcb
commit 3ab6e17ffe
2 changed files with 38 additions and 1 deletions

View 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}"

View 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):