diff options
Diffstat (limited to 'bitbake/lib/bb/fetch2/gitannex.py')
| -rw-r--r-- | bitbake/lib/bb/fetch2/gitannex.py | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/gitannex.py b/bitbake/lib/bb/fetch2/gitannex.py new file mode 100644 index 0000000000..02711b0be6 --- /dev/null +++ b/bitbake/lib/bb/fetch2/gitannex.py | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | # ex:ts=4:sw=4:sts=4:et | ||
| 2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
| 3 | """ | ||
| 4 | BitBake 'Fetch' git annex implementation | ||
| 5 | """ | ||
| 6 | |||
| 7 | # Copyright (C) 2014 Otavio Salvador | ||
| 8 | # Copyright (C) 2014 O.S. Systems Software LTDA. | ||
| 9 | # | ||
| 10 | # This program is free software; you can redistribute it and/or modify | ||
| 11 | # it under the terms of the GNU General Public License version 2 as | ||
| 12 | # published by the Free Software Foundation. | ||
| 13 | # | ||
| 14 | # This program is distributed in the hope that it will be useful, | ||
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | # GNU General Public License for more details. | ||
| 18 | # | ||
| 19 | # You should have received a copy of the GNU General Public License along | ||
| 20 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 22 | |||
| 23 | import os | ||
| 24 | import bb | ||
| 25 | from bb import data | ||
| 26 | from bb.fetch2.git import Git | ||
| 27 | from bb.fetch2 import runfetchcmd | ||
| 28 | from bb.fetch2 import logger | ||
| 29 | |||
| 30 | class GitANNEX(Git): | ||
| 31 | def supports(self, url, ud, d): | ||
| 32 | """ | ||
| 33 | Check to see if a given url can be fetched with git. | ||
| 34 | """ | ||
| 35 | return ud.type in ['gitannex'] | ||
| 36 | |||
| 37 | def uses_annex(self, ud, d): | ||
| 38 | for name in ud.names: | ||
| 39 | try: | ||
| 40 | runfetchcmd("%s rev-list git-annex" % (ud.basecmd), d, quiet=True) | ||
| 41 | return True | ||
| 42 | except bb.fetch.FetchError: | ||
| 43 | pass | ||
| 44 | |||
| 45 | return False | ||
| 46 | |||
| 47 | def update_annex(self, u, ud, d): | ||
| 48 | try: | ||
| 49 | runfetchcmd("%s annex get --all" % (ud.basecmd), d, quiet=True) | ||
| 50 | except bb.fetch.FetchError: | ||
| 51 | return False | ||
| 52 | runfetchcmd("chmod u+w -R %s/annex" % (ud.clonedir), d, quiet=True) | ||
| 53 | |||
| 54 | return True | ||
| 55 | |||
| 56 | def download(self, loc, ud, d): | ||
| 57 | Git.download(self, loc, ud, d) | ||
| 58 | |||
| 59 | os.chdir(ud.clonedir) | ||
| 60 | annex = self.uses_annex(ud, d) | ||
| 61 | if annex: | ||
| 62 | self.update_annex(loc, ud, d) | ||
| 63 | |||
| 64 | def unpack(self, ud, destdir, d): | ||
| 65 | Git.unpack(self, ud, destdir, d) | ||
| 66 | |||
| 67 | os.chdir(ud.destdir) | ||
| 68 | try: | ||
| 69 | runfetchcmd("%s annex sync" % (ud.basecmd), d) | ||
| 70 | except bb.fetch.FetchError: | ||
| 71 | pass | ||
| 72 | |||
| 73 | annex = self.uses_annex(ud, d) | ||
| 74 | if annex: | ||
| 75 | runfetchcmd("%s annex get" % (ud.basecmd), d) | ||
| 76 | runfetchcmd("chmod u+w -R %s/.git/annex" % (ud.destdir), d, quiet=True) | ||
