All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] svn.py: Stop SVN from directly pulling from an external layer w/o fetcher
@ 2019-05-15 18:02 Mark Hatle
  2019-05-16  6:41 ` Richard Purdie
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Hatle @ 2019-05-15 18:02 UTC (permalink / raw)
  To: bitbake-devel

Add a new option to the svn fetcher url "externals=allowed".  This will allow
a user to enable svn co w/ externals.  However, this does avoid the fetcher,
network access and mirror systems.

By default we no longer allow externals in the checkout.  This ensures a
deterministic download.  The system does attempt to identify SVN repos that
have externals enabled, and will warn the user.

In the future we would like to parse this list and see if the items are already
in the SRC_URI for that recipe, but with SVN being in limited use these days
that extra work is likely not worth the trouble.

Add test cases that generated a local SVN tree, with an external source
set to github bitbake in svn format.  One test case checks that externals are
ignored, and one checks that they in downloaded.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
 This was done in response to the patch from Krzysztof Zawadzki and the resulting
 discussion to make this the default instead of optional.

 lib/bb/fetch2/svn.py  | 12 +++++++++
 lib/bb/tests/fetch.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)

diff --git a/lib/bb/fetch2/svn.py b/lib/bb/fetch2/svn.py
index baeb0e7..08e4510 100644
--- a/lib/bb/fetch2/svn.py
+++ b/lib/bb/fetch2/svn.py
@@ -91,6 +91,10 @@ class Svn(FetchMethod):
             svncmd = "%s log --limit 1 %s %s://%s/%s/" % (ud.basecmd, " ".join(options), proto, svnroot, ud.module)
         else:
             suffix = ""
+
+            if not ("externals" in ud.parm and ud.parm["externals"] == "allowed"):
+                options.append("--ignore-externals")
+
             if ud.revision:
                 options.append("-r %s" % ud.revision)
                 suffix = "@%s" % (ud.revision)
@@ -136,6 +140,14 @@ class Svn(FetchMethod):
                 bb.fetch2.check_network_access(d, svnfetchcmd, ud.url)
                 runfetchcmd(svnfetchcmd, d, workdir=ud.pkgdir)
 
+            # Warn the user if this had externals (won't catch them all)
+            output = runfetchcmd("svn propget svn:externals", d, workdir=ud.moddir)
+            if output:
+                if "--ignore-externals" in svnfetchcmd.split():
+                    bb.warn("svn repository has ignored externals:\n%s" % output)
+                else:
+                    bb.debug(1, "svn repository has externals:\n%s" % output)
+
             scmdata = ud.parm.get("scmdata", "")
             if scmdata == "keep":
                 tar_flags = ""
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 6bdf041..d6b85cf 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -991,6 +991,73 @@ class FetcherNetworkTest(FetcherTest):
         self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/ctest/README.md')), msg='Missing submodule checkout')
         self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/testrunner/readme.md')), msg='Missing submodule checkout')
 
+class SVNTest(FetcherTest):
+
+    def setUp(self):
+        """ Create a local repository """
+
+        super(SVNTest, self).setUp()
+
+        # Create something we can fetch
+        src_dir = tempfile.mkdtemp(dir=self.tempdir,
+                                   prefix='svnfetch_srcdir_')
+        src_dir = os.path.abspath(src_dir)
+        bb.process.run("echo readme > README.md", cwd=src_dir)
+
+        # Store it in a local SVN repository
+        repo_dir = tempfile.mkdtemp(dir=self.tempdir,
+                                   prefix='svnfetch_localrepo_')
+        repo_dir = os.path.abspath(repo_dir)
+        bb.process.run("svnadmin create project", cwd=repo_dir)
+
+        self.repo_url = "file://%s/project" % repo_dir
+        bb.process.run("svn import --editor-cmd 'cp %s/README.md' %s %s/trunk" % (src_dir, src_dir, self.repo_url), cwd=repo_dir)
+
+        print("local checkout %s" % os.path.join(self.tempdir, 'svnfetch_co', 'trunk'))
+        bb.process.run("svn co %s svnfetch_co" % self.repo_url, cwd=self.tempdir)
+        # Github will emulate SVN.  Use this to check if we're downloding...
+        bb.process.run("svn propset svn:externals 'bitbake http://github.com/openembedded/bitbake' .",
+                       cwd=os.path.join(self.tempdir, 'svnfetch_co', 'trunk'))
+        bb.process.run('svn commit -m "Add external"',
+                       cwd=os.path.join(self.tempdir, 'svnfetch_co', 'trunk'))
+
+        self.src_dir = src_dir
+        self.repo_dir = repo_dir
+
+    def tearDown(self):
+        os.chdir(self.origdir)
+        if os.environ.get("BB_TMPDIR_NOCLEAN") == "yes":
+            print("Not cleaning up %s. Please remove manually." % self.tempdir)
+        else:
+            bb.utils.prunedir(self.tempdir)
+        
+    @skipIfNoNetwork()
+    def test_noexternal_svn(self):
+        # Always match the rev count from setUp (currently rev 2)
+        url = "svn://%s;module=trunk;protocol=file;rev=2" % self.repo_url.replace('file://', '')
+        fetcher = bb.fetch.Fetch([url], self.d)
+        fetcher.download()
+        os.chdir(os.path.dirname(self.unpackdir))
+        fetcher.unpack(self.unpackdir)
+
+        self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk')), msg="Missing trunk")
+        self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk', 'README.md')), msg="Missing contents")
+        self.assertFalse(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk')), msg="External dir should NOT exist")
+        self.assertFalse(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk', 'README')), msg="External README should NOT exit")
+
+    def test_external_svn(self):
+        # Always match the rev count from setUp (currently rev 2)
+        url = "svn://%s;module=trunk;protocol=file;externals=allowed;rev=2" % self.repo_url.replace('file://', '')
+        fetcher = bb.fetch.Fetch([url], self.d)
+        fetcher.download()
+        os.chdir(os.path.dirname(self.unpackdir))
+        fetcher.unpack(self.unpackdir)
+
+        self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk')), msg="Missing trunk")
+        self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk', 'README.md')), msg="Missing contents")
+        self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk')), msg="External dir should exist")
+        self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk', 'README')), msg="External README should exit")
+
 class TrustedNetworksTest(FetcherTest):
     def test_trusted_network(self):
         # Ensure trusted_network returns False when the host IS in the list.
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] svn.py: Stop SVN from directly pulling from an external layer w/o fetcher
  2019-05-15 18:02 [RFC PATCH] svn.py: Stop SVN from directly pulling from an external layer w/o fetcher Mark Hatle
@ 2019-05-16  6:41 ` Richard Purdie
  2019-05-16  7:22   ` Mark Hatle
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Purdie @ 2019-05-16  6:41 UTC (permalink / raw)
  To: Mark Hatle, bitbake-devel

On Wed, 2019-05-15 at 14:02 -0400, Mark Hatle wrote:
> Add a new option to the svn fetcher url "externals=allowed".  This will allow
> a user to enable svn co w/ externals.  However, this does avoid the fetcher,
> network access and mirror systems.
> 
> By default we no longer allow externals in the checkout.  This ensures a
> deterministic download.  The system does attempt to identify SVN repos that
> have externals enabled, and will warn the user.
> 
> In the future we would like to parse this list and see if the items are already
> in the SRC_URI for that recipe, but with SVN being in limited use these days
> that extra work is likely not worth the trouble.
> 
> Add test cases that generated a local SVN tree, with an external source
> set to github bitbake in svn format.  One test case checks that externals are
> ignored, and one checks that they in downloaded.
> 
> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
> ---
>  This was done in response to the patch from Krzysztof Zawadzki and the resulting
>  discussion to make this the default instead of optional.

Patch looks good to me but the autobuilder didn't like it:

https://autobuilder.yoctoproject.org/typhoon/#/builders/56/builds/465/steps/7/logs/step1d

Cheers,

Richard



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] svn.py: Stop SVN from directly pulling from an external layer w/o fetcher
  2019-05-16  6:41 ` Richard Purdie
