Exemple #1
0
def elbe_report(xml, buildenv, cache, reportname, targetfs):
    outf = ASCIIDocLog(reportname)
    rfs = buildenv.rfs

    outf.h1("ELBE Report for Project " + xml.text("project/name"))

    outf.printo("report timestamp: " +
                datetime.now().strftime("%Y%m%d-%H%M%S"))

    slist = rfs.read_file('etc/apt/sources.list')
    outf.h2("Apt Sources dump")
    outf.verbatim_start()
    outf.print_raw(slist)
    outf.verbatim_end()

    try:
        prefs = rfs.read_file("etc/apt/preferences")
    except IOError:
        prefs = ""

    outf.h2("Apt Preferences dump")
    outf.verbatim_start()
    outf.print_raw(prefs)
    outf.verbatim_end()

    outf.h2("Installed Packages List")
    outf.table()

    instpkgs = cache.get_installed_pkgs()
    for p in instpkgs:
        outf.printo("|%s|%s|%s" % (p.name, p.installed_version, p.origin))
    outf.table()

    # archive extraction is done before and after finetuning the first
    # extraction is needed that the files can be used (copied/moved to the
    # buildenv in finetuning
    # the second extraction is done to ensure that files from the archive
    # can't be modified/removed in finetuning

    outf.h2("archive extract before finetuning")

    if xml.has("archive"):
        with xml.archive_tmpfile() as fp:
            outf.do('tar xvfj "%s" -C "%s"' % (fp.name, targetfs.path))

    outf.h2("finetuning log")
    outf.verbatim_start()

    index = cache.get_fileindex()
    mt_index = targetfs.mtime_snap()
    if xml.has("target/finetuning"):
        do_finetuning(xml, outf, buildenv, targetfs)
        #outf.print_raw( do_command( opt.finetuning ) )
        mt_index_post_fine = targetfs.mtime_snap()
    else:
        mt_index_post_fine = mt_index

    outf.verbatim_end()

    outf.h2("archive extract after finetuning")

    if xml.has("archive"):
        with xml.archive_tmpfile() as fp:
            outf.do('tar xvfj "%s" -C "%s"' % (fp.name, targetfs.path))
        mt_index_post_arch = targetfs.mtime_snap()
    else:
        mt_index_post_arch = mt_index_post_fine

    outf.h2("fileslist")
    outf.table()

    tgt_pkg_list = set()

    for fpath, realpath in targetfs.walk_files():
        if index.has_key(fpath):
            pkg = index[fpath]
            tgt_pkg_list.add(pkg)
        else:
            pkg = "postinst generated"

        if mt_index_post_fine.has_key(fpath) and mt_index.has_key(fpath):
            if mt_index_post_fine[fpath] > mt_index[fpath]:
                pkg = "modified finetuning"
        if mt_index_post_fine.has_key(fpath):
            if mt_index_post_arch[fpath] > mt_index_post_fine[fpath]:
                pkg = "from archive"
            elif not mt_index.has_key(fpath):
                pkg = "added in finetuning"
        else:
            pkg = "added in archive"

        outf.printo("|+%s+|%s" % (fpath, pkg))

    outf.table()

    outf.h2("Deleted Files")
    outf.table()
    for fpath in mt_index.keys():
        if not mt_index_post_arch.has_key(fpath):
            if index.has_key(fpath):
                pkg = index[fpath]
            else:
                pkg = "postinst generated"
            outf.printo("|+%s+|%s" % (fpath, pkg))
    outf.table()

    outf.h2("Target Package List")
    outf.table()
    instpkgs = cache.get_installed_pkgs()
    pkgindex = {}
    for p in instpkgs:
        pkgindex[p.name] = p

    if xml.has("target/pkgversionlist"):
        targetfs.remove('etc/elbe_pkglist')
        f = targetfs.open('etc/elbe_pkglist', 'w')
    for pkg in tgt_pkg_list:
        p = pkgindex[pkg]
        outf.printo("|%s|%s|%s|%s" % (p.name, p.installed_version,
                                      p.is_auto_installed, p.installed_md5))
        if xml.has("target/pkgversionlist"):
            f.write("%s %s %s\n" %
                    (p.name, p.installed_version, p.installed_md5))
    outf.table()

    if xml.has("target/pkgversionlist"):
        f.close()
