Esempio n. 1
0
int query_windows(){
    string arch = lower_case(architecture());
#ifdef __WIN32__
    return 1;
#else
    if(grepp(arch,"windows") || grepp(arch,"cygwin")) return 1;
#endif
    return 0;
}
Esempio n. 2
0
bool Abi::isCompatibleWith(const Abi &other) const
{
    bool isCompat = (architecture() == other.architecture() || other.architecture() == Abi::UnknownArchitecture)
                     && (os() == other.os() || other.os() == Abi::UnknownOS)
                     && (osFlavor() == other.osFlavor() || other.osFlavor() == Abi::UnknownFlavor)
                     && (binaryFormat() == other.binaryFormat() || other.binaryFormat() == Abi::UnknownFormat)
                     && ((wordWidth() == other.wordWidth() && wordWidth() != 0) || other.wordWidth() == 0);
    // *-linux-generic-* is compatible with *-linux-* (both ways): This is for the benefit of
    // people building Qt themselves using e.g. a meego toolchain.
    //
    // We leave it to the specific targets to catch filter out the tool chains that do not
    // work for them.
    if (!isCompat && (architecture() == other.architecture() || other.architecture() == Abi::UnknownArchitecture)
                  && ((os() == other.os()) && (os() == LinuxOS))
                  && (osFlavor() == GenericLinuxFlavor || other.osFlavor() == GenericLinuxFlavor)
                  && (binaryFormat() == other.binaryFormat() || other.binaryFormat() == Abi::UnknownFormat)
                  && ((wordWidth() == other.wordWidth() && wordWidth() != 0) || other.wordWidth() == 0))
        isCompat = true;
    return isCompat;
}
Esempio n. 3
0
string query_os_type(){
    string config_file, s1, s2, s3;
    if(function_exists("architecture",load_object("/secure/sefun/sefun"))){
        string arch = lower_case(architecture());
        if(grepp(arch,"windows") || grepp(arch,"cygwin")) return "windows";
        else return "unix";
    }
    if(!file_exists("/secure/cfg/mudos.cfg")) return "unknown";
    config_file = read_matching_line("/secure/cfg/mudos.cfg","mudlib directory :");
    if(!config_file) return "";
    if(sscanf(config_file,"%s:%s:%s",s1,s2,s3) == 3){
        return "windows";
    }
    else return "unix";
}
Esempio n. 4
0
bool DebFile::check()
{
    // check arch
    if (architecture().empty()) {
        m_errorMsg = "No Architecture field in the package";
        return false;
    }

    std::cout << architecture() << std::endl;
    if (architecture().compare("all") != 0 &&
            architecture().compare(_config->Find("APT::Architecture")) != 0) {
        m_errorMsg = "Wrong architecture ";
        m_errorMsg.append(architecture());
        return false;
    }
    //     if not "Architecture" in self._sections:
    //         self._dbg(1, "ERROR: no architecture field")
    //         self._failure_string = _("No Architecture field in the package")
    //         return False
    //     arch = self._sections["Architecture"]
    //     if  arch != "all" and arch != apt_pkg.config.find("APT::Architecture"):
    //         self._dbg(1, "ERROR: Wrong architecture dude!")
    //         self._failure_string = _("Wrong architecture '%s'") % arch
    //         return False
    //
    //     // check version
    //     if self.compare_to_version_in_cache() == self.VERSION_OUTDATED:
    //         if self._cache[self.pkgname].installed:
    //             // the deb is older than the installed
    //             self._failure_string = _("A later version is already installed")
    //             return False
    //
    //     // FIXME: this sort of error handling sux
    //     self._failure_string = ""
    //
    //     // check conflicts
    //     if not self.check_conflicts():
    //         return False
    //
    //     // check if installing it would break anything on the
    //     // current system
    //     if not self.check_breaks_existing_packages():
    //         return False
    //
    //     // try to satisfy the dependencies
    //     if not self._satisfy_depends(self.depends):
    //         return False
    //
    //     // check for conflicts again (this time with the packages that are
    //     // makeed for install)
    //     if not self.check_conflicts():
    //         return False
    //
    //     if self._cache._depcache.broken_count > 0:
    //         self._failure_string = _("Failed to satisfy all dependencies "
    //                                     "(broken cache)")
    //         // clean the cache again
    //         self._cache.clear()
    //         return False
    return true;
}
Esempio n. 5
0
Value *DataflowAnalyzer::computeValue(const Term *term, const MemoryLocation &memoryLocation,
                                      const ReachingDefinitions &definitions) {
    assert(term);
    assert(term->isRead());
    assert(memoryLocation || definitions.empty());

    auto value = dataflow().getValue(term);

    if (definitions.empty()) {
        return value;
    }

    auto byteOrder = architecture()->getByteOrder(memoryLocation.domain());

    /*
     * Merge abstract values.
     */
    auto abstractValue = value->abstractValue();

    foreach (const auto &chunk, definitions.chunks()) {
        assert(memoryLocation.covers(chunk.location()));

        /*
         * Mask of bits inside abstractValue which are covered by chunk's location.
         */
        auto mask = bitMask<ConstantValue>(chunk.location().size());
        if (byteOrder == ByteOrder::LittleEndian) {
            mask = bitShift(mask, chunk.location().addr() - memoryLocation.addr());
        } else {
            mask = bitShift(mask, memoryLocation.endAddr() - chunk.location().endAddr());
        }

        foreach (auto definition, chunk.definitions()) {
            auto definitionLocation = dataflow().getMemoryLocation(definition);
            assert(definitionLocation.covers(chunk.location()));

            auto definitionValue = dataflow().getValue(definition);
            auto definitionAbstractValue = definitionValue->abstractValue();

            /*
             * Shift definition's abstract value to match term's location.
             */
            if (byteOrder == ByteOrder::LittleEndian) {
                definitionAbstractValue.shift(definitionLocation.addr() - memoryLocation.addr());
            } else {
                definitionAbstractValue.shift(memoryLocation.endAddr() - definitionLocation.endAddr());
            }

            /* Project the value to the defined location. */
            definitionAbstractValue.project(mask);

            /* Update term's value. */
            abstractValue.merge(definitionAbstractValue);
        }
    }

    value->setAbstractValue(abstractValue.resize(term->size()));

    /*
     * Merge stack offset and product flags.
     *
     * Heuristic: merge information only from terms that define lower bits of the term's value.
     */
    const std::vector<const Term *> *lowerBitsDefinitions = nullptr;

    if (byteOrder == ByteOrder::LittleEndian) {
        if (definitions.chunks().front().location().addr() == memoryLocation.addr()) {
            lowerBitsDefinitions = &definitions.chunks().front().definitions();
        }
    } else {
        if (definitions.chunks().back().location().endAddr() == memoryLocation.endAddr()) {
            lowerBitsDefinitions = &definitions.chunks().back().definitions();
        }
    }

    if (lowerBitsDefinitions) {
        foreach (auto definition, *lowerBitsDefinitions) {
            auto definitionValue = dataflow().getValue(definition);

            if (definitionValue->isNotStackOffset()) {
                value->makeNotStackOffset();
            } else if (definitionValue->isStackOffset()) {
                value->makeStackOffset(definitionValue->stackOffset());
            }

            if (definitionValue->isNotProduct()) {
                value->makeNotProduct();
            } else if (definitionValue->isProduct()) {
                value->makeProduct();
            }
        }
    }

    /*
     * Merge return address flag.
     */
    if (definitions.chunks().front().location() == memoryLocation) {
        foreach (auto definition, definitions.chunks().front().definitions()) {
            auto definitionValue = dataflow().getValue(definition);
            if (definitionValue->isNotReturnAddress()) {
                value->makeNotReturnAddress();
            } else if (definitionValue->isReturnAddress()) {
                value->makeReturnAddress();
            }
        }
    }
Esempio n. 6
0
bool DataflowAnalyzer::isTracked(const MemoryLocation &memoryLocation) const {
    return memoryLocation && !architecture()->isGlobalMemory(memoryLocation);
}
Esempio n. 7
0
int main(int argc, char *argv[])
{
    static const advgetopt::getopt::option options[] = {
        {
            '\0',
            0,
            NULL,
            NULL,
            "Usage: dep2graph [-<opt>] <package> ...",
            advgetopt::getopt::help_argument
        },
        {
            '\0',
            0,
            "admindir",
            "var/lib/wpkg",
            "define the administration directory (i.e. wpkg database folder), default is /var/lib/wpkg",
            advgetopt::getopt::required_argument
        },
        {
            '\0',
            0,
            "instdir",
            "",
            "specify the installation directory, where files get unpacked, by default the root is used",
            advgetopt::getopt::required_argument
        },
        {
            '\0',
            0,
            "root",
            "/",
            "define the root directory (i.e. where everything is installed), default is /",
            advgetopt::getopt::required_argument
        },
        {
            'o',
            0,
            "output",
            NULL,
            "define a filename where the final PNG is saved",
            advgetopt::getopt::required_argument
        },
        {
            'f',
            0,
            "filename",
            NULL,
            NULL, // hidden argument in --help screen
            advgetopt::getopt::default_multiple_argument
        },
        {
            'h',
            0,
            "help",
            NULL,
            "print this help message",
            advgetopt::getopt::no_argument
        },
        {
            '\0',
            0,
            "help-nobr",
            NULL,
            NULL,
            advgetopt::getopt::no_argument
        },
        {
            '\0',
            0,
            "version",
            NULL,
            "show the version of deb2graph",
            advgetopt::getopt::no_argument
        },
        {
            'v',
            0,
            "verbose",
            NULL,
            "print additional information as available",
            advgetopt::getopt::no_argument
        },
        {
            '\0',
            0,
            "license",
            NULL,
            "displays the license of this tool",
            advgetopt::getopt::no_argument
        },
        {
            '\0',
            0,
            "licence", // French spelling
            NULL,
            NULL, // hidden argument in --help screen
            advgetopt::getopt::no_argument
        },
        {
            '\0',
            0,
            NULL,
            NULL,
            NULL,
            advgetopt::getopt::end_of_options
        }
    };

    std::vector<std::string> configuration_files;
    advgetopt::getopt opt(argc, argv, options, configuration_files, "");

    if(opt.is_defined("help") || opt.is_defined("help-nobr"))
    {
        opt.usage(opt.is_defined("help-nobr") ? advgetopt::getopt::no_error_nobr : advgetopt::getopt::no_error, "Usage: deb2graph [-<opt>] <package> ...");
        /*NOTREACHED*/
    }

    if(opt.is_defined("version"))
    {
        printf("%s\n", debian_packages_version_string());
        exit(1);
    }

    if(opt.is_defined("license") || opt.is_defined("licence"))
    {
        license::license();
        exit(1);
    }

    bool verbose(opt.is_defined("verbose"));

    // get the size, if zero it's undefined
    int max(opt.size("filename"));
    if(max == 0)
    {
        opt.usage(advgetopt::getopt::error, "at least one debian package must be specified on the command line");
        /*NOTREACHED*/
    }

    // all these directories have a default if not specified on the command line
    manager.set_root_path(opt.get_string("root"));
    manager.set_inst_path(opt.get_string("instdir"));
    manager.set_database_path(opt.get_string("admindir"));
    manager.set_control_file_state(std::shared_ptr<wpkg_control::control_file::control_file_state_t>(new wpkg_control::control_file::contents_control_file_state_t));

    // start creating the .dot file
    dot.create(memfile::memory_file::file_format_other);
    dot.printf("digraph {\nrankdir=BT;\nlabel=\"Debian Package Dependency Graph\";\n");

    node_names_t nodes;
    node_names_t deps; // dependencies not found on the command line

    // load all the packages
    dot.printf("/* Explicit Packages */\n");
    for(int i = 0; i < max; ++i)
    {
        std::string package_filename(opt.get_string("filename", i));
        // avoid adding the exact same package more than once
        if(verbose)
        {
            printf("Package \"%s\" loaded.\n", package_filename.c_str());
        }
        manager.load_package(package_filename);
        std::string package(manager.get_field(package_filename, "Package"));
        package_info_t info;
        info.f_package = package;
        info.f_filename = package_filename;
        info.f_nodecount = node_count;
        nodes.push_back(info);
        std::string version(manager.get_field(package_filename, "Version"));
        std::string architecture(manager.get_field(package_filename, "Architecture"));
        dot.printf("n%d [label=\"%s %s\\n%s\",shape=box];\n", node_count, package.c_str(), version.c_str(), architecture.c_str());
        ++node_count;
    }

    // edges font size to small
    dot.printf("edge [fontsize=8,fontcolor=\"#990033\",color=\"#cccccc\"];\n");

    // use the dependency fields to define all the nodes of the graph
    dot.printf("edge [style=dashed];\n");
    add_nodes(nodes, deps, "Build-Depends");
    dot.printf("edge [style=bold,color=\"#8888ff\"];\n");
    add_nodes(nodes, deps, "Pre-Depends");
    dot.printf("edge [style=solid,color=\"#aaaaaa\"];\n");
    add_nodes(nodes, deps, "Depends");
    dot.printf("edge [color=\"#ff8888\"];\n");
    add_nodes(nodes, deps, "Breaks");
    dot.printf("edge [style=bold,arrowhead=tee];\n");
    add_nodes(nodes, deps, "Conflicts");

    // close the digraph
    dot.printf("}\n");

    dot.write_file("deb2graph.dot");

    std::string cmd("dot -Tsvg deb2graph.dot >");
    if(opt.is_defined("output"))
    {
        cmd += opt.get_string("output");
    }
    else
    {
        cmd += "deb2graph.svg";
    }

    const int status = system(cmd.c_str());
    if( status == -1 )
    {
        // TODO: Add a message here stating the command could not be launched...
        return 1;
    }

    return status;
}