@ 2019-05-16  7:22   ` Mark Hatle
  2019-05-16  7:47     ` richard.purdie
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Hatle @ 2019-05-16  7:22 UTC (permalink / raw)
  To: Richard Purdie, bitbake-devel

On 5/16/19 9:41 AM, Richard Purdie wrote:
> On Wed, 2019-05-15 at 14:02 -0400, Mark Hatle wrote:
>> Add a new option to the svn fetcher url "externals=allowed".  This will allow
>> a user to enable svn co w/ externals.  However, this does avoid the fetcher,
>> network access and mirror systems.
>>
>> By default we no longer allow externals in the checkout.  This ensures a
>> deterministic download.  The system does attempt to identify SVN repos that
>> have externals enabled, and will warn the user.
>>
>> In the future we would like to parse this list and see if the items are already
>> in the SRC_URI for that recipe, but with SVN being in limited use these days
>> that extra work is likely not worth the trouble.
>>
>> Add test cases that generated a local SVN tree, with an external source
>> set to github bitbake in svn format.  One test case checks that externals are
>> ignored, and one checks that they in downloaded.
>>
>> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
>> ---
>>  This was done in response to the patch from Krzysztof Zawadzki and the resulting
>>  discussion to make this the default instead of optional.
> 
> Patch looks good to me but the autobuilder didn't like it:
> 
> https://autobuilder.yoctoproject.org/typhoon/#/builders/56/builds/465/steps/7/logs/step1d

