changes
This commit is contained in:
parent
bf2cc0886b
commit
71c9178747
6 changed files with 86 additions and 14 deletions
|
@ -4,6 +4,7 @@
|
|||
"download_link": "https://cdimage.ubuntu.com/ubuntu-base/noble/daily/current/noble-base-amd64.tar.gz",
|
||||
"download_name": "noble-base-amd64.tar.gz",
|
||||
"repositories": [],
|
||||
"replace_repositories": "False",
|
||||
"packages": "grub-pc linux-image-generic ubuntu-desktop",
|
||||
"scripts": [
|
||||
"configs/scripts/install.sh",
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"download_link": "https://cdimage.ubuntu.com/ubuntu-base/noble/daily/current/noble-base-amd64.tar.gz",
|
||||
"download_name": "noble-base-amd64.tar.gz",
|
||||
"repositories": [],
|
||||
"replace_repositories": "False",
|
||||
"packages": "grub-pc linux-image-generic kubuntu-desktop",
|
||||
"scripts": [
|
||||
"configs/scripts/install.sh",
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"download_link": "https://cdimage.ubuntu.com/ubuntu-base/noble/daily/current/noble-base-amd64.tar.gz",
|
||||
"download_name": "noble-base-amd64.tar.gz",
|
||||
"repositories": [],
|
||||
"replace_repositories": "False",
|
||||
"packages": "grub-pc linux-image-generic lubuntu-desktop",
|
||||
"scripts": [
|
||||
"configs/scripts/install.sh",
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"download_link": "https://cdimage.ubuntu.com/ubuntu-base/noble/daily/current/noble-base-amd64.tar.gz",
|
||||
"download_name": "noble-base-amd64.tar.gz",
|
||||
"repositories": [],
|
||||
"replace_repositories": "False",
|
||||
"packages": "grub-pc linux-image-generic ubuntu-mate-desktop",
|
||||
"scripts": [
|
||||
"configs/scripts/install.sh",
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"download_link": "https://cdimage.ubuntu.com/ubuntu-base/noble/daily/current/noble-base-amd64.tar.gz",
|
||||
"download_name": "noble-base-amd64.tar.gz",
|
||||
"repositories": [],
|
||||
"replace_repositories": "False",
|
||||
"packages": "nginx grub-pc linux-image-generic",
|
||||
"scripts": [
|
||||
"configs/scripts/install.sh",
|
||||
|
|
95
main.py
95
main.py
|
@ -58,7 +58,7 @@ def rootfs_creator(filename):
|
|||
|
||||
|
||||
# packaging rootfs
|
||||
def rootfs_package(identifier, scripts):
|
||||
def rootfs_package(identifier, scripts, extra_files):
|
||||
infile = f"{identifier}.tar.gz"
|
||||
outfile = f"{identifier}.iso"
|
||||
|
||||
|
@ -95,6 +95,9 @@ def rootfs_package(identifier, scripts):
|
|||
command(f"echo './{result}' | sudo tee -a '{chroot}/root/.profile'")
|
||||
command(f"echo './{result}' | sudo tee -a '{chroot}/root/.bashrc'")
|
||||
|
||||
for extra_file in extra_files:
|
||||
command(f"sudo cp '{extra_file}' '{chroot}'")
|
||||
|
||||
command(f"echo 'umount -R /mnt' | sudo tee -a '{chroot}/root/.profile'")
|
||||
command(f"echo 'umount -R /mnt' | sudo tee -a '{chroot}/root/.bashrc'")
|
||||
command(f"echo 'reboot' | sudo tee -a '{chroot}/root/.profile'")
|
||||
|
@ -109,31 +112,83 @@ def rootfs_package(identifier, scripts):
|
|||
|
||||
|
||||
# distro specific
|
||||
def ubuntu_rootfs_prepare(
|
||||
download_link, download_name, packages, identifier, scripts, package_manager
|
||||
def download_rootfs_prepare(
|
||||
download_link,
|
||||
download_name,
|
||||
packages,
|
||||
repositories,
|
||||
replace_repositories,
|
||||
keyrings,
|
||||
identifier,
|
||||
scripts,
|
||||
package_manager,
|
||||
extra_files,
|
||||
):
|
||||
rootfs_downloader(download_link, download_name)
|
||||
generic_rootfs_prepare(packages, identifier, scripts, package_manager)
|
||||
apt_rootfs_prepare(
|
||||
repositories, replace_repositories, packages, identifier, scripts, extra_files
|
||||
)
|
||||
|
||||
|
||||
def debian_rootfs_prepare(
|
||||
download_link, download_name, packages, identifier, scripts, package_manager
|
||||
def debootstrap_rootfs_prepare(
|
||||
download_link,
|
||||
download_name,
|
||||
packages,
|
||||
repositories,
|
||||
replace_repositories,
|
||||
keyrings,
|
||||
identifier,
|
||||
scripts,
|
||||
package_manager,
|
||||
extra_files,
|
||||
):
|
||||
command(f"sudo debootstrap --arch amd64 {download_name} {chroot} {download_link}")
|
||||
generic_rootfs_prepare(packages, identifier, scripts, package_manager)
|
||||
apt_rootfs_prepare(
|
||||
repositories,
|
||||
replace_repositories,
|
||||
keyrings,
|
||||
packages,
|
||||
identifier,
|
||||
scripts,
|
||||
extra_files,
|
||||
)
|
||||
|
||||
|
||||
def generic_rootfs_prepare(packages, identifier, scripts, package_manager):
|
||||
def apt_rootfs_prepare(
|
||||
repositories,
|
||||
replace_repositories,
|
||||
keyrings,
|
||||
packages,
|
||||
identifier,
|
||||
scripts,
|
||||
extra_files,
|
||||
):
|
||||
prepare_chroot()
|
||||
|
||||
if replace_repositories:
|
||||
overwritten = False
|
||||
else:
|
||||
overwritten = True
|
||||
|
||||
for repository in repositories:
|
||||
if overwritten:
|
||||
do_chroot_command(f"echo '{repository}' >>/etc/apt/sources.list")
|
||||
else:
|
||||
do_chroot_command(f"echo '{repository}' >/etc/apt/sources.list")
|
||||
overwritten + True
|
||||
|
||||
for download, name in keyrings:
|
||||
do_chroot_command(f"wget {download}")
|
||||
do_chroot_command(f"dpkg -i {name}")
|
||||
do_chroot_command(f"rm {name}")
|
||||
|
||||
do_chroot_command("apt update -y")
|
||||
do_chroot_command("apt full-upgrade -y")
|
||||
do_chroot_command(
|
||||
f"DEBIAN_FRONTEND=noninteractive {package_manager} install -y {packages}"
|
||||
)
|
||||
do_chroot_command(f"DEBIAN_FRONTEND=noninteractive apt install -y {packages}")
|
||||
do_chroot_command("echo 'localmachine' > /etc/hostname")
|
||||
close_chroot()
|
||||
rootfs_creator(f"{identifier}.tar.gz")
|
||||
rootfs_package(f"{output}{identifier}", scripts)
|
||||
rootfs_package(f"{output}{identifier}", scripts, extra_files)
|
||||
|
||||
|
||||
# main
|
||||
|
@ -182,28 +237,40 @@ def main():
|
|||
download_link = data["download_link"]
|
||||
download_name = data["download_name"]
|
||||
packages = data["packages"]
|
||||
repositories = data["repositories"]
|
||||
replace_repositories = bool(data["replace_repositories"])
|
||||
keyrings = data["keyrings"]
|
||||
identifier = data["identifier"]
|
||||
scripts = data["scripts"]
|
||||
package_manager = data["package_manager"]
|
||||
extra_files = data["extra_files"]
|
||||
|
||||
match rootfs_type:
|
||||
case "download":
|
||||
ubuntu_rootfs_prepare(
|
||||
download_rootfs_prepare(
|
||||
download_link,
|
||||
download_name,
|
||||
packages,
|
||||
repositories,
|
||||
replace_repositories,
|
||||
keyrings,
|
||||
identifier,
|
||||
scripts,
|
||||
package_manager,
|
||||
extra_files,
|
||||
)
|
||||
case "debootstrap":
|
||||
debian_rootfs_prepare(
|
||||
debootstrap_rootfs_prepare(
|
||||
download_link,
|
||||
download_name,
|
||||
packages,
|
||||
repositories,
|
||||
replace_repositories,
|
||||
keyrings,
|
||||
identifier,
|
||||
scripts,
|
||||
package_manager,
|
||||
extra_files,
|
||||
)
|
||||
|
||||
close_chroot()
|
||||
|
|
Loading…
Reference in a new issue