Exemplo n.º 1
0
    def prune(self):
        """Prune the contents of the database.

        This removes warnings that are no longer valid. A warning is no longer
        valid if the file it was in no longer exists or if the content has
        changed.

        The check for changed content catches the case where a file previously
        contained warnings but no longer does.
        """

        # Need to calculate up front since we are mutating original object.
        filenames = self._files.keys()
        for filename in filenames:
            if not os.path.exists(filename):
                del self._files[filename]
                continue

            if self._files[filename]["hash"] is None:
                continue

            current_hash = hash_file(filename)
            if current_hash != self._files[filename]["hash"]:
                del self._files[filename]
                continue
Exemplo n.º 2
0
    def prune(self):
        """Prune the contents of the database.

        This removes warnings that are no longer valid. A warning is no longer
        valid if the file it was in no longer exists or if the content has
        changed.

        The check for changed content catches the case where a file previously
        contained warnings but no longer does.
        """

        # Need to calculate up front since we are mutating original object.
        filenames = self._files.keys()
        for filename in filenames:
            if not os.path.exists(filename):
                del self._files[filename]
                continue

            if self._files[filename]['hash'] is None:
                continue

            current_hash = hash_file(filename)
            if current_hash != self._files[filename]['hash']:
                del self._files[filename]
                continue
Exemplo n.º 3
0
    def insert(self, warning, compute_hash=True):
        assert isinstance(warning, CompilerWarning)

        filename = warning["filename"]

        new_hash = None

        if compute_hash:
            new_hash = hash_file(filename)

        if filename in self._files:
            if new_hash != self._files[filename]["hash"]:
                del self._files[filename]

        value = self._files.get(
            filename,
            {
                "hash": new_hash,
                "warnings": set(),
            },
        )

        value["warnings"].add(warning)

        self._files[filename] = value
Exemplo n.º 4
0
    def test_hash_file_known_hash(self):
        """Ensure a known hash value is recreated."""
        data = b'The quick brown fox jumps over the lazy cog'
        expected = 'de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3'

        temp = NamedTemporaryFile()
        temp.write(data)
        temp.flush()

        actual = hash_file(temp.name)

        self.assertEqual(actual, expected)
Exemplo n.º 5
0
    def test_hash_file_known_hash(self):
        """Ensure a known hash value is recreated."""
        data = b"The quick brown fox jumps over the lazy cog"
        expected = "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3"

        temp = NamedTemporaryFile()
        temp.write(data)
        temp.flush()

        actual = hash_file(temp.name)

        self.assertEqual(actual, expected)
def main(args):
    parser = argparse.ArgumentParser()
    parser.add_argument(dest='dir',
                        metavar='DIR',
                        help='Path to write goannalibs Android ARchive and metadata to.')
    parser.add_argument('--verbose', '-v', default=False, action='store_true',
                        help='be verbose')
    parser.add_argument('--revision',
                        help='Revision identifier to write.')
    parser.add_argument('--topsrcdir',
                        help='Top source directory.')
    parser.add_argument('--distdir',
                        help='Distribution directory (usually $OBJDIR/dist).')
    args = parser.parse_args(args)

    paths_to_hash = []

    aar = os.path.join(args.dir, 'goannalibs-{revision}.aar').format(revision=args.revision)
    paths_to_hash.append(aar)
    package_goannalibs_aar(args.topsrcdir, args.distdir, aar)

    pom = os.path.join(args.dir, 'goannalibs-{revision}.pom').format(revision=args.revision)
    paths_to_hash.append(pom)
    with open(pom, 'wt') as f:
        f.write(MAVEN_POM_TEMPLATE.format(
            groupId='org.mozilla',
            artifactId='goannalibs',
            version=args.revision,
            packaging='aar',
        ))

    ivy = os.path.join(args.dir, 'ivy-goannalibs-{revision}.xml').format(revision=args.revision)
    paths_to_hash.append(ivy)
    with open(ivy, 'wt') as f:
        f.write(IVY_XML_TEMPLATE.format(
            organisation='org.mozilla',
            module='goannalibs',
            revision=args.revision,
            publication=args.revision, # A white lie.
            name='goannalibs',
            type='aar',
            ext='aar',
        ))

    for p in paths_to_hash:
        sha = "%s.sha1" % p
        with open(sha, 'wt') as f:
            f.write(util.hash_file(p, hasher=hashlib.sha1()))
        if args.verbose:
            print(p)
            print(sha)

    return 0
