1
0
mirror of https://github.com/gryf/boxpy.git synced 2025-12-18 13:00:17 +01:00

Don't clutter current directory with checksum files.

In case of Centos, there is a need to get the checksum file first to
figure out the correct image filename, during that process checksum file
was left alone in the current directory. Place it in the temp dir in the
first place and than remove after we know the right image filename.
This commit is contained in:
2022-02-08 20:38:59 +01:00
parent 0093e32b74
commit e63d83fc7f

6
box.py
View File

@@ -1012,12 +1012,13 @@ class CentosStream(Image):
self._img_url = self.URL % (version, arch, self._img_fname)
def _get_image_name(self, version, arch):
Run(['wget', self._checksum_url, '-q', '-O', self._checksum_file])
fname = os.path.join(self._tmp, self._checksum_file)
Run(['wget', self._checksum_url, '-q', '-O', fname])
pat = re.compile(self.IMG % (version, arch))
images = []
with open(self._checksum_file) as fobj:
with open(fname) as fobj:
for line in fobj.read().strip().split('\n'):
line = line.strip()
if line.startswith('#'):
@@ -1026,6 +1027,7 @@ class CentosStream(Image):
if match and match.groups():
images.append(match.groups()[0])
Run(['rm', fname])
images.reverse()
if images:
return images[0]