What is the host system type on the autobuilder?  Everything I see in the
traceback is as intended.  So it's likely a version or argument change in a
different version of SVN.

--Mark

> Cheers,
> 
> Richard
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] svn.py: Stop SVN from directly pulling from an external layer w/o fetcher
  2019-05-16  7:22   ` Mark Hatle
@ 2019-05-16  7:47     ` richard.purdie
  0 siblings, 0 replies; 4+ messages in thread
From: richard.purdie @ 2019-05-16  7:47 UTC (permalink / raw)
  To: Mark Hatle, bitbake-devel

On Thu, 2019-05-16 at 10:22 +0300, Mark Hatle wrote:
> On 5/16/19 9:41 AM, Richard Purdie wrote:
> > On Wed, 2019-05-15 at 14:02 -0400, Mark Hatle wrote:
> > > Add a new option to the svn fetcher url "externals=allowed".  This will allow
> > > a user to enable svn co w/ externals.  However, this does avoid the fetcher,
> > > network access and mirror systems.
> > > 
> > > By default we no longer allow externals in the checkout.  This ensures a
> > > deterministic download.  The system does attempt to identify SVN repos that
> > > have externals enabled, and will warn the user.
> > > 
> > > In the future we would like to parse this list and see if the items are already
> > > in the SRC_URI for that recipe, but with SVN being in limited use these days
> > > that extra work is likely not worth the trouble.
> > > 
> > > Add test cases that generated a local SVN tree, with an external source
> > > set to github bitbake in svn format.  One test case checks that externals are
> > > ignored, and one checks that they in downloaded.
> > > 
> > > Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
> > > ---
> > >  This was done in response to the patch from Krzysztof Zawadzki and the resulting
> > >  discussion to make this the default instead of optional.
> > 
> > Patch looks good to me but the autobuilder didn't like it:
> > 
> > https://autobuilder.yoctoproject.org/typhoon/#/builders/56/builds/465/steps/7/logs/step1d
> 
> What is the host system type on the autobuilder?  Everything I see in the
> traceback is as intended.  So it's likely a version or argument change in a
> different version of SVN.

That one was debian9.

rpurdie@debian9-ty-2:~$ svn --version
svn, version 1.9.5 (r1770682)
   compiled Jul 21 2018, 02:35:40 on x86_64-pc-linux-gnu

Worryingly I looked on debian9-ty-1 first and subversion isn't
installed there at all. In builds we'd build subversion-native.

This could get quite tricky to handle...

Cheers,

Richard



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-16  7:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-15 18:02 [RFC PATCH] svn.py: Stop SVN from directly pulling from an external layer w/o fetcher Mark Hatle
2019-05-16  6:41 ` Richard Purdie
2019-05-16  7:22   ` Mark Hatle
2019-05-16  7:47     ` richard.purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.