def main(args):
    parser = argparse.ArgumentParser()
    parser.add_argument(dest='dir',
                        metavar='DIR',
                        help='Path to write geckolibs Android ARchive and metadata to.')
    parser.add_argument('--verbose', '-v', default=False, action='store_true',
                        help='be verbose')
    parser.add_argument('--revision',
                        help='Revision identifier to write.')
    parser.add_argument('--topsrcdir',
                        help='Top source directory.')
    parser.add_argument('--distdir',
                        help='Distribution directory (usually $OBJDIR/dist).')
    args = parser.parse_args(args)

    paths_to_hash = []

    aar = os.path.join(args.dir, 'geckolibs-{revision}.aar').format(revision=args.revision)
    paths_to_hash.append(aar)
    package_geckolibs_aar(args.topsrcdir, args.distdir, aar)

    pom = os.path.join(args.dir, 'geckolibs-{revision}.pom').format(revision=args.revision)
    paths_to_hash.append(pom)
    with open(pom, 'wt') as f:
        f.write(MAVEN_POM_TEMPLATE.format(
            groupId='org.mozilla',
            artifactId='geckolibs',
            version=args.revision,
            packaging='aar',
        ))

    ivy = os.path.join(args.dir, 'ivy-geckolibs-{revision}.xml').format(revision=args.revision)
    paths_to_hash.append(ivy)
    with open(ivy, 'wt') as f:
        f.write(IVY_XML_TEMPLATE.format(
            organisation='org.mozilla',
            module='geckolibs',
            revision=args.revision,
            publication=args.revision, # A white lie.
            name='geckolibs',
            type='aar',
            ext='aar',
        ))

    for p in paths_to_hash:
        sha = "%s.sha1" % p
        with open(sha, 'wt') as f:
            f.write(util.hash_file(p, hasher=hashlib.sha1()))
        if args.verbose:
            print(p)
            print(sha)

    return 0
Exemplo n.º 8
0
    def test_hash_file_large(self):
        """Ensure that hash_file seems to work with a large file."""
        data = b'x' * 1048576

        hasher = hashlib.sha1()
        hasher.update(data)
        expected = hasher.hexdigest()

        temp = NamedTemporaryFile()
        temp.write(data)
        temp.flush()

        actual = hash_file(temp.name)

        self.assertEqual(actual, expected)
Exemplo n.º 9
0
    def test_hash_file_large(self):
        """Ensure that hash_file seems to work with a large file."""
        data = b"x" * 1048576

        hasher = hashlib.sha1()
        hasher.update(data)
        expected = hasher.hexdigest()

        temp = NamedTemporaryFile()
        temp.write(data)
        temp.flush()

        actual = hash_file(temp.name)

        self.assertEqual(actual, expected)
Exemplo n.º 10
0
    def insert(self, warning, compute_hash=True):
        assert isinstance(warning, CompilerWarning)

        filename = warning["filename"]

        new_hash = None

        if compute_hash:
            new_hash = hash_file(filename)

        if filename in self._files:
            if new_hash != self._files[filename]["hash"]:
                del self._files[filename]

        value = self._files.get(filename, {"hash": new_hash, "warnings": set()})

        value["warnings"].add(warning)

        self._files[filename] = value
Exemplo n.º 11
0
    def insert(self, warning, compute_hash=True):
        assert isinstance(warning, CompilerWarning)

        filename = warning['filename']

        new_hash = None

        if compute_hash:
            new_hash = hash_file(filename)

        if filename in self._files:
            if new_hash != self._files[filename]['hash']:
                del self._files[filename]

        value = self._files.get(filename, {
            'hash': new_hash,
            'warnings': set(),
        })

        value['warnings'].add(warning)

        self._files[filename] = value
Exemplo n.º 12
0
    def insert(self, warning, compute_hash=True):
        assert isinstance(warning, CompilerWarning)

        filename = warning['filename']

        new_hash = None

        if compute_hash:
            new_hash = hash_file(filename)

        if filename in self._files:
            if new_hash != self._files[filename]['hash']:
                del self._files[filename]

        value = self._files.get(filename, {
            'hash': new_hash,
            'warnings': set(),
        })

        value['warnings'].add(warning)

        self._files[filename] = value
