4 #include "zmart-misc.h"
6 #include <zypp/Patch.h>
8 using namespace zypp::detail;
12 using namespace boost;
15 extern RuntimeData gData;
16 extern Settings gSettings;
18 void mark_package_for_install( const std::string &name )
21 capset.insert (CapFactory().parse( ResTraits<Package>::kind, name));
22 //capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo1 > 1.0"));
23 // The user is setting this capablility
24 ResPool::AdditionalCapSet aCapSet;
25 aCapSet[ResStatus::USER] = capset;
26 God->pool().setAdditionalRequire( aCapSet );
31 MIL << "Pool contains " << God->pool().size() << " items." << std::endl;
32 for ( ResPool::const_iterator it = God->pool().begin(); it != God->pool().end(); ++it )
34 Resolvable::constPtr res = it->resolvable();
35 if ( it->status().isToBeInstalled() || it->status().isToBeUninstalled() )
37 if ( it->status().isToBeInstalled() )
39 if ( it->status().isToBeUninstalled() )
40 cout << "<uninstall> ";
41 cout << res->name() << " " << res->edition() << "]" << std::endl;
46 std::string calculate_token()
48 SourceManager_Ptr manager;
49 manager = SourceManager::sourceManager();
52 stringstream token_stream;
53 for ( std::list<Source_Ref>::iterator it = gData.sources.begin(); it != gData.sources.end(); ++it )
57 // if ( gSettings.disable_system_sources == SourcesFromSystem )
59 // if ( gSettings.output_type == OutputTypeNice )
60 // cout << "Refreshing source " << src.alias() << endl;
64 token_stream << "[" << src.alias() << "| " << src.url() << src.timestamp() << "]";
65 MIL << "Source: " << src.alias() << " from " << src.timestamp() << std::endl;
68 token_stream << "[" << "target" << "| " << God->target()->timestamp() << "]";
70 //static std::string digest(const std::string& name, std::istream& is
71 token = Digest::digest("sha1", token_stream);
73 //if ( gSettings.output_type == OutputTypeSimple )
76 MIL << "new token [" << token << "]" << " previous: [" << gSettings.previous_token << "] previous code: " << gSettings.previous_code << std::endl;
83 cout << "Adding system resolvables to pool..." << endl;
84 God->addResolvables( God->target()->resolvables(), true);
89 for ( std::list<Source_Ref>::iterator it = gData.sources.begin(); it != gData.sources.end(); ++it )
92 // skip non YUM sources for now
93 //if ( it->type() == "YUM" )
95 cout << "Adding " << it->alias() << " resolvables to the pool..." << endl;
96 ResStore src_resolvables(it->resolvables());
97 cout << " " << src_resolvables.size() << " resolvables." << endl;
98 God->addResolvables(src_resolvables);
105 cout << "Resolving dependencies ..." << endl;
106 God->resolver()->establishPool();
107 God->resolver()->resolvePool();
112 MIL << "Pool contains " << God->pool().size() << " items. Checking whether available patches are needed." << std::endl;
113 for ( ResPool::byKind_iterator it = God->pool().byKindBegin<Patch>(); it != God->pool().byKindEnd<Patch>(); ++it )
115 Resolvable::constPtr res = it->resolvable();
116 Patch::constPtr patch = asKind<Patch>(res);
117 //cout << patch->name() << " " << patch->edition() << " " << "[" << patch->category() << "]" << ( it->status().isNeeded() ? " [needed]" : " [unneeded]" )<< std::endl;
118 if ( it->status().isNeeded() )
120 gData.patches_count++;
121 if (patch->category() == "security")
122 gData.security_patches_count++;
124 cerr << patch->name() << " " << patch->edition() << " " << "[" << patch->category() << "]" << std::endl;
127 cout << gData.patches_count << " patches needed. ( " << gData.security_patches_count << " security patches )" << std::endl;
130 void usage(int argc, char **argv)
132 cerr << "usage: " << argv[0] << " [<previous token>] [previous result]" << endl;