diff --git a/confluent_server/confluent/osimage.py b/confluent_server/confluent/osimage.py index 68fc22b7..8384913e 100644 --- a/confluent_server/confluent/osimage.py +++ b/confluent_server/confluent/osimage.py @@ -726,7 +726,8 @@ def get_hashes(dirname): fullname = os.path.join(dname, fname) currhash = hashlib.sha512() subname = fullname.replace(dirname + '/', '') - hashmap[subname] = get_hash(fullname) + if os.path.isfile(fullname): + hashmap[subname] = get_hash(fullname) return hashmap diff --git a/imgutil/imgutil b/imgutil/imgutil index 7fa9f319..427fd457 100644 --- a/imgutil/imgutil +++ b/imgutil/imgutil @@ -354,7 +354,8 @@ def encrypt_image(plainfile, cryptfile, keyfile): def create_yumconf(sourcedir, addrepos): - repodir = tempfile.mkdtemp(prefix='genimage-yumrepos.d-') + mkdirp('/run/imgutil/') + repodir = tempfile.mkdtemp(prefix='genimage-yumrepos.d-', dir='/run/imgutil/') yumconf = open(os.path.join(repodir, 'repos.repo'), 'w+') if '/' not in sourcedir: sourcedir = os.path.join('/var/lib/confluent/distributions', sourcedir) @@ -807,18 +808,24 @@ def fancy_chroot(args, installroot): imgname = os.path.basename(installroot) oshandler = fingerprint_host(args, args.scratchdir) if oshandler: - with open(os.path.join(installroot, 'etc/confluentimg.buildinfo')) as binfo: - for line in binfo.readlines(): - if '=' in line: - k, v = line.split('=', 1) - if k == 'BUILDSRC': - dst = os.path.join(installroot, 'run/confluentdistro') - dst = os.path.abspath(dst) - os.makedirs(dst) - _mount(v.strip(), dst, flags=MS_BIND|MS_RDONLY) - break - else: - oshandler = None + try: + with open(os.path.join(installroot, 'etc/confluentimg.buildinfo')) as binfo: + for line in binfo.readlines(): + if '=' in line: + k, v = line.split('=', 1) + if k == 'BUILDSRC': + dst = os.path.join(installroot, 'run/confluentdistro') + dst = os.path.abspath(dst) + os.makedirs(dst) + try: + _mount(v.strip(), dst, flags=MS_BIND|MS_RDONLY) + except Exception: + oshandler = None + break + else: + oshandler = None + except FileNotFoundError: + oshandler = None sourceresolv = '/etc/resolv.conf' if os.path.islink(sourceresolv): sourceresolv = os.readlink(sourceresolv)