summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Zini <enrico@enricozini.org>2015-06-18 09:52:02 +0200
committerEnrico Zini <enrico@enricozini.org>2015-06-18 09:52:02 +0200
commit3da106b8cd121aab3f8650e63ca0ac6d2f4ba7d3 (patch)
treeb9bdfe6c435adc644d2605bfda9bd698633605b1
parent384517ddc1209ec56bc4d5fa4457ef6becb38a84 (diff)
downloadlibept-3da106b8cd121aab3f8650e63ca0ac6d2f4ba7d3.tar.gz
Removed support for patching
-rw-r--r--ept/debtags/debtags.cc115
-rw-r--r--ept/debtags/debtags.h57
-rw-r--r--ept/debtags/debtags.test.h3
3 files changed, 0 insertions, 175 deletions
diff --git a/ept/debtags/debtags.cc b/ept/debtags/debtags.cc
index 5d633f4..371dce8 100644
--- a/ept/debtags/debtags.cc
+++ b/ept/debtags/debtags.cc
@@ -73,127 +73,12 @@ string Debtags::pathname()
return res;
}
-tagcoll::PatchList<std::string, std::string> Debtags::changes() const
-{
- return tagcoll::PatchList<std::string, std::string>();
-}
-
-
-#if 0
-bool Debtags::hasTagDatabase()
-{
- if (Path::access(Path::tagdb(), R_OK) == -1)
- {
- std::cerr << "Missing tag database " << Path::tagdb() << std::endl;
- return false;
- }
- if (Path::access(Path::tagdbIndex(), R_OK) == -1)
- {
- std::cerr << "Missing tag database index " << Path::tagdbIndex() << std::endl;
- return false;
- }
- if (Path::access(Path::vocabulary(), R_OK) == -1)
- {
- std::cerr << "Missing tag vocabulary " << Path::vocabulary() << std::endl;
- return false;
- }
- if (Path::access(Path::vocabularyIndex(), R_OK) == -1)
- {
- std::cerr << "Missing index for tag vocabulary " << Path::vocabularyIndex() << std::endl;
- return false;
- }
- return true;
-}
-#endif
-
-
-void Debtags::savePatch()
-{
- PatchList<std::string, std::string> spatch;
- changes().output(tagcoll::inserter(spatch));
- savePatch(spatch);
-}
-
-void Debtags::savePatch(const PatchList<std::string, std::string>& patch)
-{
- std::string patchFile = str::joinpath(rcdir, "patch");
- std::string backup = patchFile + "~";
-
- wibble::sys::fs::mkFilePath(patchFile);
-
- if (access(patchFile.c_str(), F_OK) == 0)
- if (rename(patchFile.c_str(), backup.c_str()) == -1)
- throw wibble::exception::System("Can't rename " + patchFile + " to " + backup);
-
- try {
- FILE* out = fopen(patchFile.c_str(), "w");
- if (out == 0)
- throw wibble::exception::System("Can't write to " + patchFile);
-
- textformat::outputPatch(patch, out);
-
- fclose(out);
- } catch (std::exception& e) {
- if (rename(backup.c_str(), patchFile.c_str()) == -1)
- std::cerr << "Warning: Cannot restore previous backup copy: " << e.what() << std::endl;
- throw;
- }
-}
-
-void Debtags::sendPatch()
-{
- PatchList<std::string, std::string> spatch;
- changes().output(tagcoll::inserter(spatch));
- if (!spatch.empty())
- {
- sendPatch(spatch);
- }
-}
-
-void Debtags::sendPatch(const PatchList<std::string, std::string>& patch)
-{
- static const char* cmd = "/usr/sbin/sendmail -t";
- FILE* out = popen(cmd, "w");
- if (out == 0)
- throw wibble::exception::System(std::string("trying to run `") + cmd + "'");
-
- struct passwd* udata = getpwuid(getuid());
-
- fprintf(out,
- "To: enrico-debtags@debian.org\n"
- "Bcc: %s\n"
- "Subject: Tag patch\n"
- "Mime-Version: 1.0\n"
- "Content-Type: multipart/mixed; boundary=\"9amGYk9869ThD9tj\"\n"
- "Content-Disposition: inline\n"
- "X-Mailer: debtags-edit\n\n"
- "This mail contains a Debtags patch for the central archive\n\n"
- "--9amGYk9869ThD9tj\n"
- "Content-Type: text/plain; charset=utf-8\n"
- "Content-Disposition: inline\n\n"
- "-- DEBTAGS DIFF V0.1 --\n", udata->pw_name);
-
- textformat::outputPatch(patch, out);
-
- fprintf(out, "\n--9amGYk9869ThD9tj\n");
-
- int res = pclose(out);
- if (!WIFEXITED(res) || WEXITSTATUS(res) != 0)
- {
- std::stringstream str;
- str << res;
- throw wibble::exception::Consistency("checking mailer exit status", "sendmail returned nonzero (" + str.str() + "): the mail may have not been sent");
- }
-}
-
}
}
-#include <tagcoll/patch.tcc>
#include <tagcoll/coll/simple.tcc>
#include <tagcoll/coll/fast.tcc>
#include <tagcoll/TextFormat.tcc>
-//#include <tagcoll/stream/filters.tcc>
// Explicit template instantiations for our stuff
template class tagcoll::coll::Fast<std::string, std::string>;
diff --git a/ept/debtags/debtags.h b/ept/debtags/debtags.h
index f07d3b9..f51daa0 100644
--- a/ept/debtags/debtags.h
+++ b/ept/debtags/debtags.h
@@ -83,63 +83,6 @@ public:
coll_type& tagdb() { return *this; }
const coll_type& tagdb() const { return *this; }
- tagcoll::PatchList<std::string, std::string> changes() const;
-
-#if 0
- /**
- * Get the changes that have been applied to this collection
- */
- const Patches& changes() const { return m_changes; }
-
- /**
- * Throw away all changes previously applied to this collection
- */
- void resetChanges() { m_changes.clear(); }
-
- /**
- * Set the changes list to a specific patch list
- */
- void setChanges(const Patches& changes);
-
- /**
- * Add a specific patch list to the changes list
- */
- void addChanges(const Patches& changes);
-#endif
-
-#if 0
- ItemSet getTaggedItems() const;
-#endif
-
- /**
- * Check if the tag database has been created (i.e. if something
- * equivalend to debtags update has been run)
- */
- //static bool hasTagDatabase();
-
-
- /**
- * Save in the state storage directory a patch that can be used to turn
- * the system database into the collection given
- */
- void savePatch();
-
- /**
- * Save in the state storage directory a patch to turn the system database
- * into the collection given
- */
- void savePatch(const tagcoll::PatchList<std::string, std::string>& patch);
-
- /**
- * Send to the central archive a patch that can be used to turn
- * the system database into the collection given
- */
- void sendPatch();
-
- /**
- * Send the given patch to the central archive
- */
- void sendPatch(const tagcoll::PatchList<std::string, std::string>& patch);
/**
* Return the default pathname for the debtags tags.
diff --git a/ept/debtags/debtags.test.h b/ept/debtags/debtags.test.h
index a2c3dd4..54b57eb 100644
--- a/ept/debtags/debtags.test.h
+++ b/ept/debtags/debtags.test.h
@@ -187,9 +187,6 @@ struct TestDebtags : DebtagsTestEnvironment
assert_eq(empty.timestamp(), 0);
assert(!empty.hasData());
- tagcoll::PatchList<std::string, std::string> patches = empty.changes();
- assert(patches.empty());
-
set<std::string> res = empty.getTagsOfItem("apt");
assert(res.empty());
// TODO: currently does not compile because of a bug in tagcoll