Patchwork [bitbake-devel,RFC] git: add BB_FETCH_PREMIRROR_READONLY option

login
register
mail settings
Submitter Martin Jansa
Date April 30, 2013, 10:52 a.m.
Message ID <1367319160-19785-1-git-send-email-Martin.Jansa@gmail.com>
Download mbox | patch
Permalink /patch/49133/
State Deferred, archived
Headers show

Comments

Martin Jansa - April 30, 2013, 10:52 a.m.
* just RFC, because I haven't even tested this change,
  use it only to describe the issue and discuss it

* remove symlink to ud.fullmirror when BB_FETCH_PREMIRROR_READONLY is set

* with read-only PREMIRROR (e.g. mounted over NFS or CIFS
  and referenced as file:///mnt/premirror) we cannot use
  BB_GENERATE_MIRROR_TARBALLS because all git2_abc.git.tar.gz
  files later became just symlinks to read-only location in PREMIRROR
  (it works fine on first build and for new components, because
  at that time there isn't tarball on PREMIRROR yet).

  ERROR: Fetcher failure: Fetch command failed with exit code 141, output:
  tar (child): /build/downloads/git2_abc.git.tar.gz: Cannot open: Read-only file system
  tar (child): Error is not recoverable: exiting now

* maybe we can change the default behavior and always remove symlink
  without introducing new option

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 lib/bb/fetch2/git.py | 4 ++++
 1 file changed, 4 insertions(+)
Paul Eggleton - April 30, 2013, 12:57 p.m.
On Tuesday 30 April 2013 12:52:40 Martin Jansa wrote:
> * just RFC, because I haven't even tested this change,
>   use it only to describe the issue and discuss it
> 
> * remove symlink to ud.fullmirror when BB_FETCH_PREMIRROR_READONLY is set
> 
> * with read-only PREMIRROR (e.g. mounted over NFS or CIFS
>   and referenced as file:///mnt/premirror) we cannot use
>   BB_GENERATE_MIRROR_TARBALLS because all git2_abc.git.tar.gz
>   files later became just symlinks to read-only location in PREMIRROR
>   (it works fine on first build and for new components, because
>   at that time there isn't tarball on PREMIRROR yet).
> 
>   ERROR: Fetcher failure: Fetch command failed with exit code 141, output:
>   tar (child): /build/downloads/git2_abc.git.tar.gz: Cannot open: Read-only
> file system tar (child): Error is not recoverable: exiting now
> 
> * maybe we can change the default behavior and always remove symlink
>   without introducing new option

Personally I think it would be better to do the latter.

Cheers,
Paul
Martin Jansa - April 30, 2013, 2:46 p.m.
On Tue, Apr 30, 2013 at 01:57:42PM +0100, Paul Eggleton wrote:
> On Tuesday 30 April 2013 12:52:40 Martin Jansa wrote:
> > * just RFC, because I haven't even tested this change,
> >   use it only to describe the issue and discuss it
> > 
> > * remove symlink to ud.fullmirror when BB_FETCH_PREMIRROR_READONLY is set
> > 
> > * with read-only PREMIRROR (e.g. mounted over NFS or CIFS
> >   and referenced as file:///mnt/premirror) we cannot use
> >   BB_GENERATE_MIRROR_TARBALLS because all git2_abc.git.tar.gz
> >   files later became just symlinks to read-only location in PREMIRROR
> >   (it works fine on first build and for new components, because
> >   at that time there isn't tarball on PREMIRROR yet).
> > 
> >   ERROR: Fetcher failure: Fetch command failed with exit code 141, output:
> >   tar (child): /build/downloads/git2_abc.git.tar.gz: Cannot open: Read-only
> > file system tar (child): Error is not recoverable: exiting now
> > 
> > * maybe we can change the default behavior and always remove symlink
> >   without introducing new option
> 
> Personally I think it would be better to do the latter.

Only case when keeping old behavior is IMHO desirable is when someone
is using file:// and wants tar.gz updated in original location (e.g. to
rsync less from downloads directory after build).

But it won't update all (e.g. new components which don't have symlinks
yet) so rsync is still needed and usefulness of such requirement is quite low.

Cheers,

> 
> Cheers,
> Paul
> 
> -- 
> 
> Paul Eggleton
> Intel Open Source Technology Centre

Patch

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 052802e..14a8bc2 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -217,6 +217,10 @@  class Git(FetchMethod):
     def build_mirror_data(self, url, ud, d):
         # Generate a mirror tarball if needed
         if ud.write_tarballs and (ud.repochanged or not os.path.exists(ud.fullmirror)):
+            premirror_readonly = (d.getVar("BB_FETCH_PREMIRROR_READONLY", True) == "1")
+            if premirror_readonly and os.path.islink(ud.fullmirror):
+                os.unlink(origud.localpath)
+
             os.chdir(ud.clonedir)
             logger.info("Creating tarball of git repository")
             runfetchcmd("tar -czf %s %s" % (ud.fullmirror, os.path.join(".") ), d)