Skip to contentSkip to conversation

Handle angular2 package names in bitbake

PATCH New Anders Darander 1 participant 3 messages Feb 24, 2017

lore
Share & tools
lore
#0 lore raw

cover Handle angular2 package names in bitbake

When trying to build a webapp using angular2, some issued with angular2's npm package names were found. This series fixes the bitbake issues, one or more late pull-request to oe-core will look into that side.

The following changes since commit 5b364b02270b0d7c2b7ca8d67fa2731bf93720ee:

fetch2/svn: change 'rsh' parameter to 'ssh' (2017-02-19 08:29:43 -0800)

are available in the git repository at:

git://github.com/darander/bitbake npm
https://github.com/darander/bitbake/tree/npm

Anders Darander (2):
fetch2/__init__: handle @ in package names
lib/bb/fetch2: rewrite / to - in package names

 lib/bb/fetch2/__init__.py | 2 +-
 lib/bb/fetch2/npm.py      | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.10.2
#1 lore raw

PATCH 1/2 fetch2/__init__: handle @ in package names

A number of npm packages use @ as a leading chararacter. Examples are most of the angular2 packages.

---
 lib/bb/fetch2/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/fetch2/__init__.py +1 -1
index 70387f5..760e24f 100644
@@ -356,7 +356,7 @@ def decodeurl(url):
     user, password, parameters).
     """
 
-    m = re.compile('(?P<type>[^:]*)://((?P<user>[^/]+)@)?(?P<location>[^;]+)(;(?P<parm>.*))?').match(url)
+    m = re.compile('(?P<type>[^:]*)://((?P<user>[^/;]+)@)?(?P<location>[^;]+)(;(?P<parm>.*))?').match(url)
     if not m:
         raise MalformedUrl(url)
 
Signature · 1 line
2.10.2
#2 lore raw

PATCH 2/2 lib/bb/fetch2: rewrite / to - in package names

In reply to Anders Darander

Most angular2 packages have names of the form @angular/xxx. The / obviously can't be used in a file name, replace it with -.

---
 lib/bb/fetch2/npm.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/bb/fetch2/npm.py +3 -2
index 15b281f..780f26d 100644
@@ -80,6 +80,7 @@ class Npm(FetchMethod):
         if not ud.version:
             raise ParameterError("NPM fetcher requires a version parameter", ud.url)
         ud.bbnpmmanifest = "%s-%s.deps.json" % (ud.pkgname, ud.version)
+        ud.bbnpmmanifest = ud.bbnpmmanifest.replace('/', '-')
         ud.registry = "http://%s" % (ud.url.replace('npm://', '', 1).split(';'))[0]
         prefixdir = "npm/%s" % ud.pkgname
         ud.pkgdatadir = d.expand("${DL_DIR}/%s" % prefixdir)
@@ -92,6 +93,7 @@ class Npm(FetchMethod):
 
         ud.write_tarballs = ((d.getVar("BB_GENERATE_MIRROR_TARBALLS") or "0") != "0")
         ud.mirrortarball = 'npm_%s-%s.tar.xz' % (ud.pkgname, ud.version)
+        ud.mirrortarball = ud.mirrortarball.replace('/', '-')
         ud.fullmirror = os.path.join(d.getVar("DL_DIR"), ud.mirrortarball)
 
     def need_update(self, ud, d):
@@ -133,8 +135,7 @@ class Npm(FetchMethod):
 
     def unpack(self, ud, destdir, d):
         dldir = d.getVar("DL_DIR")
-        depdumpfile = "%s-%s.deps.json" % (ud.pkgname, ud.version)
-        with open("%s/npm/%s" % (dldir, depdumpfile)) as datafile:
+        with open("%s/npm/%s" % (dldir, ud.bbnpmmanifest)) as datafile:
             workobj = json.load(datafile)
         dldir = "%s/%s" % (os.path.dirname(ud.localpath), ud.pkgname)
 
Signature · 1 line
2.10.2