#!/bin/bash

clear
echo "INSTALLING/UPDATING..."
sudo apt install -y live-build
echo "================="
echo "LIVE-BUILD SCRIPT"
echo "   VER. 251203   "
echo "================="
echo "NAME:"
read name
#echo "BASE DISTRO:" (DEBIAN/UBUNTU/MINT)
#read distro
echo "BASE RELEASE:"
read release
echo "PACKAGE LIST TO INSTALL:"
read pkgs
#echo "HOOKS"
#read hooks
mkdir lb; cd lb
mkdir $name; cd $name
sudo lb clean --all && rm -rf config cache local
#"--win32-loader" dropped with Debian 13 Trixie
lb config --apt-recommends true --backports true --system live --memtest memtest86+ --debian-installer-gui true --debian-installer live --bootappend-live "boot=live components quiet splash hostname=$name toram" -d $release --mode debian --parent-distribution $release --parent-debian-installer-distribution $release --archive-areas "main contrib non-free non-free-firmware" --linux-packages "linux-image linux-headers" true --uefi-secure-boot auto --security true --updates true -b iso-hybrid --binary-filesystem ext4 --image-name $name --hdd-label $name --iso-application $name 
echo "$pkgs" >> config/package-lists/my.list.chroot
mkdir -p config/includes.chroot_after_packages/etc/skel/.local/; mkdir -p config/includes.chroot_after_packages/etc/skel/.config/
echo "COPY USER FILES..."
xdg-open config/includes.chroot_after_packages/etc/skel;
echo "ENTER TO CONTINUE"
read -n1
echo "COPY DEB PACKAGE FILES TO INSTALL..."
xdg-open config/packages.chroot;
echo "ENTER TO CONTINUE"
read -n1
#echo "COPY HOOKS..."
#xdg-open config/hooks;
#echo "ENTER TO CONTINUE"
#read -n1
echo "PESS ENTER TO BUILD ISO" 
read -n1
sudo lb build

