From 9919c1523f8270cdf702c9132691b07da5ccc339 Mon Sep 17 00:00:00 2001 From: Tudor Marcu Date: Wed, 31 Aug 2016 15:56:05 -0700 Subject: [PATCH] Use raw bytes to read filenames We cannot be sure of the encoding used for certain filenames or the locale on a specific system, so use raw bytes and don't worry about the encoding of the filenames. Signed-off-by: Tudor Marcu --- bundle-chroot-builder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundle-chroot-builder.py b/bundle-chroot-builder.py index b9d4111..b1cd69e 100755 --- a/bundle-chroot-builder.py +++ b/bundle-chroot-builder.py @@ -321,14 +321,14 @@ def create_chroots(args, state_dir, bundles, yum_conf): # real package's filename I'm using it instead of recursing through # temporary per bundle folders package_name = map_file[map_file.find(" * ") + 3:-len(".src.rpm")] - with open(out_dir + "/" + map_file, "r") as file: + with open(out_dir + "/" + map_file, "rb") as file: path_list = file.readlines() if package_name not in package_mapping: package_mapping[package_name] = set() for path in path_list: package_mapping[package_name].add(path) for package_name, paths in package_mapping.items(): - with open(out_dir + "/files-{}".format(package_name), "w") as file: + with open(out_dir + "/files-{}".format(package_name), "wb") as file: file.writelines(sorted(paths)) for map_file in map_files: os.unlink(out_dir + "/" + map_file)