diff --git a/lib/sysgeneral.py b/lib/sysgeneral.py index fdbafd0..e1d2efa 100644 --- a/lib/sysgeneral.py +++ b/lib/sysgeneral.py @@ -96,14 +96,28 @@ this script the next time") raise Exception("Download failed.") return abs_file_name - def get_packages(self): + def get_packages(self, source_manifest): """Prepare remaining sources""" + for line in source_manifest.split("\n"): + line = line.strip().split(" ") + + path = self.download_file(line[2], line[1], line[3]) + self.check_file(path, line[0]) + + @classmethod + def get_source_manifest(cls): + """ + Generage a source manifest for the system. + """ + manifest_lines = [] + directory = os.path.relpath(cls.cache_dir, cls.git_dir) + # Find all source files - for file in os.listdir(self.sys_dir): - if os.path.isdir(os.path.join(self.sys_dir, file)): - sourcef = os.path.join(self.sys_dir, file, "sources") + for file in os.listdir(cls.sys_dir): + if os.path.isdir(os.path.join(cls.sys_dir, file)): + sourcef = os.path.join(cls.sys_dir, file, "sources") if os.path.exists(sourcef): - # Download sources in the source file + # Read sources from the source file with open(sourcef, "r", encoding="utf_8") as sources: for line in sources.readlines(): line = line.strip().split(" ") @@ -114,8 +128,9 @@ this script the next time") # Automatically determine file name based on URL. file_name = os.path.basename(line[0]) - path = self.download_file(line[0], self.cache_dir, file_name) - self.check_file(path, line[1]) + manifest_lines.append(f"{line[1]} {directory} {line[0]} {file_name}") + + return "\n".join(manifest_lines) def make_initramfs(self): """Package binary bootstrap seeds and sources into initramfs.""" diff --git a/sysa.py b/sysa.py index f6ec005..dd709c9 100755 --- a/sysa.py +++ b/sysa.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """System A""" # SPDX-License-Identifier: GPL-3.0-or-later -# SPDX-FileCopyrightText: 2022 Dor Askayo +# SPDX-FileCopyrightText: 2022-2023 Dor Askayo # SPDX-FileCopyrightText: 2021 Andrius Štikonas # SPDX-FileCopyrightText: 2021 Melg Eight # SPDX-FileCopyrightText: 2021-22 fosslinux @@ -78,7 +78,8 @@ class SysA(SysGeneral): def sysa(self): """Copy in sysa files for sysa.""" - self.get_packages() + source_manifest = self.get_source_manifest() + self.get_packages(source_manifest) shutil.copytree(self.sys_dir, os.path.join(self.tmp_dir, 'sysa'), ignore=shutil.ignore_patterns('tmp')) diff --git a/sysc.py b/sysc.py index b59b259..0851f25 100755 --- a/sysc.py +++ b/sysc.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """System C""" # SPDX-License-Identifier: GPL-3.0-or-later -# SPDX-FileCopyrightText: 2022 Dor Askayo +# SPDX-FileCopyrightText: 2022-2023 Dor Askayo # SPDX-FileCopyrightText: 2021-22 fosslinux # SPDX-FileCopyrightText: 2021 Andrius Štikonas @@ -70,7 +70,9 @@ class SysC(SysGeneral): rootfs_dir = self.tmp_dir if self.external_sources: - self.get_packages() + source_manifest = self.get_source_manifest() + self.get_packages(source_manifest) + copytree(self.cache_dir, os.path.join(rootfs_dir, "distfiles")) # Unmount tmp/mnt if it was mounted