[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#602652: unblock: debtags/1.7.11



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: freeze-exception

Please unblock package debtags

It fixes bug #602634.

The debdiff is somewhat polluted by autotools updates. The important bit
is this one:

diff --git a/configure.ac b/configure.ac
index d6a1c0a..fd717ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(debtags, 1.7.10, [enrico@debian.org])
+AC_INIT(debtags, 1.7.11, [enrico@debian.org])
 AC_CONFIG_SRCDIR([configure.ac])
 AM_CONFIG_HEADER(config.h)
 AM_INIT_AUTOMAKE([foreign])
diff --git a/debian/changelog b/debian/changelog
index 05cec5b..6759936 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+debtags (1.7.11) unstable; urgency=low
+
+  * Update /var/lib/debtags/package-tags. Closes: #602634.
+
+ -- Enrico Zini <enrico@debian.org>  Sat, 06 Nov 2010 19:33:06 +0000
+
 debtags (1.7.10) unstable; urgency=low
 
   * Build with new libept. Closes: #588546
diff --git a/tools/debtags.cc b/tools/debtags.cc
index 4ec2ea0..27a7de9 100644
--- a/tools/debtags.cc
+++ b/tools/debtags.cc
@@ -544,6 +544,68 @@ public:
 	}
 };
 
+struct AtomicStdioWriter
+{
+	std::string fname;
+	char* tmpfname;
+	int fd;
+	FILE* out;
+
+	AtomicStdioWriter(const std::string& fname)
+		: fname(fname), tmpfname(0), out(0), fd(-1)
+	{
+		// Build the temp file template
+		tmpfname = new char[fname.size() + 8];
+		strncpy(tmpfname, fname.c_str(), fname.size());
+		strncpy(tmpfname + fname.size(), ".XXXXXX", 8);
+		// Create and open the temporary file
+		fd = mkstemp(tmpfname);
+		if (fd < 0)
+			throw wibble::exception::File(tmpfname, "opening file");
+
+		// Pass the file descriptor to stdio
+		out = fdopen(fd, "wt");
+		if (!out)
+			throw wibble::exception::File(tmpfname, "fdopening file");
+	}
+
+	~AtomicStdioWriter()
+	{
+		if (out)
+		{
+			if (unlink(tmpfname) == -1)
+				throw wibble::exception::File(tmpfname, "cannot delete temporary file");
+			fclose(out);
+		}
+		if (tmpfname) delete[] tmpfname;
+	}
+
+	void flush()
+	{
+		// Read the current umask
+		mode_t cur_umask = umask(0);
+		umask(cur_umask);
+
+		// Give the file the right permissions
+		if (fchmod(fd, 0666 & ~cur_umask) < 0)
+			throw wibble::exception::File(tmpfname, "setting file permissions");
+
+		// Flush stdio's buffers
+		fflush(out);
+
+		// Flush OS buffers
+		fdatasync(fd);
+
+		// Close the file
+		fclose(out);
+		out = NULL;
+
+		// Rename the successfully written file to its final name
+		if (rename(tmpfname, fname.c_str()) == -1)
+			throw wibble::exception::System(string("renaming ") + tmpfname + " to " + fname);
+	}
+};
+
 int main(int argc, const char* argv[])
 {
 	wibble::commandline::DebtagsOptions opts;
@@ -1172,6 +1234,13 @@ int main(int argc, const char* argv[])
 
 			// Write out the merged, updated vocabulary
 			voc.write();
+
+			// Read and merge all tag sources, and write them out
+			{
+				AtomicStdioWriter writer(debtags::Path::tagdb());
+				env().debtags().output(textformat::StdioWriter(writer.out));
+				writer.flush();
+			}
 		}
 		else if (opts.foundCommand() == opts.vocfilter)
 		{

Code for AtomicStdioWriter comes from ept/debtags/vocabulary.cc in
libept, which is used to atomically write /var/lib/debtags/vocabulary

unblock debtags/1.7.11

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash



Reply to: