################################################################################
-import psycopg2, sys
+import psycopg2, sys, fcntl, os
import apt_pkg
import time
from daklib import database
################################################################################
+
def update_db_to_zero(self):
# This function will attempt to update a pre-zero database schema to zero
print "Please make sure you have a database backup handy. If you don't, press Ctrl-C now!"
print ""
print "Continuing in five seconds ..."
- #time.sleep(5)
+ time.sleep(5)
print ""
print "Attempting to upgrade pre-zero database to zero"
dakdb = __import__("dakdb", globals(), locals(), ['update'+str(i+1)])
update_module = getattr(dakdb, "update"+str(i+1))
update_module.do_update(self)
- database_revision /+ 1
+ database_revision += 1
################################################################################
utils.warn("dak update-db takes no arguments.")
usage(exit_code=1)
+
self.update_db()
+ try:
+ lock_fd = os.open(Cnf["Dinstall::LockFile"], os.O_RDWR | os.O_CREAT)
+ fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ except IOError, e:
+ if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
+ utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.")
+
+
################################################################################
if __name__ == '__main__':