Exemple #2
0
def elbe_report(xml, buildenv, cache, reportname, errorname, targetfs):

    # pylint: disable=too-many-arguments
    # pylint: disable=too-many-locals
    # pylint: disable=too-many-statements
    # pylint: disable=too-many-branches

    outf = ASCIIDocLog(reportname)
    rfs = buildenv.rfs

    outf.h1("ELBE Report for Project " + xml.text("project/name"))

    outf.printo(
        "report timestamp: " +
        datetime.now().strftime("%Y%m%d-%H%M%S"))
    outf.printo("elbe: %s" % str(elbe_version))

    slist = rfs.read_file('etc/apt/sources.list')
    outf.h2("Apt Sources dump")
    outf.verbatim_start()
    outf.print_raw(slist)
    outf.verbatim_end()

    try:
        prefs = rfs.read_file("etc/apt/preferences")
    except IOError:
        prefs = ""

    outf.h2("Apt Preferences dump")
    outf.verbatim_start()
    outf.print_raw(prefs)
    outf.verbatim_end()

    outf.h2("Installed Packages List")
    outf.table()

    instpkgs = cache.get_installed_pkgs()
    for p in instpkgs:
        outf.printo("|%s|%s|%s" % (p.name, p.installed_version, p.origin))
    outf.table()

    index = cache.get_fileindex()
    mt_index = targetfs.mtime_snap()

    outf.h2("archive extract")

    if xml.has("archive") and not xml.text("archive") is None:
        with xml.archive_tmpfile() as fp:
            outf.do('tar xvfj "%s" -C "%s"' % (fp.name, targetfs.path))
        mt_index_postarch = targetfs.mtime_snap()
    else:
        mt_index_postarch = mt_index

    outf.h2("finetuning log")
    outf.verbatim_start()

    if xml.has("target/finetuning"):
        do_finetuning(xml, outf, buildenv, targetfs)
        mt_index_post_fine = targetfs.mtime_snap()
    else:
        mt_index_post_fine = mt_index_postarch

    outf.verbatim_end()

    outf.h2("fileslist")
    outf.table()

    tgt_pkg_list = set()

    for fpath, _ in targetfs.walk_files():
        if fpath in index:
            pkg = index[fpath]
            tgt_pkg_list.add(pkg)
        else:
            pkg = "postinst generated"

        if fpath in mt_index_post_fine:
            if fpath in mt_index_postarch:
                if mt_index_post_fine[fpath] != mt_index_postarch[fpath]:
                    pkg = "modified finetuning"
                elif fpath in mt_index:
                    if mt_index_postarch[fpath] != mt_index[fpath]:
                        pkg = "from archive"
                    # else leave pkg as is
                else:
                    pkg = "added in archive"
            else:
                pkg = "added in finetuning"
        # else leave pkg as is

        outf.printo("|+%s+|%s" % (fpath, pkg))

    outf.table()

    outf.h2("Deleted Files")
    outf.table()
    for fpath in list(mt_index.keys()):
        if fpath not in mt_index_post_fine:
            if fpath in index:
                pkg = index[fpath]
            else:
                pkg = "postinst generated"
            outf.printo("|+%s+|%s" % (fpath, pkg))
    outf.table()

    outf.h2("Target Package List")
    outf.table()
    instpkgs = cache.get_installed_pkgs()
    pkgindex = {}
    for p in instpkgs:
        pkgindex[p.name] = p

    if xml.has("target/pkgversionlist"):
        targetfs.remove('etc/elbe_pkglist')
        f = targetfs.open('etc/elbe_pkglist', 'w')
    for pkg in tgt_pkg_list:
        p = pkgindex[pkg]
        outf.printo(
            "|%s|%s|%s|%s" %
            (p.name,
             p.installed_version,
             p.is_auto_installed,
             p.installed_md5))
        if xml.has("target/pkgversionlist"):
            f.write(
                "%s %s %s\n" %
                (p.name,
                 p.installed_version,
                 p.installed_md5))
    outf.table()

    if xml.has("target/pkgversionlist"):
        f.close()

    if not xml.has("archive") or xml.text("archive") is None:
        return

    elog = ASCIIDocLog(errorname, True)

    elog.h1("Archive validation")

    errors = 0

    for fpath in list(mt_index_postarch.keys()):
        if fpath not in mt_index or \
                mt_index_postarch[fpath] != mt_index[fpath]:
            if fpath not in mt_index_post_fine:
                elog.printo(
                        "- archive file %s deleted in finetuning" %
                        fpath)
                errors += 1
            elif mt_index_post_fine[fpath] != mt_index_postarch[fpath]:
                elog.printo(
                        "- archive file %s modified in finetuning" %
                        fpath)
                errors += 1

    if errors == 0:
        elog.printo("No Errors found")
