diff --git a/build-buildroot b/build-buildroot index 9cd16b2..f2f1375 100755 --- a/build-buildroot +++ b/build-buildroot @@ -84,7 +84,7 @@ usually extra Buildroot targets. elif self.env['arch'] == 'aarch64': defconfig = 'qemu_aarch64_virt_defconfig' br2_external_dirs = [] - for package_dir in os.listdir(self.env['packages_dir']): + for package_dir in sorted(os.listdir(self.env['packages_dir'])): package_dir_abs = os.path.join(self.env['packages_dir'], package_dir) if os.path.isdir(package_dir_abs): br2_external_dirs.append(self._path_relative_to_buildroot(package_dir_abs)) diff --git a/common.py b/common.py index 2df3d29..609b2c2 100644 --- a/common.py +++ b/common.py @@ -866,7 +866,10 @@ lunch aosp_{}-eng List checkpoint directory, oldest first. ''' prefix_re = re.compile(self.env['gem5_cpt_prefix']) - files = list(filter(lambda x: os.path.isdir(os.path.join(self.env['m5out_dir'], x)) and prefix_re.search(x), os.listdir(self.env['m5out_dir']))) + files = list(filter( + lambda x: os.path.isdir(os.path.join(self.env['m5out_dir'], x)) + and prefix_re.search(x), os.listdir(self.env['m5out_dir']) + )) files.sort(key=lambda x: os.path.getmtime(os.path.join(self.env['m5out_dir'], x))) return files diff --git a/release-zip b/release-zip index 5139b40..2bb2477 100755 --- a/release-zip +++ b/release-zip @@ -20,9 +20,9 @@ https://github.com/cirosantilli/linux-kernel-module-cheat#release-zip def timed_main(self): self.zip_files.append(self.env['qcow2_file']) self.zip_files.append(self.env['linux_image']) - for root, dirs, files in os.walk(self.env['baremetal_build_dir']): - for file in files: - path = os.path.join(root, file) + for root, dirnames, filenames in os.walk(self.env['baremetal_build_dir']): + for filename in sorted(filenames): + path = os.path.join(root, filename) if os.path.splitext(path)[1] == self.env['baremetal_build_ext']: self.zip_files.append(path) diff --git a/shell_helpers.py b/shell_helpers.py index 58790ba..a893112 100644 --- a/shell_helpers.py +++ b/shell_helpers.py @@ -122,7 +122,7 @@ class ShellHelpers: def copy_dir_if_update_non_recursive(self, srcdir, destdir, filter_ext=None): # TODO print rsync equivalent. os.makedirs(destdir, exist_ok=True) - for basename in os.listdir(srcdir): + for basename in sorted(os.listdir(srcdir)): src = os.path.join(srcdir, basename) if os.path.isfile(src): noext, ext = os.path.splitext(basename) @@ -138,6 +138,7 @@ class ShellHelpers: srcdir_abs = os.path.abspath(srcdir) srcdir_abs_len = len(srcdir_abs) for path, dirnames, filenames in os.walk(srcdir_abs): + dirnames.sort() for dirname in dirnames: dirpath = os.path.join(path, dirname) dirpath_relative_root = dirpath[srcdir_abs_len + 1:] diff --git a/test-baremetal b/test-baremetal index ad5a467..bfb19fd 100755 --- a/test-baremetal +++ b/test-baremetal @@ -26,14 +26,15 @@ If given, run only the given tests. Otherwise, run all tests. if self.env['tests'] == []: baremetal_source_exts = (self.env['c_ext'], self.env['asm_ext']) paths = [] - for f in os.listdir(self.env['baremetal_source_dir']): + for f in sorted(os.listdir(self.env['baremetal_source_dir'])): path = os.path.join(self.env['baremetal_source_dir'], f) if os.path.isfile(path) and os.path.splitext(path)[1] in baremetal_source_exts: paths.append(path) - for root, dirs, files in os.walk(self.env['baremetal_source_arch_dir'], topdown=True): - dirs[:] = [d for d in dirs if d != 'interactive'] - for file in files: - path = os.path.join(root, file) + for root, dirnames, filenames in os.walk(self.env['baremetal_source_arch_dir'], topdown=True): + dirnames[:] = [d for d in dirnames if d != 'interactive'] + dirnames.sort() + for filename in filenames: + path = os.path.join(root, filename) if os.path.splitext(path)[1] in baremetal_source_exts: paths.append(path) sources = [] diff --git a/test-gdb b/test-gdb index 1590abf..0932044 100755 --- a/test-gdb +++ b/test-gdb @@ -27,13 +27,13 @@ found by searching for the Python test files. if self.env['arch'] in self.env['crosstool_ng_supported_archs']: if self.env['tests'] == []: test_scripts_noext = [] - for f in os.listdir(self.env['baremetal_source_dir']): - base, ext = os.path.splitext(f) + for filename in sorted(os.listdir(self.env['baremetal_source_dir'])): + base, ext = os.path.splitext(filename) if ext == '.py': test_scripts_noext.append(base) - for root, dirs, files in os.walk(os.path.join(self.env['baremetal_source_dir'], 'arch', self.env['arch'])): - for f in files: - base, ext = os.path.splitext(f) + for root, dirnames, filenames in os.walk(os.path.join(self.env['baremetal_source_dir'], 'arch', self.env['arch'])): + for filename in filenames: + base, ext = os.path.splitext(filename) if ext == '.py': full_path = os.path.join(root, base) relpath = os.path.relpath(full_path, self.env['baremetal_source_dir'])