[Rpm-metadata] [PATCH] chdir("/") if $PWD does not exist. BZ 1001629

Zdenek Pavlas zpavlas at redhat.com
Tue Aug 27 13:07:42 UTC 2013


---
 genpkgmetadata.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/genpkgmetadata.py b/genpkgmetadata.py
index 3612890..56ba249 100755
--- a/genpkgmetadata.py
+++ b/genpkgmetadata.py
@@ -24,6 +24,7 @@ import sys
 import re
 from optparse import OptionParser,SUPPRESS_HELP
 import time
+import errno
 
 import createrepo
 from createrepo import MDError
@@ -244,6 +245,12 @@ class MDCallBack(object):
 
 def main(args):
     """createrepo from cli main flow"""
+    try:
+        os.getcwd()
+    except OSError:
+        if e.errno != errno.ENOENT: raise
+        print ('No getcwd() access in current directory, moving to /')
+        os.chdir("/")
     start_st = time.time()
     conf = createrepo.MetaDataConfig()
     conf = parse_args(args, conf)
-- 
1.7.11.7



More information about the Rpm-metadata mailing list