Exemple #3
0
def elbe_report(xml, buildenv, cache, reportname, errorname, targetfs):

    # pylint: disable=too-many-arguments
    # pylint: disable=too-many-locals
    # pylint: disable=too-many-statements
    # pylint: disable=too-many-branches

    outf = ASCIIDocLog(reportname)
    rfs = buildenv.rfs

    outf.h1("ELBE Report for Project " + xml.text("project/name"))

    outf.printo("report timestamp: " +
                datetime.now().strftime("%Y%m%d-%H%M%S"))
    outf.printo("elbe: %s" % str(elbe_version))

    slist = rfs.read_file('etc/apt/sources.list')
    outf.h2("Apt Sources dump")
    outf.verbatim_start()
    outf.print_raw(slist)
    outf.verbatim_end()

    try:
        prefs = rfs.read_file("etc/apt/preferences")
    except IOError:
        prefs = ""

    outf.h2("Apt Preferences dump")
    outf.verbatim_start()
    outf.print_raw(prefs)
    outf.verbatim_end()

    outf.h2("Installed Packages List")
    outf.table()

    instpkgs = cache.get_installed_pkgs()
    for p in instpkgs:
        outf.printo("|%s|%s|%s" % (p.name, p.installed_version, p.origin))
    outf.table()

    index = cache.get_fileindex()
    mt_index = targetfs.mtime_snap()

    outf.h2("archive extract")

    if xml.has("archive") and not xml.text("archive") is None:
        with xml.archive_tmpfile() as fp:
            outf.do('tar xvfj "%s" -h -C "%s"' % (fp.name, targetfs.path))
        mt_index_postarch = targetfs.mtime_snap()
    else:
        mt_index_postarch = mt_index

    outf.h2("finetuning log")
    outf.verbatim_start()

    if xml.has("target/finetuning"):
        do_finetuning(xml, outf, buildenv, targetfs)
        mt_index_post_fine = targetfs.mtime_snap()
    else:
        mt_index_post_fine = mt_index_postarch

    outf.verbatim_end()

    outf.h2("fileslist")
    outf.table()

    tgt_pkg_list = set()

    for fpath, _ in targetfs.walk_files():
        if fpath in index:
            pkg = index[fpath]
            tgt_pkg_list.add(pkg)
        else:
            pkg = "postinst generated"

        if fpath in mt_index_post_fine:
            if fpath in mt_index_postarch:
                if mt_index_post_fine[fpath] != mt_index_postarch[fpath]:
                    pkg = "modified finetuning"
                elif fpath in mt_index:
                    if mt_index_postarch[fpath] != mt_index[fpath]:
                        pkg = "from archive"
                    # else leave pkg as is
                else:
                    pkg = "added in archive"
            else:
                pkg = "added in finetuning"
        # else leave pkg as is

        outf.printo("|+%s+|%s" % (fpath, pkg))

    outf.table()

    outf.h2("Deleted Files")
    outf.table()
    for fpath in list(mt_index.keys()):
        if fpath not in mt_index_post_fine:
            if fpath in index:
                pkg = index[fpath]
            else:
                pkg = "postinst generated"
            outf.printo("|+%s+|%s" % (fpath, pkg))
    outf.table()

    outf.h2("Target Package List")
    outf.table()
    instpkgs = cache.get_installed_pkgs()
    pkgindex = {}
    for p in instpkgs:
        pkgindex[p.name] = p

    if xml.has("target/pkgversionlist"):
        targetfs.remove('etc/elbe_pkglist')
        f = targetfs.open('etc/elbe_pkglist', 'w')
    for pkg in tgt_pkg_list:
        p = pkgindex[pkg]
        outf.printo("|%s|%s|%s|%s" % (p.name, p.installed_version,
                                      p.is_auto_installed, p.installed_md5))
        if xml.has("target/pkgversionlist"):
            f.write("%s %s %s\n" %
                    (p.name, p.installed_version, p.installed_md5))
    outf.table()

    if xml.has("target/pkgversionlist"):
        f.close()

    if not xml.has("archive") or xml.text("archive") is None:
        return

    elog = ASCIIDocLog(errorname, True)

    elog.h1("Archive validation")

    errors = 0

    for fpath in list(mt_index_postarch.keys()):
        if fpath not in mt_index or \
                mt_index_postarch[fpath] != mt_index[fpath]:
            if fpath not in mt_index_post_fine:
                elog.printo("- archive file %s deleted in finetuning" % fpath)
                errors += 1
            elif mt_index_post_fine[fpath] != mt_index_postarch[fpath]:
                elog.printo("- archive file %s modified in finetuning" % fpath)
                errors += 1

    if errors == 0:
        elog.printo("No Errors found")
