I ran pungi once and created a fedora iso. When I ran it again with the
same config file, and forgot to erase the previous work directory
files, pungi shows a traceback telling me that some file already exists.
I have two proposals for this situation.
1. create a timestamp directory inside the working directory for each
pungi run. The problem with this approach is that the use is left with
a bunch of directories that are named after whatever time.time() spit
out (not very pretty). But alas it does away with the ugly traceback
message.
The diff for the first solution:
--- pungi-0.3.0 2007-04-02 23:17:25.000000000 +0200
+++ pungi-0.3.1-JG 2007-04-13 14:27:22.000000000 +0200
@@ -18,6 +18,7 @@
import yum
from ConfigParser import SafeConfigParser
+from time import time
def main():
# Set some default variables, can be overrided in config file
@@ -76,7 +77,8 @@
if not opts.destdir == "*CONFFILE*":
config.set('default', 'destdir', opts.destdir)
-
+ config.set('default', 'destdir',
os.path.join(config.get('default','destdir'),
+ str(int(time()))))
destdir = config.get('default', 'destdir')
if not os.path.exists(destdir):
2. Just tell the user to erase the things he/she has in the directory.
The diff for the second solution:
--- pungi-0.3.0 2007-04-13 15:03:26.000000000 +0200
+++ pungi-0.3.1-JG 2007-04-13 15:02:22.000000000 +0200
@@ -18,6 +18,7 @@
import yum
from ConfigParser import SafeConfigParser
+from os.path import isdir
def main():
# Set some default variables, can be overrided in config file
@@ -77,7 +78,7 @@
if not opts.destdir == "*CONFFILE*":
config.set('default', 'destdir', opts.destdir)
- destdir = config.get('default', 'destdir')
+ destdir = check_destdir(config.get('default', 'destdir'))
if not os.path.exists(destdir):
try:
@@ -180,4 +181,10 @@
manifestfile.close()
return pkglist
+ def check_destdir(workpath):
+ if isdir(workpath) and len(os.listdir(workpath)) > 0:
+ print >> sys.stderr, "Please erase all items from the
directory %s before continuing." % workpath
+ exit(1)
+ return workpath
+
main()