def main(args):
    parser = argparse.ArgumentParser()
    parser.add_argument(dest='dir',
                        metavar='DIR',
                        help='Path to write Android ARchives and metadata to.')
    parser.add_argument('--verbose', '-v', default=False, action='store_true',
                        help='be verbose')
    parser.add_argument('--revision',
                        help='Revision identifier to write.')
    parser.add_argument('--topsrcdir',
                        help='Top source directory.')
    parser.add_argument('--distdir',
                        help='Distribution directory (usually $OBJDIR/dist).')
    parser.add_argument('--appname',
                        help='Application name (usually $MOZ_APP_NAME, like "fennec").')
    args = parser.parse_args(args)

    # An Ivy 'publication' date must be given in the form yyyyMMddHHmmss, and Mozilla buildids are in this format.
    if len(args.revision) != 14:
        raise ValueError('Revision must be in yyyyMMddHHmmss format: %s' % args.revision)

    paths_to_hash = []

    groupId='org.mozilla'
    packaging_type='aar'
    gecklibs_aar = os.path.join(args.dir, 'geckolibs-{revision}.aar').format(revision=args.revision)
    paths_to_hash.append(gecklibs_aar)
    geckoview_aar = os.path.join(args.dir, 'geckoview-{revision}.aar').format(revision=args.revision)
    paths_to_hash.append(geckoview_aar)

    package_geckolibs_aar(args.topsrcdir, args.distdir, args.appname, gecklibs_aar)
    package_geckoview_aar(args.topsrcdir, args.distdir, args.appname, geckoview_aar)

    geckolibs_pom_path = os.path.join(args.dir, 'geckolibs-{revision}.pom').format(revision=args.revision)
    paths_to_hash.append(geckolibs_pom_path)
    geckolibs_pom = MAVEN_POM_TEMPLATE.format(
            groupId=groupId,
            artifactId='geckolibs',
            version=args.revision,
            packaging=packaging_type,
            dependencies=''
        )

    with open(geckolibs_pom_path, 'wt') as f:
        f.write(geckolibs_pom)

    geckoview_pom_path = os.path.join(args.dir, 'geckoview-{revision}.pom').format(revision=args.revision)
    paths_to_hash.append(geckoview_pom_path)
    geckoview_pom = MAVEN_POM_TEMPLATE.format(
        groupId=groupId,
        artifactId='geckoview',
        version=args.revision,
        packaging=packaging_type,
        dependencies=MAVEN_POM_DEPENDENCY_TEMPLATE.format(
            groupId=groupId,
            artifactId='geckolibs',
            version=args.revision,
            packaging=packaging_type
        )
    )

    with open(geckoview_pom_path, 'wt') as f:
        f.write(geckoview_pom)

    geckolibs_ivy_path = os.path.join(args.dir, 'ivy-geckolibs-{revision}.xml').format(revision=args.revision)
    paths_to_hash.append(geckolibs_ivy_path)
    with open(geckolibs_ivy_path, 'wt') as f:
        f.write(IVY_XML_TEMPLATE.format(
            organisation=groupId,
            module='geckolibs',
            revision=args.revision,
            publication=args.revision, # A white lie.
            name='geckolibs',
            type=packaging_type,
            ext=packaging_type,
            dependencies=''
        ))

    geckoview_ivy_path = os.path.join(args.dir, 'ivy-geckoview-{revision}.xml').format(revision=args.revision)
    paths_to_hash.append(geckoview_ivy_path)
    with open(geckoview_ivy_path, 'wt') as f:
        f.write(IVY_XML_TEMPLATE.format(
            organisation=groupId,
            module='geckoview',
            revision=args.revision,
            publication=args.revision, # A white lie.
            name='geckoview',
            type=packaging_type,
            ext=packaging_type,
            dependencies=IVY_XML_DEPENDENCY_TEMPLATE.format(
                organisation=groupId,
                name='geckolibs',
                revision=args.revision)
        ))

    for p in paths_to_hash:
        sha = "%s.sha1" % p
        with open(sha, 'wt') as f:
            f.write(util.hash_file(p, hasher=hashlib.sha1()))
        if args.verbose:
            print(p)
            print(sha)

    return 0
