mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 00:59:48 +00:00
bitbake: fetch2/svn: Fix SVN repository concurrent update race
The ${DL_DIR}/svn directory is used by BitBake to keep checked-out SVN
repositories from which tarballs are generated. These repositories were
protected from concurrent update with a lock on the tarballs. However,
the tarballs are specific to the SRCREV and module checked out (many
tarballs can come from the same repository), meaning a repository could
be modified concurrently if two recipes checked out two different
SRCREVs or modules from it in parallel. This caused errors like the
following:
ERROR: Fetcher failure: Fetch command failed with exit code 1, output:
svn: E155004: Run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
svn: E155004: Working copy '/home/foo/downloads/svn/repo/trunk' locked.
svn: E155004: '/home/foo/downloads/svn/repo/trunk' is already locked.
Fix it by adding a per-repository lock that's independent of the module
and SRCREV.
(Bitbake rev: 3f1f183a17bf3580da8a4ffd6dab30b62c2654a8)
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@bmw.de>
Signed-off-by: Michael Ho <Michael.Ho@bmw.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
c5ca140d38
commit
db20fe6f0a
@@ -63,6 +63,9 @@ class Svn(FetchMethod):
|
|||||||
relpath = self._strip_leading_slashes(ud.path)
|
relpath = self._strip_leading_slashes(ud.path)
|
||||||
ud.pkgdir = os.path.join(svndir, ud.host, relpath)
|
ud.pkgdir = os.path.join(svndir, ud.host, relpath)
|
||||||
ud.moddir = os.path.join(ud.pkgdir, ud.module)
|
ud.moddir = os.path.join(ud.pkgdir, ud.module)
|
||||||
|
# Protects the repository from concurrent updates, e.g. from two
|
||||||
|
# recipes fetching different revisions at the same time
|
||||||
|
ud.svnlock = os.path.join(ud.pkgdir, "svn.lock")
|
||||||
|
|
||||||
ud.setup_revisions(d)
|
ud.setup_revisions(d)
|
||||||
|
|
||||||
@@ -123,35 +126,40 @@ class Svn(FetchMethod):
|
|||||||
|
|
||||||
logger.debug(2, "Fetch: checking for module directory '" + ud.moddir + "'")
|
logger.debug(2, "Fetch: checking for module directory '" + ud.moddir + "'")
|
||||||
|
|
||||||
if os.access(os.path.join(ud.moddir, '.svn'), os.R_OK):
|
lf = bb.utils.lockfile(ud.svnlock)
|
||||||
svnupdatecmd = self._buildsvncommand(ud, d, "update")
|
|
||||||
logger.info("Update " + ud.url)
|
|
||||||
# We need to attempt to run svn upgrade first in case its an older working format
|
|
||||||
try:
|
|
||||||
runfetchcmd(ud.basecmd + " upgrade", d, workdir=ud.moddir)
|
|
||||||
except FetchError:
|
|
||||||
pass
|
|
||||||
logger.debug(1, "Running %s", svnupdatecmd)
|
|
||||||
bb.fetch2.check_network_access(d, svnupdatecmd, ud.url)
|
|
||||||
runfetchcmd(svnupdatecmd, d, workdir=ud.moddir)
|
|
||||||
else:
|
|
||||||
svnfetchcmd = self._buildsvncommand(ud, d, "fetch")
|
|
||||||
logger.info("Fetch " + ud.url)
|
|
||||||
# check out sources there
|
|
||||||
bb.utils.mkdirhier(ud.pkgdir)
|
|
||||||
logger.debug(1, "Running %s", svnfetchcmd)
|
|
||||||
bb.fetch2.check_network_access(d, svnfetchcmd, ud.url)
|
|
||||||
runfetchcmd(svnfetchcmd, d, workdir=ud.pkgdir)
|
|
||||||
|
|
||||||
scmdata = ud.parm.get("scmdata", "")
|
try:
|
||||||
if scmdata == "keep":
|
if os.access(os.path.join(ud.moddir, '.svn'), os.R_OK):
|
||||||
tar_flags = ""
|
svnupdatecmd = self._buildsvncommand(ud, d, "update")
|
||||||
else:
|
logger.info("Update " + ud.url)
|
||||||
tar_flags = "--exclude='.svn'"
|
# We need to attempt to run svn upgrade first in case its an older working format
|
||||||
|
try:
|
||||||
|
runfetchcmd(ud.basecmd + " upgrade", d, workdir=ud.moddir)
|
||||||
|
except FetchError:
|
||||||
|
pass
|
||||||
|
logger.debug(1, "Running %s", svnupdatecmd)
|
||||||
|
bb.fetch2.check_network_access(d, svnupdatecmd, ud.url)
|
||||||
|
runfetchcmd(svnupdatecmd, d, workdir=ud.moddir)
|
||||||
|
else:
|
||||||
|
svnfetchcmd = self._buildsvncommand(ud, d, "fetch")
|
||||||
|
logger.info("Fetch " + ud.url)
|
||||||
|
# check out sources there
|
||||||
|
bb.utils.mkdirhier(ud.pkgdir)
|
||||||
|
logger.debug(1, "Running %s", svnfetchcmd)
|
||||||
|
bb.fetch2.check_network_access(d, svnfetchcmd, ud.url)
|
||||||
|
runfetchcmd(svnfetchcmd, d, workdir=ud.pkgdir)
|
||||||
|
|
||||||
# tar them up to a defined filename
|
scmdata = ud.parm.get("scmdata", "")
|
||||||
runfetchcmd("tar %s -czf %s %s" % (tar_flags, ud.localpath, ud.path_spec), d,
|
if scmdata == "keep":
|
||||||
cleanup=[ud.localpath], workdir=ud.pkgdir)
|
tar_flags = ""
|
||||||
|
else:
|
||||||
|
tar_flags = "--exclude='.svn'"
|
||||||
|
|
||||||
|
# tar them up to a defined filename
|
||||||
|
runfetchcmd("tar %s -czf %s %s" % (tar_flags, ud.localpath, ud.path_spec), d,
|
||||||
|
cleanup=[ud.localpath], workdir=ud.pkgdir)
|
||||||
|
finally:
|
||||||
|
bb.utils.unlockfile(lf)
|
||||||
|
|
||||||
def clean(self, ud, d):
|
def clean(self, ud, d):
|
||||||
""" Clean SVN specific files and dirs """
|
""" Clean SVN specific files and dirs """
|
||||||
|
|||||||
Reference in New Issue
Block a user