Ejemplo n.º 1
0
    def fix_checksum(self, package_name):
        """
        Fix the checksum of a package

        $ sage --package fix-checksum pari
        Updating checksum of pari-2.8-2044-g89b0f1e.tar.gz
        """
        log.debug('Correcting the checksum of %s', package_name)
        update = ChecksumUpdater(package_name)
        pkg = update.package
        if not pkg.tarball_filename:
            log.info('Ignoring {0} because it is not a normal package'.format(
                package_name))
            return
        if not os.path.exists(pkg.tarball.upstream_fqn):
            log.info('Ignoring {0} because tarball is not cached'.format(
                package_name))
            return
        if pkg.tarball.checksum_verifies():
            log.info('Checksum of {0} (tarball {1}) unchanged'.format(
                package_name, pkg.tarball_filename))
        else:
            log.info('Updating checksum of {0} (tarball {1})'.format(
                package_name, pkg.tarball_filename))
            update.fix_checksum()
Ejemplo n.º 2
0
 def create(self, package_name, version, tarball, pkg_type):
     log.debug('Creating %s: %s, %s, %s', package_name, version, tarball,
               pkg_type)
     creator = PackageCreator(package_name)
     if version:
         creator.set_version(version)
     if pkg_type:
         creator.set_type(pkg_type)
     if tarball:
         creator.set_tarball(tarball)
         update = ChecksumUpdater(package_name)
         update.fix_checksum()
Ejemplo n.º 3
0
    def fix_checksum(self, package_name):
        """
        Fix the checksum of a package

        $ sage --package fix-checksum pari
        Updating checksum of pari-2.8-2044-g89b0f1e.tar.gz
        """
        log.debug('Correcting the checksum of %s', package_name)
        update = ChecksumUpdater(package_name)
        pkg = update.package
        if pkg.tarball.checksum_verifies():
            print('Checksum of {0} unchanged'.format(pkg.tarball_filename))
        else:
            print('Updating checksum of {0}'.format(pkg.tarball_filename))
            update.fix_checksum()
Ejemplo n.º 4
0
    def fix_checksum(self, package_name):
        """
        Fix the checksum of a package

        $ sage --package fix-checksum pari
        Updating checksum of pari-2.8-2044-g89b0f1e.tar.gz
        """
        log.debug('Correcting the checksum of %s', package_name)
        update = ChecksumUpdater(package_name)
        pkg = update.package
        if pkg.tarball.checksum_verifies():
            print('Checksum of {0} unchanged'.format(pkg.tarball_filename))
        else:
            print('Updating checksum of {0}'.format(pkg.tarball_filename))
            update.fix_checksum()
Ejemplo n.º 5
0
    def fix_all_checksums(self):
        """
        Fix the checksum of a package

        $ sage --package fix-checksum
        """
        for pkg in Package.all():
            if not os.path.exists(pkg.tarball.upstream_fqn):
                log.debug('Ignoring {0} because tarball is not cached'.format(pkg.tarball_filename))
                continue
            if pkg.tarball.checksum_verifies():
                log.debug('Checksum of {0} unchanged'.format(pkg.tarball_filename))
                continue
            update = ChecksumUpdater(pkg.name)
            print('Updating checksum of {0}'.format(pkg.tarball_filename))
            update.fix_checksum()
Ejemplo n.º 6
0
    def fix_all_checksums(self):
        """
        Fix the checksum of a package

        $ sage --package fix-checksum
        """
        for pkg in Package.all():
            if not os.path.exists(pkg.tarball.upstream_fqn):
                log.debug('Ignoring {0} because tarball is not cached'.format(pkg.tarball_filename))
                continue
            if pkg.tarball.checksum_verifies():
                log.debug('Checksum of {0} (tarball {1}) unchanged'.format(pkg.name, pkg.tarball_filename))
                continue
            update = ChecksumUpdater(pkg.name)
            print('Updating checksum of {0} (tarball {1})'.format(pkg.name, pkg.tarball_filename))
            update.fix_checksum()
Ejemplo n.º 7
0
 def create(self, package_name, version, tarball, pkg_type, upstream_url):
     log.debug('Creating %s: %s, %s, %s', package_name, version, tarball, pkg_type)
     creator = PackageCreator(package_name)
     if version:
         creator.set_version(version)
     if pkg_type:
         creator.set_type(pkg_type)
     if tarball:
         creator.set_tarball(tarball, upstream_url)
         if upstream_url and version:
             update = PackageUpdater(package_name, version)
             update.download_upstream()
         else:
             update = ChecksumUpdater(package_name)
         update.fix_checksum()
Ejemplo n.º 8
0
 def create(self,
            package_name,
            version=None,
            tarball=None,
            pkg_type=None,
            upstream_url=None,
            description=None,
            license=None,
            upstream_contact=None,
            pypi=False,
            source='normal'):
     """
     Create a normal package
     """
     if '-' in package_name:
         raise ValueError(
             'package names must not contain dashes, use underscore instead'
         )
     if pypi:
         pypi_version = PyPiVersion(package_name)
         if source == 'normal':
             if not tarball:
                 # Guess the general format of the tarball name.
                 tarball = pypi_version.tarball.replace(
                     pypi_version.version, 'VERSION')
             if not version:
                 version = pypi_version.version
             # Use a URL from pypi.io instead of the specific URL received from the PyPI query
             # because it follows a simple pattern.
             upstream_url = 'https://pypi.io/packages/source/{0:1.1}/{0}/{1}'.format(
                 package_name, tarball)
         if not description:
             description = pypi_version.summary
         if not license:
             license = pypi_version.license
         if not upstream_contact:
             upstream_contact = pypi_version.package_url
     if tarball and not pkg_type:
         # If we set a tarball, also make sure to create a "type" file,
         # so that subsequent operations (downloading of tarballs) work.
         pkg_type = 'optional'
     log.debug('Creating %s: %s, %s, %s', package_name, version, tarball,
               pkg_type)
     creator = PackageCreator(package_name)
     if version:
         creator.set_version(version)
     if pkg_type:
         creator.set_type(pkg_type)
     if description or license or upstream_contact:
         creator.set_description(description, license, upstream_contact)
     if pypi or source == 'pip':
         creator.set_python_data_and_scripts(
             pypi_package_name=pypi_version.name, source=source)
     if tarball:
         creator.set_tarball(tarball, upstream_url)
         if upstream_url and version:
             update = PackageUpdater(package_name, version)
             update.download_upstream()
         else:
             update = ChecksumUpdater(package_name)
         update.fix_checksum()