Changeset 403
- Timestamp:
- 24-06-09 17:17:49 (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
moap/test/test_vcs_svn.py (modified) (2 diffs)
-
moap/vcs/vcs.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r402 r403 1 2009-06-24 Thomas Vander Stichele <thomas at apestaart dot org> 2 3 * moap/test/test_vcs_svn.py: 4 * moap/vcs/vcs.py: 5 Fix for Python 2.3 by avoiding extractall, and working around 6 a hardlinking bug in tarfile in python 2.3 7 1 8 2009-06-24 Thomas Vander Stichele <thomas at apestaart dot org> 2 9 -
trunk/moap/test/test_vcs_svn.py
r366 r403 8 8 import tempfile 9 9 10 from moap.util import log 10 11 from moap.vcs import svn 11 12 … … 268 269 def assertBackupRestore(self): 269 270 # do a backup and restore and check 270 fd, archive = tempfile.mkstemp(suffix=' tar.gz', prefix="moap.test.")271 fd, archive = tempfile.mkstemp(suffix='.tar.gz', prefix="moap.test.") 271 272 os.close(fd) 272 273 273 274 # backup does a test restore 275 log.debug('test', 'backing up archive %s', archive) 274 276 self.vcs.backup(archive) 275 277 -
trunk/moap/vcs/vcs.py
r366 r403 350 350 """ 351 351 mode = 'w:' 352 suffix = '.tar' 352 353 if archive.endswith('.gz'): 353 354 mode = 'w:gz' 355 suffix = '.tar.gz' 354 356 if archive.endswith('.bz2'): 355 357 mode = 'w:bw2' 356 358 suffix = '.tar.bz2' 359 360 # P2.4 361 # Pre-2.5, tarfile has a bug, creating hardlinks for temporary files 362 # if the temporary files get deleted right after adding. 363 # See http://mail.python.org/pipermail/python-bugs-list/2005-October/030793.html 364 # the workaround chosen is to keep the temporary files until after 365 # closing 357 366 tar = tarfile.TarFile.open(name=archive, mode=mode) 358 367 359 368 # store the diff 360 (fd, path) = tempfile.mkstemp(prefix='moap.backup.diff.')369 (fd, diffpath) = tempfile.mkstemp(prefix='moap.backup.diff.') 361 370 diff = self.diff('') 362 371 if diff: 363 372 os.write(fd, diff + '\n') 364 373 os.close(fd) 365 tar.add(path, arcname='diff') 366 os.unlink(path) 374 tar.add(diffpath, arcname='diff') 367 375 368 376 # store the checkout commands 369 (fd, path) = tempfile.mkstemp(prefix='moap.backup.checkout.')377 (fd, checkoutpath) = tempfile.mkstemp(prefix='moap.backup.checkout.') 370 378 os.write(fd, "#!/bin/sh\n" + self.getCheckoutCommands()) 371 379 os.close(fd) 372 os.chmod(path, 0755) 373 tar.add(path, arcname='checkout.sh') 374 os.unlink(path) 380 os.chmod(checkoutpath, 0755) 381 tar.add(checkoutpath, arcname='checkout.sh') 375 382 376 383 # store the unignored files … … 384 391 tar.add(abspath, 'unignored/' + rel) 385 392 tar.close() 393 os.unlink(diffpath) 394 os.unlink(checkoutpath) 386 395 387 396 # now verify the backup 388 restoreDir = tempfile.mkdtemp(prefix="moap.test. ")397 restoreDir = tempfile.mkdtemp(prefix="moap.test.restore.") 389 398 os.rmdir(restoreDir) 390 399 self.restore(archive, restoreDir) … … 414 423 oldPath = os.getcwd() 415 424 425 # P2.3: tarfile.extractall only exists since 2.5 416 426 tar = tarfile.TarFile.open(name=archive) 417 tar.extractall(path) 427 try: 428 tar.extractall(path) 429 except AttributeError: 430 # do it the shell way 431 self.debug('Restoring by using tar directly') 432 os.system('mkdir -p %s' % path) 433 if archive.endswith('.gz'): 434 os.system('cd %s; tar xzf %s' % (path, archive)) 435 elif archive.endswith('.bz2'): 436 os.system('cd %s; tar xjf %s' % (path, archive)) 437 else: 438 raise AssertionError("Don't know how to handle %s" % archive) 418 439 419 440 # start with the checkout
Note: See TracChangeset
for help on using the changeset viewer.
