Exemplo n.º 1
0
def find_sources(options, args):
    """Find the tarball(s) to import - either via uscan or via command line argument
    @return: list of upstream source filenames or None if nothing to import
    @rtype: list of strings
    @raise GbpError: raised on all detected errors
    """
    if options.uscan: # uscan mode
        uscan = Uscan()

        if args:
            raise GbpError("you can't pass both --uscan and a filename.")

        gbp.log.info("Launching uscan...")
        try:
            uscan.scan()
        except UscanError as e:
            raise GbpError("%s" % e)

        if not uscan.uptodate:
            if uscan.tarball:
                gbp.log.info("using %s" % uscan.tarball)
                args.append(uscan.tarball)
            else:
                raise GbpError("uscan didn't download anything, and no source was found in ../")
        else:
            gbp.log.info("package is up to date, nothing to do.")
            return None
    if len(args) == 0:
        raise GbpError("No archive to import specified. Try --help.")

    return [ SourceImportManager(arg) for arg in args ]
Exemplo n.º 2
0
def find_source(use_uscan, args):
    """Find the tarball to import - either via uscan or via command line argument
    @return: upstream source filename or None if nothing to import
    @rtype: string
    @raise GbpError: raised on all detected errors
    """
    if use_uscan:
        if args:
            raise GbpError("you can't pass both --uscan and a filename.")

        uscan = Uscan()
        gbp.log.info("Launching uscan...")
        try:
            uscan.scan()
        except UscanError as e:
            raise GbpError("%s" % e)

        if not uscan.uptodate:
            if uscan.tarball:
                gbp.log.info("using %s" % uscan.tarball)
                args.append(uscan.tarball)
            else:
                raise GbpError(
                    "uscan didn't download anything, and no source was found in ../"
                )
        else:
            gbp.log.info("package is up to date, nothing to do.")
            return None
    if len(args) > 1:  # source specified
        raise GbpError("More than one archive specified. Try --help.")
    elif len(args) == 0:
        raise GbpError("No archive to import specified. Try --help.")
    else:
        archive = DebianUpstreamSource(args[0])
        return archive
Exemplo n.º 3
0
def find_upstream(use_uscan, args, version=None):
    """Find the main tarball to import - either via uscan or via command line argument
    @return: upstream source filename or None if nothing to import
    @rtype: string
    @raise GbpError: raised on all detected errors

    >>> find_upstream(False, ['too', 'many'])
    Traceback (most recent call last):
    ...
    gbp.errors.GbpError: More than one archive specified. Try --help.
    >>> find_upstream(False, [])
    Traceback (most recent call last):
    ...
    gbp.errors.GbpError: No archive to import specified. Try --help.
    >>> find_upstream(True, ['tarball'])
    Traceback (most recent call last):
    ...
    gbp.errors.GbpError: you can't pass both --uscan and a filename.
    >>> find_upstream(False, ['tarball']).path
    'tarball'
    """
    if use_uscan:
        if args:
            raise GbpError("you can't pass both --uscan and a filename.")

        uscan = Uscan()
        gbp.log.info("Launching uscan...")
        try:
            if not uscan.scan(download_version=version):
                gbp.log.info("package is up to date, nothing to do.")
                return None
        except UscanError as e:
            raise GbpError("%s" % e)

        if uscan.tarball:
            gbp.log.info("Using uscan downloaded tarball %s" % uscan.tarball)
            args.append(uscan.tarball)
        else:
            raise GbpError(
                "uscan didn't download anything, and no source was found in ../"
            )
    if len(args) > 1:  # source specified
        raise GbpError("More than one archive specified. Try --help.")
    elif len(args) == 0:
        raise GbpError("No archive to import specified. Try --help.")
    else:
        sig = '{}.asc'.format(args[0])
        if os.path.exists(sig):
            gbp.log.debug("Signature {} found for {}".format(args[0], sig))
        else:
            sig = None
        return DebianUpstreamSource(args[0], sig=sig)
Exemplo n.º 4
0
def find_source(use_uscan, args):
    """Find the tarball to import - either via uscan or via command line argument
    @return: upstream source filename or None if nothing to import
    @rtype: string
    @raise GbpError: raised on all detected errors

    >>> find_source(False, ['too', 'much'])
    Traceback (most recent call last):
    ...
    GbpError: More than one archive specified. Try --help.
    >>> find_source(False, [])
    Traceback (most recent call last):
    ...
    GbpError: No archive to import specified. Try --help.
    >>> find_source(True, ['tarball'])
    Traceback (most recent call last):
    ...
    GbpError: you can't pass both --uscan and a filename.
    >>> find_source(False, ['tarball']).path
    'tarball'
    """
    if use_uscan:
        if args:
            raise GbpError("you can't pass both --uscan and a filename.")

        uscan = Uscan()
        gbp.log.info("Launching uscan...")
        try:
            uscan.scan()
        except UscanError as e:
            raise GbpError("%s" % e)

        if not uscan.uptodate:
            if uscan.tarball:
                gbp.log.info("using %s" % uscan.tarball)
                args.append(uscan.tarball)
            else:
                raise GbpError("uscan didn't download anything, and no source was found in ../")
        else:
            gbp.log.info("package is up to date, nothing to do.")
            return None
    if len(args) > 1: # source specified
        raise GbpError("More than one archive specified. Try --help.")
    elif len(args) == 0:
        raise GbpError("No archive to import specified. Try --help.")
    else:
        archive = OrigUpstreamSource(args[0])
        return archive
Exemplo n.º 5
0
 def test_uscan(self, uscan_mock):
     """Test parsing a valid uscan file"""
     uscan = Uscan()
     self.assertTrue(uscan.scan())
     self.assertFalse(uscan.uptodate)
     self.assertEquals(uscan.tarball, '../virt-what_1.18.orig.tar.gz')
Exemplo n.º 6
0
 def test_uscan(self, uscan_mock):
     """Test parsing a valid uscan file"""
     uscan = Uscan()
     self.assertTrue(uscan.scan())
     self.assertFalse(uscan.uptodate)
     self.assertEquals(uscan.tarball, '../virt-what_1.18.orig.tar.gz')