aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2007-08-23 15:52:10 +0200
committerGuido Guenther <agx@bogon.sigxcpu.org>2007-08-23 15:52:10 +0200
commitb1cc0b013eda181e25052a45b6fdc558ad4b96f0 (patch)
treebbc53ebe372ae624d79f7af21c6a5fa6f077f6b9
parente5f5a2ab23ace19c6de39512f76f8fed5f5ad912 (diff)
update packages files atomically
-rw-r--r--debian/changelog7
-rwxr-xr-xmini-dinstall20
2 files changed, 20 insertions, 7 deletions
diff --git a/debian/changelog b/debian/changelog
index 0091f49..be1e906 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+mini-dinstall (0.6.21-0.2) unstable; urgency=low
+
+ * NMU with maintainers approval
+ * update packages files atomically (Closes: #324855)
+
+ -- Guido Guenther <agx@sigxcpu.org> Thu, 23 Aug 2007 15:51:12 +0200
+
mini-dinstall (0.6.21-0.1) unstable; urgency=low
* Non-maintainer upload (with maintainer permission).
diff --git a/mini-dinstall b/mini-dinstall
index e8386a2..675e422 100755
--- a/mini-dinstall
+++ b/mini-dinstall
@@ -19,7 +19,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os, sys, re, glob, getopt, time, traceback, gzip, getpass, socket
-import signal, threading, select, Queue, SocketServer
+import shutil, signal, threading, select, Queue, SocketServer
import logging, logging.handlers
#logging.basicConfig()
import apt_pkg
@@ -1047,19 +1047,25 @@ class ArchiveDirIndexer(threading.Thread):
os.exit(1)
os.close(outfd)
stdout = os.fdopen(infd)
- packagesfile = open(os.path.join(dir, name), 'w')
- zpackagesfile = gzip.GzipFile(os.path.join(dir, name + '.gz'), 'w')
+ packagesfilename = os.path.join(dir, name)
+ newpackagesfilename = packagesfilename + '.new'
+ zpackagesfilename = packagesfilename + '.gz'
+ newzpackagesfilename = newpackagesfilename + '.gz'
+ newpackagesfile = open(newpackagesfilename, 'w')
+ newzpackagesfile = gzip.GzipFile(newzpackagesfilename, 'w')
buf = stdout.read(8192)
while buf != '':
- packagesfile.write(buf)
- zpackagesfile.write(buf)
+ newpackagesfile.write(buf)
+ newzpackagesfile.write(buf)
buf = stdout.read(8192)
stdout.close()
(pid, status) = os.waitpid(pid, 0)
if not (status is None or (os.WIFEXITED(status) and os.WEXITSTATUS(status) == 0)):
raise DinstallException("apt-ftparchive exited with status code %d" % (status,))
- packagesfile.close()
- zpackagesfile.close()
+ newpackagesfile.close()
+ newzpackagesfile.close()
+ shutil.move(newpackagesfilename, packagesfilename)
+ shutil.move(newzpackagesfilename, zpackagesfilename)
def _make_packagesfile(self, dir):
self._make_indexfile(dir, 'packages', 'Packages')