diff --git a/lib/generator.py b/lib/generator.py index 54e3859..1aec17f 100755 --- a/lib/generator.py +++ b/lib/generator.py @@ -32,6 +32,7 @@ class Generator(): self.tmpdir = tmpdir self.tmp_dir = tmpdir.path self.external_dir = os.path.join(self.tmp_dir, 'external') + self.source_manifest = self.get_source_manifest(not self.external_sources) def prepare(self, using_kernel=False, kernel_bootstrap=False, target_size=0): """ @@ -100,8 +101,7 @@ class Generator(): def steps(self): """Copy in steps.""" - source_manifest = self.get_source_manifest(not self.external_sources) - self.get_packages(source_manifest) + self.get_packages() shutil.copytree(os.path.join(self.git_dir, 'steps'), os.path.join(self.tmp_dir, 'steps')) @@ -155,12 +155,10 @@ class Generator(): """Copy in distfiles""" def copy_no_network_distfiles(out): # Note that "no disk" implies "no network" for kernel bootstrap mode - pre_src_path = os.path.join(self.git_dir, 'steps', 'pre-network-sources') - with open(pre_src_path, 'r', encoding="utf-8") as source_list: - for file in source_list.readlines(): - file = file.strip() - shutil.copy2(os.path.join(self.distfiles_dir, file), - os.path.join(out, file)) + for file in self.source_manifest: + file = file[3].strip() + shutil.copy2(os.path.join(self.distfiles_dir, file), + os.path.join(out, file)) early_distfile_dir = os.path.join(self.tmp_dir, 'external', 'distfiles') main_distfile_dir = os.path.join(self.external_dir, 'distfiles') @@ -298,11 +296,9 @@ this script the next time") raise requests.HTTPError("Download failed.") return abs_file_name - def get_packages(self, source_manifest): + def get_packages(self): """Prepare remaining sources""" - for line in source_manifest.split("\n"): - line = line.strip().split(" ") - + for line in self.source_manifest: path = self.download_file(line[2], line[1], line[3]) self.check_file(path, line[0]) @@ -311,7 +307,7 @@ this script the next time") """ Generate a source manifest for the system. """ - manifest_lines = [] + entries = [] directory = os.path.relpath(cls.distfiles_dir, cls.git_dir) # Find all source files @@ -329,20 +325,20 @@ this script the next time") if os.path.exists(sourcef): # Read sources from the source file with open(sourcef, "r", encoding="utf_8") as sources: - for line in sources.readlines(): - line = line.strip().split(" ") + for source in sources.readlines(): + source = source.strip().split(" ") - if len(line) > 2: - file_name = line[2] + if len(source) > 2: + file_name = source[2] else: # Automatically determine file name based on URL. - file_name = os.path.basename(line[0]) + file_name = os.path.basename(source[0]) - manifest_line = f"{line[1]} {directory} {line[0]} {file_name}" - if manifest_line not in manifest_lines: - manifest_lines.append(manifest_line) + entry = (source[1], directory, source[0], file_name) + if entry not in entries: + entries.append(entry) - return "\n".join(manifest_lines) + return entries stage0_arch_map = { "amd64": "AMD64", diff --git a/source_manifest.py b/source_manifest.py index 81a1ba9..a972538 100755 --- a/source_manifest.py +++ b/source_manifest.py @@ -13,7 +13,7 @@ from lib.generator import Generator def main(): """Generate a source manifest for a system""" - print(Generator.get_source_manifest()) + print('\n'.join(map(' '.join, Generator.get_source_manifest()))) if __name__ == "__main__": main() diff --git a/steps/pre-network-sources b/steps/pre-network-sources deleted file mode 100644 index 8b54d0d..0000000 --- a/steps/pre-network-sources +++ /dev/null @@ -1,86 +0,0 @@ -mes-0.25.tar.gz -nyacc-1.00.2.tar.gz -tcc-0.9.26.tar.gz -tcc-0.9.27.tar.bz2 -fiwix-1.4.0-lb3.tar.gz -lwext4-1.0.0-lb1.tar.gz -make-3.82.tar.bz2 -patch-2.5.9.tar.gz -gzip-1.2.4.tar.gz -tar-1.12.tar.gz -sed-4.0.9.tar.gz -bzip2-1.0.8.tar.gz -coreutils-5.0.tar.bz2 -heirloom-devtools-070527.tar.bz2 -bash-2.05b.tar.gz -flex-2.5.11.tar.gz -tcc-0.9.27.tar.bz2 -musl-1.1.24.tar.gz -tcc-0.9.27.tar.bz2 -musl-1.1.24.tar.gz -tcc-0.9.27.tar.bz2 -sed-4.0.9.tar.gz -bzip2-1.0.8.tar.gz -m4-1.4.7.tar.gz -flex-2.6.4.tar.gz -bison-3.4.1.tar.gz -bison-3.4.1.tar.gz -bison-3.4.1.tar.gz -grep-2.4.tar.gz -diffutils-2.7.tar.gz -coreutils-5.0.tar.bz2 -coreutils-6.10.tar.gz -gawk-3.0.4.tar.gz -perl-5.000.tar.gz -perl-5.003.tar.gz -perl5.004_05.tar.gz -perl5.005_03.tar.gz -perl-5.6.2.tar.gz -autoconf-2.52.tar.bz2 -automake-1.6.3.tar.bz2 -automake-1.6.3.tar.bz2 -autoconf-2.53.tar.bz2 -automake-1.7.tar.bz2 -autoconf-2.54.tar.bz2 -autoconf-2.55.tar.bz2 -automake-1.7.8.tar.bz2 -autoconf-2.57.tar.bz2 -autoconf-2.59.tar.bz2 -automake-1.8.5.tar.bz2 -help2man-1.36.4.tar.gz -autoconf-2.61.tar.bz2 -automake-1.9.6.tar.bz2 -automake-1.10.3.tar.bz2 -autoconf-2.64.tar.bz2 -automake-1.11.2.tar.bz2 -autoconf-2.69.tar.gz -libtool-2.2.4.tar.bz2 -automake-1.15.1.tar.gz -binutils-2.30.tar.bz2 -musl-1.1.24.tar.gz -tcc-0.9.27.tar.bz2 -gcc-core-4.0.4.tar.bz2 -automake-1.16.3.tar.gz -findutils-4.2.33.tar.gz -gnulib-8e128e.tar.gz -musl-1.2.4.tar.gz -gcc-core-4.0.4.tar.bz2 -automake-1.16.3.tar.gz -util-linux-2.19.1.tar.gz -e2fsprogs-1.45.7.tar.gz -CaseFolding.txt -DerivedAge.txt -DerivedCombiningClass.txt -DerivedCoreProperties.txt -NormalizationCorrections.txt -NormalizationTest.txt -UnicodeData.txt -v10.0.1.tar.gz -kbd-1.15.tar.gz -make-3.82.tar.bz2 -ed-1.4.tar.gz -bc-1.07.1.tar.gz -v2.0.22.tar.gz -linux-4.9.10.tar.gz -deblob-4.9 -curl-7.88.1.tar.bz2