mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-16 16:25:23 +01:00
Move to /usr prefix.
- This is much more standard and replaces /image in sysa and is the standard in sysc (avoids many issues). - GCC needs to have a file created for some unknown reason. - Checksums updated.
This commit is contained in:
parent
ddd4f1bc81
commit
b93a931a53
104 changed files with 659 additions and 722 deletions
103
sysa.py
103
sysa.py
|
|
@ -35,106 +35,8 @@ class SysA(SysGeneral):
|
|||
|
||||
self.prepare()
|
||||
|
||||
<<<<<<< HEAD
|
||||
def __del__(self):
|
||||
if not self.preserve_tmp:
|
||||
print("Unmounting tmpfs from %s" % (self.tmp_dir))
|
||||
umount(self.tmp_dir)
|
||||
os.rmdir(self.tmp_dir)
|
||||
|
||||
def check_file(self, file_name):
|
||||
"""Check hash of downloaded source file."""
|
||||
checksum_store = os.path.join(self.git_dir, 'SHA256SUMS.sources')
|
||||
with open(checksum_store) as checksum_file:
|
||||
hashes = checksum_file.read().splitlines()
|
||||
for hash_line in hashes:
|
||||
if os.path.basename(file_name) in hash_line:
|
||||
# Hash is in store, check it
|
||||
expected_hash = hash_line.split()[0]
|
||||
|
||||
with open(file_name, "rb") as downloaded_file:
|
||||
downloaded_content = downloaded_file.read() # read entire file as bytes
|
||||
readable_hash = hashlib.sha256(downloaded_content).hexdigest()
|
||||
if expected_hash == readable_hash:
|
||||
return
|
||||
raise Exception("Checksum mismatch")
|
||||
|
||||
raise Exception("File checksum is not yet recorded")
|
||||
|
||||
def download_file(self, url, file_name=None):
|
||||
"""
|
||||
Download a single source archive.
|
||||
"""
|
||||
cache_dir = os.path.join(self.git_dir, 'sources')
|
||||
|
||||
# Automatically determine file name based on URL.
|
||||
if file_name is None:
|
||||
file_name = os.path.basename(url)
|
||||
abs_file_name = os.path.join(cache_dir, file_name)
|
||||
|
||||
# Create a cache directory for downloaded sources
|
||||
if not os.path.isdir(cache_dir):
|
||||
os.mkdir(cache_dir)
|
||||
|
||||
# Actually download the file
|
||||
if not os.path.isfile(abs_file_name):
|
||||
print("Downloading: %s" % (file_name))
|
||||
response = requests.get(url, allow_redirects=True, stream=True)
|
||||
if response.status_code == 200:
|
||||
with open(abs_file_name, 'wb') as target_file:
|
||||
target_file.write(response.raw.read())
|
||||
else:
|
||||
raise Exception("Download failed.")
|
||||
|
||||
# Check SHA256 hash
|
||||
self.check_file(abs_file_name)
|
||||
return abs_file_name
|
||||
|
||||
def get_file(self, url, output=None):
|
||||
"""
|
||||
Download and prepare source packages
|
||||
|
||||
url can be either:
|
||||
1. a single URL
|
||||
2. list of URLs to download. In this case the first URL is the primary URL
|
||||
from which we derive the name of package directory
|
||||
output can be used to override file name of the downloaded file(s).
|
||||
"""
|
||||
# Single URL
|
||||
if isinstance(url, str):
|
||||
assert output is None or isinstance(output, str)
|
||||
file_name = url if output is None else output
|
||||
urls = [url]
|
||||
outputs = [output]
|
||||
# Multiple URLs
|
||||
elif isinstance(url, list):
|
||||
assert output is None or len(output) == len(url)
|
||||
file_name = url[0] if output is None else output[0]
|
||||
urls = url
|
||||
outputs = output if output is not None else [None] * len(url)
|
||||
else:
|
||||
raise TypeError("url must be either a string or a list of strings")
|
||||
|
||||
# Determine installation directory
|
||||
target_name = get_target(file_name)
|
||||
target_src_dir = os.path.join(self.after_dir, target_name, 'src')
|
||||
|
||||
# Install base files
|
||||
src_tree = os.path.join(self.sysa_dir, target_name)
|
||||
copytree(src_tree, self.after_dir)
|
||||
if not os.path.isdir(target_src_dir):
|
||||
os.mkdir(target_src_dir)
|
||||
|
||||
for i, _ in enumerate(urls):
|
||||
# Download files into cache directory
|
||||
tarball = self.download_file(urls[i], outputs[i])
|
||||
|
||||
# Install sources into target directory
|
||||
shutil.copy2(tarball, target_src_dir)
|
||||
=======
|
||||
if not chroot:
|
||||
self.make_initramfs()
|
||||
>>>>>>> 6252572 (Add sysb and sysc scaffolding.)
|
||||
|
||||
def prepare(self):
|
||||
"""
|
||||
|
|
@ -370,8 +272,9 @@ class SysA(SysGeneral):
|
|||
self.get_file("https://mirrors.kernel.org/gnu/autoconf/autoconf-2.64.tar.bz2")
|
||||
|
||||
# gcc 4.0.4
|
||||
self.get_file("https://mirrors.kernel.org/gnu/gcc/gcc-4.0.4/gcc-core-4.0.4.tar.bz2",
|
||||
output="gcc-4.0.4.tar.bz2")
|
||||
self.get_file(["https://mirrors.kernel.org/gnu/gcc/gcc-4.0.4/gcc-core-4.0.4.tar.bz2",
|
||||
"https://mirrors.kernel.org/gnu/automake/automake-1.16.3.tar.gz"],
|
||||
output=["gcc-4.0.4.tar.bz2", "automake-1.16.3.tar.gz"])
|
||||
|
||||
# linux api headers 5.10.41
|
||||
self.get_file("https://mirrors.kernel.org/pub/linux/kernel/v5.x/linux-5.10.41.tar.gz",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue