Download source files using a source manifest

This commit is contained in:
Dor Askayo 2023-01-13 15:55:39 +02:00
parent 425beee8dd
commit a1c8c0312c
3 changed files with 29 additions and 11 deletions

View File

@ -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."""

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""System A"""
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
# SPDX-FileCopyrightText: 2022-2023 Dor Askayo <dor.askayo@gmail.com>
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2021 Melg Eight <public.melg8@gmail.com>
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
@ -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'))

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""System C"""
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
# SPDX-FileCopyrightText: 2022-2023 Dor Askayo <dor.askayo@gmail.com>
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
@ -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