Hi,

Le 22/09/2018 à 13:47, Bastien ROUCARIES a écrit :

Le sam. 22 sept. 2018 à 11:36, Pirate Praveen <prav...@onenetbeyond.org <mailto:prav...@onenetbeyond.org>> a écrit :

    On 8/10/18 2:58 AM, Bastien ROUCARIES wrote:
     >
     >     - just one node-types-definitelytyped real package would
    provide all
     >     necessary node-types-foo ones, so if a package needs the
    @types/foo, it
     >     can depend on node-types-foo and the right one is pulled in ;
     >
     > No

    There is already such a package,
    https://tracker.debian.org/pkg/typescript-types

    What is the current status and how to proceed here?

    I think one source package is perfect as it is only a build dependency
    anyway.

No because it is source included. How do you take care of version hell

I don't know exactly how to take care of version hell, but I'm not sure it should prevent us from trying to ship something -- or we probably wouldn't ship a single node-* package!

What do you think of the attached script? It assumes the upstream DefinitelyTyped tree is in "DefinitelyTyped.upstream" as it's the layout I use for my experiment, and generates a "control" file and a bunch of "node-types-*.install" files.

jpuydt on irc.debian.org
#!/usr/bin/python3

# Improvements:
#
# (1) Also generate copyrights files, as index.d.ts files generally
# have an helpful "// Definitions by: " line. One copyright file per
# package?
#
# (2) In write_control: the first line of index.d.ts has the software name
# and the version, so perhaps it's possible to do more fine-grained work here.
#
# (3) There are *-tests.js files around, but I'm not sure it's
# possible to create an autopkgtest for each one, since I don't see
# how to find out the deps nor how to properly run them.
#

import json,os
import apt_pkg

types_path = 'DefinitelyTyped.upstream/types' # FIXME

debian_names_exceptions = {}

apt_pkg.init()
cache = apt_pkg.Cache()

def find_debian_name(directory):
    # First see if we can directly find the package name
    if directory in debian_names_exceptions:
        return debian_names_exceptions[directory]
    # Then see if we have the corresponding node- package
    if 'node-' + directory in cache:
        return directory
    # If all fails, don't package the definitions
    return None

def write_control_header(control):
    header = (
        "Source: node-definitelytyped\n"
        "Section: javascript\n"
        "Priority: optional\n"
        "Maintainer: Debian Javascript Maintainers <pkg-javascript-de...@lists.alioth.debian.org>\n"
        "Uploaders: Julien Puydt <jpu...@debian.org>\n"
        "Build-Depends: debhelper (>= 11), python3-apt\n"
        "Standards-Version: 4.2.1\n"
        "Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped\n";
        "Vcs-Git: https://salsa.debian.org/js-team/node-definitelytyped.git\n";
        "Vcs-Browser: https://salsa.debian.org/js-team/node-definitelytyped\n";
        "\n"
    )
    control.write(header)

def write_control(directory, name, control):
    control.write('Package: node-types-'+name+'\n')
    control.write('Architecture: all\n')
    control.write('Depends: ${misc:Depends}, nodejs, node-'+name+'\n')
    control.write('Description: type definitions for node-'+name+'\n')
    control.write(' This package provides the type definitions corresponding\n')
    control.write(' to the code in the node-'+name+' package.\n')
    control.write(' .\n')
    control.write(' Type declarations are used by the TypeScript\n')
    control.write(' compiler and some integrated development environments\n')
    control.write(' to feature early error detection.\n')
    control.write('\n') # will leave an empty line also after the last one

def write_install(directory, name):
    with open('node-types-'+name+'.install', 'w') as outfile:
        with open(os.path.join(types_path, directory, 'tsconfig.json'), 'r') as infile:
            files = json.load(infile)['files']
            for filename in files:
                # make sure we don't ship the tests
                if not filename.endswith('-tests.ts') and not filename.startswith('test/'):
                    outfile.write(os.path.join(types_path,directory,filename)+'\t/usr/lib/nodejs/'+name+'\n')

def main():
    with open('control', 'w') as control:
        write_control_header(control)
        count_ok = 0
        count_notok = 0
        for directory in os.listdir(types_path):
            name = find_debian_name(directory)
            if name:
                count_ok = count_ok+1
                write_control(directory, name, control)
                write_install(directory, name)
            else:
                count_notok = count_notok+1
        print('{0:d} node-types-* generated and {1:d} not considered'.format(count_ok, count_notok))

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

Reply via email to