Compare commits
9 Commits
68c6544df0
...
0b7cd62f73
Author | SHA1 | Date |
---|---|---|
fosslinux | 0b7cd62f73 | |
Andrius Štikonas | 13f8dabd89 | |
Dor Askayo | 9d1e5b64be | |
Dor Askayo | a1c8c0312c | |
Dor Askayo | 425beee8dd | |
Dor Askayo | 38e5dfe35b | |
Dor Askayo | 693d01dc1b | |
Dor Askayo | 808fc67cbd | |
Dor Askayo | ce2276583a |
|
@ -156,8 +156,8 @@ sysc
|
||||||
sysc is the (current) last 'system' of live-bootstrap. This is a continuation
|
sysc is the (current) last 'system' of live-bootstrap. This is a continuation
|
||||||
from sysb, executed through util-linux's ``switch_root`` command which moves
|
from sysb, executed through util-linux's ``switch_root`` command which moves
|
||||||
the entire rootfs without a reboot. Every package from here on out is compiled
|
the entire rootfs without a reboot. Every package from here on out is compiled
|
||||||
under this system, taking binaries from sysa. Chroot mode skips sysb, as it
|
under this system, taking binaries from sysa. Chroot and bubblewrap modes skip
|
||||||
is obviously irrelevant for a chroot.
|
sysb, as it is obviously irrelevant to them.
|
||||||
|
|
||||||
Python-less build
|
Python-less build
|
||||||
-----------------
|
-----------------
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
This file contains a few functions to be shared by all Sys* classes
|
This file contains a few functions to be shared by all Sys* classes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# 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>
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
@ -71,18 +71,15 @@ actual: {readable_hash}\n\
|
||||||
When in doubt, try deleting the file in question -- it will be downloaded again when running \
|
When in doubt, try deleting the file in question -- it will be downloaded again when running \
|
||||||
this script the next time")
|
this script the next time")
|
||||||
|
|
||||||
def download_file(self, url, file_name=None):
|
def download_file(self, url, directory, file_name):
|
||||||
"""
|
"""
|
||||||
Download a single source archive.
|
Download a single source archive.
|
||||||
"""
|
"""
|
||||||
# Automatically determine file name based on URL.
|
abs_file_name = os.path.join(directory, file_name)
|
||||||
if file_name is None:
|
|
||||||
file_name = os.path.basename(url)
|
|
||||||
abs_file_name = os.path.join(self.cache_dir, file_name)
|
|
||||||
|
|
||||||
# Create a cache directory for downloaded sources
|
# Create a directory for downloaded file
|
||||||
if not os.path.isdir(self.cache_dir):
|
if not os.path.isdir(directory):
|
||||||
os.mkdir(self.cache_dir)
|
os.mkdir(directory)
|
||||||
|
|
||||||
# Actually download the file
|
# Actually download the file
|
||||||
headers = {
|
headers = {
|
||||||
|
@ -99,22 +96,41 @@ 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(" ")
|
||||||
|
|
||||||
if len(line) > 2:
|
if len(line) > 2:
|
||||||
path = self.download_file(line[0], line[2])
|
file_name = line[2]
|
||||||
else:
|
else:
|
||||||
path = self.download_file(line[0])
|
# Automatically determine file name based on URL.
|
||||||
self.check_file(path, line[1])
|
file_name = os.path.basename(line[0])
|
||||||
|
|
||||||
|
manifest_lines.append(f"{line[1]} {directory} {line[0]} {file_name}")
|
||||||
|
|
||||||
|
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."""
|
||||||
|
|
|
@ -104,9 +104,10 @@ def main():
|
||||||
return count
|
return count
|
||||||
|
|
||||||
if check_types() > 1:
|
if check_types() > 1:
|
||||||
raise ValueError("No more than one of qemu, chroot, minikernel, bare metal may be used.")
|
raise ValueError("No more than one of qemu, chroot, bwrap, minikernel, bare metal "
|
||||||
|
"may be used.")
|
||||||
if check_types() == 0:
|
if check_types() == 0:
|
||||||
raise ValueError("One of qemu, chroot, minikernel or bare metal must be selected.")
|
raise ValueError("One of qemu, chroot, bwrap, minikernel or bare metal must be selected.")
|
||||||
|
|
||||||
if args.bare_metal:
|
if args.bare_metal:
|
||||||
args.no_create_config = True
|
args.no_create_config = True
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
A helper application used to get a list of source files required
|
||||||
|
for the bootstrapping process.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
# SPDX-FileCopyrightText: 2023 Dor Askayo <dor.askayo@gmail.com>
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from sysa import SysA
|
||||||
|
from sysc import SysC
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
parser.add_argument("-s", "--system",
|
||||||
|
help="Generate source manifest for the specified systems",
|
||||||
|
choices=["sysa", "sysc"],
|
||||||
|
nargs="+",
|
||||||
|
action="extend",
|
||||||
|
required=True)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if "sysa" in args.system:
|
||||||
|
print(SysA.get_source_manifest())
|
||||||
|
|
||||||
|
if "sysc" in args.system:
|
||||||
|
print(SysC.get_source_manifest())
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
17
sysa.py
17
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>
|
||||||
|
@ -14,26 +14,30 @@ import tarfile
|
||||||
from lib.sysgeneral import SysGeneral, stage0_arch_map
|
from lib.sysgeneral import SysGeneral, stage0_arch_map
|
||||||
|
|
||||||
# pylint: disable=consider-using-with
|
# pylint: disable=consider-using-with
|
||||||
|
# pylint: disable=too-many-instance-attributes
|
||||||
class SysA(SysGeneral):
|
class SysA(SysGeneral):
|
||||||
"""
|
"""
|
||||||
Class responsible for preparing sources for System A.
|
Class responsible for preparing sources for System A.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=too-many-instance-attributes,too-many-arguments
|
|
||||||
|
git_dir = os.path.dirname(os.path.join(__file__))
|
||||||
|
sys_dir = os.path.join(git_dir, 'sysa')
|
||||||
|
cache_dir = os.path.join(sys_dir, 'distfiles')
|
||||||
|
|
||||||
|
# pylint: disable=too-many-arguments
|
||||||
def __init__(self, arch, preserve_tmp, external_sources,
|
def __init__(self, arch, preserve_tmp, external_sources,
|
||||||
early_preseed, tmpdir, sysb_dir, sysc_dir):
|
early_preseed, tmpdir, sysb_dir, sysc_dir):
|
||||||
self.git_dir = os.path.dirname(os.path.join(__file__))
|
|
||||||
self.arch = arch
|
self.arch = arch
|
||||||
self.preserve_tmp = preserve_tmp
|
self.preserve_tmp = preserve_tmp
|
||||||
self.early_preseed = early_preseed
|
self.early_preseed = early_preseed
|
||||||
|
|
||||||
self.sys_dir = os.path.join(self.git_dir, 'sysa')
|
|
||||||
if tmpdir is None:
|
if tmpdir is None:
|
||||||
self.tmp_dir = os.path.join(self.git_dir, 'tmp')
|
self.tmp_dir = os.path.join(self.git_dir, 'tmp')
|
||||||
else:
|
else:
|
||||||
self.tmp_dir = os.path.join(tmpdir, 'sysa')
|
self.tmp_dir = os.path.join(tmpdir, 'sysa')
|
||||||
self.sysa_dir = os.path.join(self.tmp_dir, 'sysa')
|
self.sysa_dir = os.path.join(self.tmp_dir, 'sysa')
|
||||||
self.base_dir = self.sysa_dir
|
self.base_dir = self.sysa_dir
|
||||||
self.cache_dir = os.path.join(self.sys_dir, 'distfiles')
|
|
||||||
self.sysb_dir = sysb_dir
|
self.sysb_dir = sysb_dir
|
||||||
self.sysc_dir = sysc_dir
|
self.sysc_dir = sysc_dir
|
||||||
self.external_sources = external_sources
|
self.external_sources = external_sources
|
||||||
|
@ -74,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'))
|
||||||
|
|
7
sysb.py
7
sysb.py
|
@ -12,9 +12,10 @@ class SysB(SysGeneral):
|
||||||
"""
|
"""
|
||||||
Class responsible for preparing sources for System B.
|
Class responsible for preparing sources for System B.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
git_dir = os.path.dirname(os.path.join(__file__))
|
||||||
|
sys_dir = os.path.join(git_dir, 'sysb')
|
||||||
|
|
||||||
def __init__(self, arch, preserve_tmp):
|
def __init__(self, arch, preserve_tmp):
|
||||||
self.git_dir = os.path.dirname(os.path.join(__file__))
|
|
||||||
self.arch = arch
|
self.arch = arch
|
||||||
self.preserve_tmp = preserve_tmp
|
self.preserve_tmp = preserve_tmp
|
||||||
|
|
||||||
self.sys_dir = os.path.join(self.git_dir, 'sysb')
|
|
||||||
|
|
12
sysc.py
12
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>
|
||||||
|
|
||||||
|
@ -18,16 +18,16 @@ class SysC(SysGeneral):
|
||||||
Class responsible for preparing sources for System C.
|
Class responsible for preparing sources for System C.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
git_dir = os.path.dirname(os.path.join(__file__))
|
||||||
|
sys_dir = os.path.join(git_dir, 'sysc')
|
||||||
|
cache_dir = os.path.join(sys_dir, 'distfiles')
|
||||||
dev_name = None
|
dev_name = None
|
||||||
|
|
||||||
def __init__(self, arch, preserve_tmp, tmpdir, external_sources):
|
def __init__(self, arch, preserve_tmp, tmpdir, external_sources):
|
||||||
self.git_dir = os.path.dirname(os.path.join(__file__))
|
|
||||||
self.arch = arch
|
self.arch = arch
|
||||||
self.preserve_tmp = preserve_tmp
|
self.preserve_tmp = preserve_tmp
|
||||||
self.external_sources = external_sources
|
self.external_sources = external_sources
|
||||||
|
|
||||||
self.sys_dir = os.path.join(self.git_dir, 'sysc')
|
|
||||||
self.cache_dir = os.path.join(self.sys_dir, 'distfiles')
|
|
||||||
if tmpdir is None:
|
if tmpdir is None:
|
||||||
self.tmp_dir = os.path.join(self.sys_dir, 'tmp')
|
self.tmp_dir = os.path.join(self.sys_dir, 'tmp')
|
||||||
else:
|
else:
|
||||||
|
@ -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