Exemplo n.º 14
0
def main(args):
    parser = argparse.ArgumentParser()
    parser.add_argument(dest='dir',
                        metavar='DIR',
                        help='Path to write Android ARchives and metadata to.')
    parser.add_argument('--verbose',
                        '-v',
                        default=False,
                        action='store_true',
                        help='be verbose')
    parser.add_argument('--revision', help='Revision identifier to write.')
    parser.add_argument('--topsrcdir', help='Top source directory.')
    parser.add_argument('--distdir',
                        help='Distribution directory (usually $OBJDIR/dist).')
    args = parser.parse_args(args)

    # An Ivy 'publication' date must be given in the form yyyyMMddHHmmss, and Mozilla buildids are in this format.
    if len(args.revision) != 14:
        raise ValueError('Revision must be in yyyyMMddHHmmss format: %s' %
                         args.revision)

    paths_to_hash = []

    groupId = 'org.mozilla'
    packaging_type = 'aar'
    gecklibs_aar = os.path.join(
        args.dir, 'geckolibs-{revision}.aar').format(revision=args.revision)
    paths_to_hash.append(gecklibs_aar)
    geckoview_aar = os.path.join(
        args.dir, 'geckoview-{revision}.aar').format(revision=args.revision)
    paths_to_hash.append(geckoview_aar)

    package_geckolibs_aar(args.topsrcdir, args.distdir, gecklibs_aar)
    package_geckoview_aar(args.topsrcdir, args.distdir, geckoview_aar)

    geckolibs_pom_path = os.path.join(
        args.dir, 'geckolibs-{revision}.pom').format(revision=args.revision)
    paths_to_hash.append(geckolibs_pom_path)
    geckolibs_pom = MAVEN_POM_TEMPLATE.format(groupId=groupId,
                                              artifactId='geckolibs',
                                              version=args.revision,
                                              packaging=packaging_type,
                                              dependencies='')

    with open(geckolibs_pom_path, 'wt') as f:
        f.write(geckolibs_pom)

    geckoview_pom_path = os.path.join(
        args.dir, 'geckoview-{revision}.pom').format(revision=args.revision)
    paths_to_hash.append(geckoview_pom_path)
    geckoview_pom = MAVEN_POM_TEMPLATE.format(
        groupId=groupId,
        artifactId='geckoview',
        version=args.revision,
        packaging=packaging_type,
        dependencies=MAVEN_POM_DEPENDENCY_TEMPLATE.format(
            groupId=groupId,
            artifactId='geckolibs',
            version=args.revision,
            packaging=packaging_type))

    with open(geckoview_pom_path, 'wt') as f:
        f.write(geckoview_pom)

    geckolibs_ivy_path = os.path.join(
        args.dir,
        'ivy-geckolibs-{revision}.xml').format(revision=args.revision)
    paths_to_hash.append(geckolibs_ivy_path)
    with open(geckolibs_ivy_path, 'wt') as f:
        f.write(
            IVY_XML_TEMPLATE.format(
                organisation=groupId,
                module='geckolibs',
                revision=args.revision,
                publication=args.revision,  # A white lie.
                name='geckolibs',
                type=packaging_type,
                ext=packaging_type,
                dependencies=''))

    geckoview_ivy_path = os.path.join(
        args.dir,
        'ivy-geckoview-{revision}.xml').format(revision=args.revision)
    paths_to_hash.append(geckoview_ivy_path)
    with open(geckoview_ivy_path, 'wt') as f:
        f.write(
            IVY_XML_TEMPLATE.format(
                organisation=groupId,
                module='geckoview',
                revision=args.revision,
                publication=args.revision,  # A white lie.
                name='geckoview',
                type=packaging_type,
                ext=packaging_type,
                dependencies=IVY_XML_DEPENDENCY_TEMPLATE.format(
                    organisation=groupId,
                    name='geckolibs',
                    revision=args.revision)))

    for p in paths_to_hash:
        sha = "%s.sha1" % p
        with open(sha, 'wt') as f:
            f.write(util.hash_file(p, hasher=hashlib.sha1()))
        if args.verbose:
            print(p)
            print(sha)

    return 0