Exemple #4
0
def elbe_report( xml, buildenv, cache, reportname, targetfs ):
    outf = ASCIIDocLog(reportname)
    rfs = buildenv.rfs

    outf.h1( "ELBE Report for Project " + xml.text("project/name") )

    outf.printo( "report timestamp: "+datetime.now().strftime("%Y%m%d-%H%M%S") )

    slist = rfs.read_file('etc/apt/sources.list')
    outf.h2( "Apt Sources dump" )
    outf.verbatim_start()
    outf.print_raw(slist)
    outf.verbatim_end()

    try:
        prefs = rfs.read_file("etc/apt/preferences")
    except IOError:
        prefs = ""

    outf.h2( "Apt Preferences dump" )
    outf.verbatim_start()
    outf.print_raw(prefs)
    outf.verbatim_end()

    outf.h2( "Installed Packages List" )
    outf.table()

    instpkgs = cache.get_installed_pkgs()
    for p in instpkgs:
        outf.printo( "|%s|%s|%s" % (p.name, p.installed_version, p.origin) )
    outf.table()

    # archive extraction is done before and after finetuning the first
    # extraction is needed that the files can be used (copied/moved to the
    # buildenv in finetuning
    # the second extraction is done to ensure that files from the archive
    # can't be modified/removed in finetuning

    outf.h2( "archive extract before finetuning" )

    if xml.has("archive"):
        with xml.archive_tmpfile() as fp:
            outf.do( 'tar xvfj "%s" -C "%s"' % (fp.name, targetfs.path) )

    outf.h2( "finetuning log" )
    outf.verbatim_start()

    index = cache.get_fileindex()
    mt_index = targetfs.mtime_snap()
    if xml.has("target/finetuning"):
        do_finetuning(xml, outf, buildenv, targetfs)
        #outf.print_raw( do_command( opt.finetuning ) )
        mt_index_post_fine = targetfs.mtime_snap()
    else:
        mt_index_post_fine = mt_index

    outf.verbatim_end()

    outf.h2( "archive extract after finetuning" )

    if xml.has("archive"):
        with xml.archive_tmpfile() as fp:
            outf.do( 'tar xvfj "%s" -C "%s"' % (fp.name, targetfs.path) )
        mt_index_post_arch = targetfs.mtime_snap()
    else:
        mt_index_post_arch = mt_index_post_fine

    outf.h2( "fileslist" )
    outf.table()

    tgt_pkg_list = set()

    for fpath, realpath in targetfs.walk_files():
        if index.has_key(fpath):
            pkg = index[fpath]
            tgt_pkg_list.add(pkg)
        else:
            pkg = "postinst generated"

        if mt_index_post_fine.has_key(fpath) and mt_index.has_key(fpath):
            if mt_index_post_fine[fpath] > mt_index[fpath]:
                pkg = "modified finetuning"
        if mt_index_post_fine.has_key(fpath):
            if mt_index_post_arch[fpath] > mt_index_post_fine[fpath]:
                pkg = "from archive"
            elif not mt_index.has_key(fpath):
                pkg = "added in finetuning"
        else:
            pkg = "added in archive"

        outf.printo( "|+%s+|%s" % (fpath,pkg) )

    outf.table()

    outf.h2( "Deleted Files" )
    outf.table()
    for fpath in mt_index.keys():
        if not mt_index_post_arch.has_key(fpath):
            if index.has_key(fpath):
                pkg = index[fpath]
            else:
                pkg = "postinst generated"
            outf.printo( "|+%s+|%s" % (fpath,pkg) )
    outf.table()

    outf.h2( "Target Package List" )
    outf.table()
    instpkgs = cache.get_installed_pkgs()
    pkgindex = {}
    for p in instpkgs:
        pkgindex[p.name] = p

    if xml.has("target/pkgversionlist"):
        targetfs.remove('etc/elbe_pkglist')
        f = targetfs.open('etc/elbe_pkglist', 'w')
    for pkg in tgt_pkg_list:
        p = pkgindex[pkg]
        outf.printo( "|%s|%s|%s|%s" % (p.name, p.installed_version, p.is_auto_installed, p.installed_md5) )
        if xml.has("target/pkgversionlist"):
            f.write ("%s %s %s\n" % (p.name, p.installed_version, p.installed_md5))
    outf.table()

    if xml.has("target/pkgversionlist"):
        f.close ()