Download source files using a source manifest
This commit is contained in:
parent
425beee8dd
commit
a1c8c0312c
|
@ -96,14 +96,28 @@ this script the next time")
|
||||||
raise Exception("Download failed.")
|
raise Exception("Download failed.")
|
||||||
return abs_file_name
|
return abs_file_name
|
||||||
|
|
||||||
def get_packages(self):
|
def get_packages(self, source_manifest):
|
||||||
"""Prepare remaining sources"""
|
"""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
|
# Find all source files
|
||||||
for file in os.listdir(self.sys_dir):
|
for file in os.listdir(cls.sys_dir):
|
||||||
if os.path.isdir(os.path.join(self.sys_dir, file)):
|
if os.path.isdir(os.path.join(cls.sys_dir, file)):
|
||||||
sourcef = os.path.join(self.sys_dir, file, "sources")
|
sourcef = os.path.join(cls.sys_dir, file, "sources")
|
||||||
if os.path.exists(sourcef):
|
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:
|
with open(sourcef, "r", encoding="utf_8") as sources:
|
||||||
for line in sources.readlines():
|
for line in sources.readlines():
|
||||||
line = line.strip().split(" ")
|
line = line.strip().split(" ")
|
||||||
|
@ -114,8 +128,9 @@ this script the next time")
|
||||||
# Automatically determine file name based on URL.
|
# Automatically determine file name based on URL.
|
||||||
file_name = os.path.basename(line[0])
|
file_name = os.path.basename(line[0])
|
||||||
|
|
||||||
path = self.download_file(line[0], self.cache_dir, file_name)
|
manifest_lines.append(f"{line[1]} {directory} {line[0]} {file_name}")
|
||||||
self.check_file(path, line[1])
|
|
||||||
|
return "\n".join(manifest_lines)
|
||||||
|
|
||||||
def make_initramfs(self):
|
def make_initramfs(self):
|
||||||
"""Package binary bootstrap seeds and sources into initramfs."""
|
"""Package binary bootstrap seeds and sources into initramfs."""
|
||||||
|
|
5
sysa.py
5
sysa.py
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""System A"""
|
"""System A"""
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# 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 Andrius Štikonas <andrius@stikonas.eu>
|
||||||
# SPDX-FileCopyrightText: 2021 Melg Eight <public.melg8@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Melg Eight <public.melg8@gmail.com>
|
||||||
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
|
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
|
||||||
|
@ -78,7 +78,8 @@ class SysA(SysGeneral):
|
||||||
|
|
||||||
def sysa(self):
|
def sysa(self):
|
||||||
"""Copy in sysa files for sysa."""
|
"""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'),
|
shutil.copytree(self.sys_dir, os.path.join(self.tmp_dir, 'sysa'),
|
||||||
ignore=shutil.ignore_patterns('tmp'))
|
ignore=shutil.ignore_patterns('tmp'))
|
||||||
|
|
6
sysc.py
6
sysc.py
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""System C"""
|
"""System C"""
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# 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-22 fosslinux <fosslinux@aussies.space>
|
||||||
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
|
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
|
||||||
|
|
||||||
|
@ -70,7 +70,9 @@ class SysC(SysGeneral):
|
||||||
rootfs_dir = self.tmp_dir
|
rootfs_dir = self.tmp_dir
|
||||||
|
|
||||||
if self.external_sources:
|
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"))
|
copytree(self.cache_dir, os.path.join(rootfs_dir, "distfiles"))
|
||||||
|
|
||||||
# Unmount tmp/mnt if it was mounted
|
# Unmount tmp/mnt if it was mounted
|
||||||
|
|
Loading…
Reference in New Issue