Exemplo n.º 15
0
def main(args):
    parser = argparse.ArgumentParser()
    parser.add_argument(dest="dir", metavar="DIR", help="Path to write Android ARchives and metadata to.")
    parser.add_argument("--verbose", "-v", default=False, action="store_true", help="be verbose")
    parser.add_argument("--revision", help="Revision identifier to write.")
    parser.add_argument("--topsrcdir", help="Top source directory.")
    parser.add_argument("--distdir", help="Distribution directory (usually $OBJDIR/dist).")
    parser.add_argument("--appname", help='Application name (usually $MOZ_APP_NAME, like "fennec").')
    parser.add_argument(
        "--purge-old",
        default=False,
        action="store_true",
        help="Delete any existing output files in the output directory.",
    )
    args = parser.parse_args(args)

    # An Ivy 'publication' date must be given in the form yyyyMMddHHmmss, and Mozilla buildids are in this format.
    if len(args.revision) != 14:
        raise ValueError("Revision must be in yyyyMMddHHmmss format: %s" % args.revision)

    paths_to_hash = []

    groupId = "org.mozilla"
    packaging_type = "aar"
    gecklibs_aar = os.path.join(args.dir, "geckolibs-{revision}.aar").format(revision=args.revision)
    paths_to_hash.append(gecklibs_aar)
    geckoview_aar = os.path.join(args.dir, "geckoview-{revision}.aar").format(revision=args.revision)
    paths_to_hash.append(geckoview_aar)

    if args.purge_old:
        old_output_finder = FileFinder(args.dir, find_executables=False)
        for p, f in old_output_finder.find("geckoview-*.*"):
            os.remove(f.path)
        for p, f in old_output_finder.find("geckolibs-*.*"):
            os.remove(f.path)
        for p, f in old_output_finder.find("ivy-*.*"):
            os.remove(f.path)

    package_geckolibs_aar(args.topsrcdir, args.distdir, args.appname, gecklibs_aar)
    package_geckoview_aar(args.topsrcdir, args.distdir, args.appname, geckoview_aar)

    geckolibs_pom_path = os.path.join(args.dir, "geckolibs-{revision}.pom").format(revision=args.revision)
    paths_to_hash.append(geckolibs_pom_path)
    geckolibs_pom = MAVEN_POM_TEMPLATE.format(
        groupId=groupId, artifactId="geckolibs", version=args.revision, packaging=packaging_type, dependencies=""
    )

    with open(geckolibs_pom_path, "wt") as f:
        f.write(geckolibs_pom)

    geckoview_pom_path = os.path.join(args.dir, "geckoview-{revision}.pom").format(revision=args.revision)
    paths_to_hash.append(geckoview_pom_path)
    geckoview_pom = MAVEN_POM_TEMPLATE.format(
        groupId=groupId,
        artifactId="geckoview",
        version=args.revision,
        packaging=packaging_type,
        dependencies=MAVEN_POM_DEPENDENCY_TEMPLATE.format(
            groupId=groupId, artifactId="geckolibs", version=args.revision, packaging=packaging_type
        ),
    )

    with open(geckoview_pom_path, "wt") as f:
        f.write(geckoview_pom)

    geckolibs_ivy_path = os.path.join(args.dir, "ivy-geckolibs-{revision}.xml").format(revision=args.revision)
    paths_to_hash.append(geckolibs_ivy_path)
    with open(geckolibs_ivy_path, "wt") as f:
        f.write(
            IVY_XML_TEMPLATE.format(
                organisation=groupId,
                module="geckolibs",
                revision=args.revision,
                publication=args.revision,  # A white lie.
                name="geckolibs",
                type=packaging_type,
                ext=packaging_type,
                dependencies="",
            )
        )

    geckoview_ivy_path = os.path.join(args.dir, "ivy-geckoview-{revision}.xml").format(revision=args.revision)
    paths_to_hash.append(geckoview_ivy_path)
    with open(geckoview_ivy_path, "wt") as f:
        f.write(
            IVY_XML_TEMPLATE.format(
                organisation=groupId,
                module="geckoview",
                revision=args.revision,
                publication=args.revision,  # A white lie.
                name="geckoview",
                type=packaging_type,
                ext=packaging_type,
                dependencies=IVY_XML_DEPENDENCY_TEMPLATE.format(
                    organisation=groupId, name="geckolibs", revision=args.revision
                ),
            )
        )

    for p in paths_to_hash:
        sha = "%s.sha1" % p
        with open(sha, "wt") as f:
            f.write(util.hash_file(p, hasher=hashlib.sha1()))
        if args.verbose:
            print(p)
            print(sha)

    return 0