+set<string> pkgadd::apply_install_rules(const string& name, pkginfo_t& info, const vector<rule_t>& rules)
+{
+ // TODO: better algo(?)
+ set<string> install_set;
+ set<string> non_install_set;
+ vector<rule_t> found;
+
+ find_rules(rules, INSTALL, found);
+
+ for (set<string>::const_iterator i = info.files.begin(); i != info.files.end(); i++) {
+ bool install_file = true;
+
+ for (vector<rule_t>::reverse_iterator j = found.rbegin(); j != found.rend(); j++) {
+ if (rule_applies_to_file(*j, *i)) {
+ install_file = (*j).action;
+ break;
+ }
+ }
+
+ if (install_file)
+ install_set.insert(install_set.end(), *i);
+ else
+ non_install_set.insert(*i);
+ }
+
+ info.files.clear();
+ info.files = install_set;
+
+#ifndef NDEBUG
+ cerr << "Install set:" << endl;
+ for (set<string>::iterator j = info.files.begin(); j != info.files.end(); j++) {
+ cerr << " " << (*j) << endl;
+ }
+ cerr << endl;
+
+ cerr << "Non-Install set:" << endl;
+ for (set<string>::iterator j = non_install_set.begin(); j != non_install_set.end(); j++) {
+ cerr << " " << (*j) << endl;
+ }
+ cerr << endl;
+#endif
+
+ return non_install_set;
+}
+