summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/npm.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-25 15:07:08 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-26 17:20:09 +0000
commit12ade9b093a30d725e86d3da26e6f3152e1ca54f (patch)
treef29e3dfd76eab2cbdc1817047eca6ff0139ceddb /bitbake/lib/bb/fetch2/npm.py
parentca5b6d66e036fd52a7666480d2009f2a0c1e5216 (diff)
downloadpoky-12ade9b093a30d725e86d3da26e6f3152e1ca54f.tar.gz
bitbake: fetch2/npm: Add mirroring support for npm fetcher
(Bitbake rev: bff46c614d3f9cc18a1c8908c47842712e0e3a8c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/npm.py')
-rw-r--r--bitbake/lib/bb/fetch2/npm.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/npm.py b/bitbake/lib/bb/fetch2/npm.py
index 54cf76df09..7d5e8913fb 100644
--- a/bitbake/lib/bb/fetch2/npm.py
+++ b/bitbake/lib/bb/fetch2/npm.py
@@ -59,6 +59,7 @@ class Npm(FetchMethod):
59 logger.debug(2, "Calling cleanup %s" % ud.pkgname) 59 logger.debug(2, "Calling cleanup %s" % ud.pkgname)
60 bb.utils.remove(ud.localpath, False) 60 bb.utils.remove(ud.localpath, False)
61 bb.utils.remove(ud.pkgdatadir, True) 61 bb.utils.remove(ud.pkgdatadir, True)
62 bb.utils.remove(ud.fullmirror, False)
62 63
63 def urldata_init(self, ud, d): 64 def urldata_init(self, ud, d):
64 """ 65 """
@@ -82,12 +83,16 @@ class Npm(FetchMethod):
82 prefixdir = "npm/%s" % ud.pkgname 83 prefixdir = "npm/%s" % ud.pkgname
83 ud.pkgdatadir = d.expand("${DL_DIR}/%s" % prefixdir) 84 ud.pkgdatadir = d.expand("${DL_DIR}/%s" % prefixdir)
84 if not os.path.exists(ud.pkgdatadir): 85 if not os.path.exists(ud.pkgdatadir):
85 bb.utils.mkdirhiet(ud.pkgdatadir) 86 bb.utils.mkdirhier(ud.pkgdatadir)
86 ud.localpath = d.expand("${DL_DIR}/npm/%s" % ud.bbnpmmanifest) 87 ud.localpath = d.expand("${DL_DIR}/npm/%s" % ud.bbnpmmanifest)
87 88
88 self.basecmd = d.getVar("FETCHCMD_wget", True) or "/usr/bin/env wget -O -t 2 -T 30 -nv --passive-ftp --no-check-certificate " 89 self.basecmd = d.getVar("FETCHCMD_wget", True) or "/usr/bin/env wget -O -t 2 -T 30 -nv --passive-ftp --no-check-certificate "
89 self.basecmd += " --directory-prefix=%s " % prefixdir 90 self.basecmd += " --directory-prefix=%s " % prefixdir
90 91
92 ud.write_tarballs = ((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0")
93 ud.mirrortarball = 'npm_%s-%s.tar.xz' % (ud.pkgname, ud.version)
94 ud.fullmirror = os.path.join(d.getVar("DL_DIR", True), ud.mirrortarball)
95
91 def need_update(self, ud, d): 96 def need_update(self, ud, d):
92 if os.path.exists(ud.localpath): 97 if os.path.exists(ud.localpath):
93 return False 98 return False
@@ -202,6 +207,15 @@ class Npm(FetchMethod):
202 shrinkobj = {} 207 shrinkobj = {}
203 lockdown = {} 208 lockdown = {}
204 209
210 if not os.listdir(ud.pkgdatadir) and os.path.exists(ud.fullmirror):
211 dest = d.getVar("DL_DIR", True)
212 bb.utils.mkdirhier(dest)
213 save_cwd = os.getcwd()
214 os.chdir(dest)
215 runfetchcmd("tar -xJf %s" % (ud.fullmirror), d)
216 os.chdir(save_cwd)
217 return
218
205 shwrf = d.getVar('NPM_SHRINKWRAP', True) 219 shwrf = d.getVar('NPM_SHRINKWRAP', True)
206 logger.debug(2, "NPM shrinkwrap file is %s" % shwrf) 220 logger.debug(2, "NPM shrinkwrap file is %s" % shwrf)
207 try: 221 try:
@@ -224,3 +238,18 @@ class Npm(FetchMethod):
224 238
225 with open(ud.localpath, 'w') as outfile: 239 with open(ud.localpath, 'w') as outfile:
226 json.dump(jsondepobj, outfile) 240 json.dump(jsondepobj, outfile)
241
242 def build_mirror_data(self, ud, d):
243 # Generate a mirror tarball if needed
244 if ud.write_tarballs and not os.path.exists(ud.fullmirror):
245 # it's possible that this symlink points to read-only filesystem with PREMIRROR
246 if os.path.islink(ud.fullmirror):
247 os.unlink(ud.fullmirror)
248
249 save_cwd = os.getcwd()
250 os.chdir(d.getVar("DL_DIR", True))
251 logger.info("Creating tarball of npm data")
252 runfetchcmd("tar -cJf %s npm/%s npm/%s" % (ud.fullmirror, ud.bbnpmmanifest, ud.pkgname), d)
253 runfetchcmd("touch %s.done" % (ud.fullmirror), d)
254 os.chdir(save_cwd)
255