[Pkg-javascript-devel] Bug#909753: fails to find binary package

2018-09-27 Thread Pirate Praveen
On Thu, 27 Sep 2018 12:51:58 -0400 =?utf-8?Q?Antoine_Beaupr=C3=A9?=
 wrote: > FWIW, I've also submitted this as a merge
request in salsa.

Thanks for the patch. As this is not a native debian package, can you
send the pull request to https://github.com/LeoIannacone/npm2deb or
modify the existing merge request as a quilt patch (in case you don't
like to use github)?

> The "-S" does not help here: it would show binary packages if we
> somehow magically found the right source package, but not the
> reverse.

For the majority of packages created by npm2deb, the source package name
is always node-, but as you found out, not all packages
follow this scheme and there is the case of babel, where one source
package creates a lot of binary packages. We were simple not aware of a
better solution and thanks for figuring out the correct solution.



signature.asc
Description: OpenPGP digital signature
-- 
Pkg-javascript-devel mailing list
Pkg-javascript-devel@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-javascript-devel

[Pkg-javascript-devel] Bug#909753: fails to find binary package

2018-09-27 Thread Antoine Beaupré
Control: forwarded -1 https://salsa.debian.org/js-team/npm2deb/merge_requests/1

FWIW, I've also submitted this as a merge request in salsa.

-- 
Pkg-javascript-devel mailing list
Pkg-javascript-devel@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-javascript-devel

[Pkg-javascript-devel] Bug#909753: fails to find binary package

2018-09-27 Thread Antoine Beaupre
Package: npm2deb
Version: 0.2.8-1
Severity: normal
Tags: patch

The tool used by the JavaScript team to track progress on packaging,
js_task_edit[1], has trouble dealing with binary packages that have a
different name than the source package. For example, in the OpenPGP
packaging page[2], a bunch of babel packages are marked as missing in
Debian even though they are actually present (e.g. babel-code).

This is because of that bit of rmadison code in mapper.py:

madison = _getstatusoutput(
'rmadison -u debian "%s" | tac | grep source' % result['name'])

If you look at the output for `babel-core`, you'll see this can't
possibly work:

$ rmadison -u debian node-babel-core
node-babel-core | 6.26.0+dfsg-3 | testing| all
node-babel-core | 6.26.0+dfsg-3 | unstable   | all

The "-S" does not help here: it would show binary packages if we
somehow magically found the right source package, but not the
reverse. There's no way the commandline rmadison tool can give us that
information, because that's a limitation of the API.

At least that's what I thought at first. As it turns out, there's an
undocumented `python` output format hidden deep in the entrails of
Dak[3] which, in turn, actually indicate the source package associated
with any binary package found. This nasty business requires us to do
an actual HTTP query in Python, but rmadison does that anyways, so
doing so is not really slower.

The attached patch fixes the bug in my tests: return the source
package instead of the binary package and things all fall into
place. As a bonus, we sort the version numbers with Python's distutils
which should be more reliable than `tac` (if that's even what that
thing was doing).

[1]: https://salsa.debian.org/js-team/js-task-wiki-edit
[2]: https://wiki.debian.org/Javascript/Nodejs/Tasks/openpgp
[3]: https://ftp-team.pages.debian.net/dak/epydoc/dak.daklib.ls-pysrc.html#L77

-- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (500, 'testing'), (1, 'experimental'), (1, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.18.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8), 
LANGUAGE=fr_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages npm2deb depends on:
ii  devscripts2.18.4
ii  node-github-url-from-git  1.4.0-1
ii  npm   5.8.0+ds5-1
ii  python3   3.6.6-1
ii  python3-dateutil  2.6.1-1

npm2deb recommends no packages.

npm2deb suggests no packages.

-- debconf-show failed
--- /usr/lib/python3/dist-packages/npm2deb/mapper.py2018-08-17 
07:53:04.0 -0400
+++ /home/anarcat/mapper.py 2018-09-27 12:30:52.010299687 -0400
@@ -4,10 +4,13 @@
 from subprocess import getstatusoutput as _getstatusoutput
 from fnmatch import fnmatch as _fnmatch
 
+import distutils.version
+
 from npm2deb.utils import debug as _debug
 from npm2deb.utils import debianize_name as _debianize_name
 
 DB_URL = 'https://wiki.debian.org/Javascript/Nodejs/Database'
+MADISON_URL = 
'https://api.ftp-master.debian.org/madison?S=true=python=%s'
 
 
 class Mapper(object):
@@ -68,19 +71,22 @@
 if not result['name']:
 return result
 
-madison = _getstatusoutput(
-'rmadison -u debian "%s" | tac | grep source' % result['name'])
-
-if madison[0] != 0:
+data = _urlopen(MADISON_URL % result['name']).read().decode('utf-8')
+packages = _parseJSON(data)
+if len(packages) < 1:
 result['name'] = None
 return result
-
-tmp = madison[1].split('|')
-if len(tmp) >= 2:
-result['name'] = tmp[0].strip()
-result['version'] = tmp[1].strip()
-result['suite'] = tmp[2].strip()
-result['repr'] = '%s (%s)' % (result['name'], result['version'])
+result['version'] = distutils.version.LooseVersion('0:0')
+for suite, versions in packages[0][result['name']]:
+for vers, source in versions:
+if distutils.version.LooseVersion(vers) > version:
+result['version'] = distutils.version.LooseVersion(vers)
+result['suite'] = suite
+result['name'] = source['source']
+result['repr'] = '%s (%s)' % (result['name'], 
result['version'])
+result['version'] = str(result['version'])
+if result['version'] == '0:0':
+result['version'] = None
 
 return result
 
-- 
Pkg-javascript-devel mailing list
Pkg-javascript-devel@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-javascript-devel