From 4c8d33b25005d57ebd24a0bd2e5cc7f02874f447 Mon Sep 17 00:00:00 2001 From: crims0n Date: Mon, 7 Jun 2021 08:14:29 +0300 Subject: [PATCH] adding docker support --- docker/01-runme.sh | 4 +- docker/02-build.sh | 3 +- docker/Dockerfile.py | 5 +- linux-live/basesystem/01-core/install | 5 +- linux-live/config | 2 +- linux-live/minioslib | 843 ++++++++++++++++++-------- linux-live/modules/02-xorg/install | 4 +- linux-live/modules/03-desktop/install | 9 +- linux-live/modules/04-apps/install | 4 +- 9 files changed, 617 insertions(+), 262 deletions(-) diff --git a/docker/01-runme.sh b/docker/01-runme.sh index 00759ea..2219f88 100755 --- a/docker/01-runme.sh +++ b/docker/01-runme.sh @@ -1,6 +1,8 @@ #!/bin/bash # Several packages need to be installed to use Dockerfile.py # It creates a local container that you can use to build minios-live -apt install python3-pip +apt install -y docker.io python3-pip +systemctl start docker +systemctl enable docker pip3 install pydocker python3 ./Dockerfile.py \ No newline at end of file diff --git a/docker/02-build.sh b/docker/02-build.sh index b7f4d84..04762b7 100755 --- a/docker/02-build.sh +++ b/docker/02-build.sh @@ -1,5 +1,6 @@ #!/bin/bash #docker run -d --name mlc --privileged -v /build:/build local/mlc /build/slax/autoinstall - -docker run --rm -it --privileged -v /build:/build local/mlc /build/slax/autoinstall build_modules_chroot - +docker run --rm -it --privileged -v /build:/build local/mlc /build/slax/autoinstall - +#docker run --rm -it --privileged -v /build:/build local/mlc /build/slax/autoinstall build_modules_chroot - #docker run -it --name mlc --privileged -v /build:/build local/mlc #docker run -d --name mlc --privileged -v /build:/build local/mlc \ No newline at end of file diff --git a/docker/Dockerfile.py b/docker/Dockerfile.py index 8036cec..efd6eb2 100755 --- a/docker/Dockerfile.py +++ b/docker/Dockerfile.py @@ -12,8 +12,9 @@ logging.root.addHandler(logging.StreamHandler(sys.stdout)) class DockerFile(pydocker.DockerFile): """ add here your custom features """ -#d = DockerFile(base_img='ubuntu:focal', name='crims0n/minios-live-container:latest') -d = DockerFile(base_img='ubuntu:focal', name='local/mlc:latest') +d = DockerFile(base_img='ubuntu:focal', name='crims0n/minios-live-container:latest') +#d = DockerFile(base_img='ubuntu:bionic', name='local/mlc:latest') +#d = DockerFile(base_img='debian:buster', name='local/mlc:latest') d.RUN_bash_script('/opt/install.sh', r''' touch /.minios-live-container diff --git a/linux-live/basesystem/01-core/install b/linux-live/basesystem/01-core/install index e45fc91..028d7bf 100644 --- a/linux-live/basesystem/01-core/install +++ b/linux-live/basesystem/01-core/install @@ -13,7 +13,4 @@ if [ -f $SCRIPT_DIR/package.list ]; then #sudo DEBIAN_FRONTEND=$DEBIAN_FRONTEND_TYPE \ $APT_CMD install $APT_OPTIONS $APT_OPTIONS2 \ $(grep -vE "^\s*#" $SCRIPT_DIR/package.list | tr "\n" " ") >>$OUTPUT 2>&1 -fi - -chown live.users /home/live -chown -R live.users /home/live \ No newline at end of file +fi \ No newline at end of file diff --git a/linux-live/config b/linux-live/config index bc93df1..d0f13bf 100644 --- a/linux-live/config +++ b/linux-live/config @@ -34,7 +34,7 @@ DISTRIBUTION_VARIANT="minbase" DISTRIBUTION_URL="http://ftp.ru.debian.org/debian/" # -COMP_TYPE="xz" +COMP_TYPE="lz4" # Kernel file, will be copied to your Live Kit # Your kernel must support aufs and squashfs. Debian Jessie's kernel is ready diff --git a/linux-live/minioslib b/linux-live/minioslib index 9250441..ff279f1 100644 --- a/linux-live/minioslib +++ b/linux-live/minioslib @@ -400,12 +400,21 @@ function chroot_umount_fs() { echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..." set +e - umount $BUILD_DIR/proc >>$OUTPUT 2>&1 - umount $BUILD_DIR/sys >>$OUTPUT 2>&1 - umount $BUILD_DIR/dev/pts >>$OUTPUT 2>&1 - umount $BUILD_DIR/tmp >>$OUTPUT 2>&1 - umount $BUILD_DIR/dev >>$OUTPUT 2>&1 - umount $BUILD_DIR/run >>$OUTPUT 2>&1 + if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then + umount $BUILD_DIR/proc + umount $BUILD_DIR/sys + umount $BUILD_DIR/dev/pts + umount $BUILD_DIR/tmp + umount $BUILD_DIR/dev + umount $BUILD_DIR/run + else + umount $BUILD_DIR/proc >>$OUTPUT 2>&1 + umount $BUILD_DIR/sys >>$OUTPUT 2>&1 + umount $BUILD_DIR/dev/pts >>$OUTPUT 2>&1 + umount $BUILD_DIR/tmp >>$OUTPUT 2>&1 + umount $BUILD_DIR/dev >>$OUTPUT 2>&1 + umount $BUILD_DIR/run >>$OUTPUT 2>&1 + fi set -e check_mounted @@ -531,6 +540,10 @@ function build_bootstrap() { fi } +# ================================================================= +# +# +# ================================================================= function copy_build_scripts() { echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..." if [ ! -d $BUILD_DIR/linux-live ]; then @@ -538,10 +551,18 @@ function copy_build_scripts() { (cd $SCRIPT_DIR/linux-live && cp --parents -afr * $BUILD_DIR/linux-live) else find $SCRIPT_DIR/linux-live -type f -print0 | sed "s,$SCRIPT_DIR/linux-live/,,g" | while IFS= read -r -d '' file; do - if ! cmp $SCRIPT_DIR/linux-live/"$file" $BUILD_DIR/linux-live/"$file" >>$OUTPUT 2>&1; then - echo -e "$file has been modified since last build run." >>$OUTPUT 2>&1 - echo -e "Copying $SCRIPT_DIR/linux-live/$file to $BUILD_DIR/linux-live/$file..." >>$OUTPUT 2>&1 - cp -f $SCRIPT_DIR/linux-live/"$file" $BUILD_DIR/linux-live/"$file" >>$OUTPUT 2>&1 + if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then + if ! cmp $SCRIPT_DIR/linux-live/"$file" $BUILD_DIR/linux-live/"$file"; then + echo -e "$file has been modified since last build run." + echo -e "Copying $SCRIPT_DIR/linux-live/$file to $BUILD_DIR/linux-live/$file..." + cp -f $SCRIPT_DIR/linux-live/"$file" $BUILD_DIR/linux-live/"$file" + fi + else + if ! cmp $SCRIPT_DIR/linux-live/"$file" $BUILD_DIR/linux-live/"$file" >>$OUTPUT 2>&1; then + echo -e "$file has been modified since last build run." >>$OUTPUT 2>&1 + echo -e "Copying $SCRIPT_DIR/linux-live/$file to $BUILD_DIR/linux-live/$file..." >>$OUTPUT 2>&1 + cp -f $SCRIPT_DIR/linux-live/"$file" $BUILD_DIR/linux-live/"$file" >>$OUTPUT 2>&1 + fi fi done fi @@ -565,6 +586,10 @@ function copy_build_scripts() { fi } +# ================================================================= +# +# +# ================================================================= function build_chroot() { current_process @@ -618,6 +643,10 @@ function build_chroot() { fi } +# ================================================================= +# +# +# ================================================================= function build_live() { current_process @@ -668,6 +697,10 @@ function build_live() { } +# ================================================================= +# +# +# ================================================================= function build_iso() { current_process @@ -738,29 +771,16 @@ function build_iso() { exit 0 } -function batch_run() { - current_process - - chroot $1 /usr/bin/env \ - OUTPUT=$OUTPUT \ - LOGPATH=$LOGPATH \ - BUILD_TEST_ISO=$BUILD_TEST_ISO \ - CREATE_BACKUP=$CREATE_BACKUP \ - DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \ - APT_CMD=$APT_CMD \ - APT_OPTIONS=$APT_OPTIONS \ - APT_OPTIONS2=$APT_OPTIONS2 \ - LIVE_TYPE=$LIVE_TYPE \ - sudo DEBIAN_FRONTEND=$DEBIAN_FRONTEND_TYPE \ - $2 -} - # ================================================================= # ================================================================= # ====================== INSTALL FUNCTIONS ======================== # ================================================================= # ================================================================= +# ================================================================= +# +# +# ================================================================= function setup_host() { current_process @@ -769,6 +789,10 @@ function setup_host() { fi } +# ================================================================= +# +# +# ================================================================= function chroot_setup_host() { current_process @@ -787,77 +811,81 @@ function chroot_setup_host() { current_process } -function build_cleanup() { +# ================================================================= +# +# +# ================================================================= +function chroot_build_cleanup() { echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..." set +e - rm -f $MODULE_UPPER_DIR/preinstall >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/install >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/install2 >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/cleanup >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/package.list >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/postinstall >>$OUTPUT 2>&1 - rm -rf $MODULE_UPPER_DIR/rootcopy >>$OUTPUT 2>&1 - rm -rf $MODULE_UPPER_DIR/patches >>$OUTPUT 2>&1 - - rm -f $MODULE_UPPER_DIR/etc/fstab >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/etc/mtab >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/etc/apt/sources.list~ >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/etc/systemd/system/timers.target.wants >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/etc/systemd/system/multi-user.target.wants/ssh.service >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/etc/systemd/system/multi-user.target.wants/dnsmasq.service >>$OUTPUT 2>&1 - - rm -f $MODULE_UPPER_DIR/etc/ssh/ssh_host* >>$OUTPUT 2>&1 - - rm -f $MODULE_UPPER_DIR/var/backups/* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/cache/ldconfig/* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/cache/debconf/* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/cache/fontconfig/* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/lib/apt/extended_states >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/lib/systemd/random-seed >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/deb.* >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/root/.local/share/mc >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/root/.cache >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/root/.wget-hsts >>$OUTPUT 2>&1 - - rm -f $MODULE_UPPER_DIR/var/lib/dpkg/*-old >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/log/* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/log/*/* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/log/*/*/* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/cache/apt/archives/*.deb >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/cache/apt/*.bin >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/cache/debconf/*-old >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/lib/dhcp/dhclient.leases >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/root/.bash_history >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/root/.wget-hsts >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/usr/share/doc/* >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/usr/share/info/* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/usr/share/images/fluxbox/debian-squared.jpg >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/usr/share/fluxbox/nls/??* >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/usr/share/gnome/help >>$OUTPUT 2>&1 - - rm -Rf $MODULE_UPPER_DIR/usr/share/locale/?? >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??_* >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??@* >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??? >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/usr/share/i18n/locales/*_* >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/usr/share/man/?? >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/usr/share/man/*_* >>$OUTPUT 2>&1 - - rm -Rf $MODULE_UPPER_DIR/usr/share/icons/elementaryXubuntu-dark >>$OUTPUT 2>&1 - rm -Rf $MODULE_UPPER_DIR/usr/share/icons/gnome/256x256 >>$OUTPUT 2>&1 - - rm $MODULE_UPPER_DIR/usr/share/applications/compton.desktop >>$OUTPUT 2>&1 - rm $MODULE_UPPER_DIR/usr/share/applications/debian-uxterm.desktop >>$OUTPUT 2>&1 - rm $MODULE_UPPER_DIR/usr/share/applications/debian-xterm.desktop >>$OUTPUT 2>&1 - rm $MODULE_UPPER_DIR/usr/share/applications/htop.desktop >>$OUTPUT 2>&1 - rm $MODULE_UPPER_DIR/usr/share/applications/mc.desktop >>$OUTPUT 2>&1 - rm $MODULE_UPPER_DIR/usr/share/applications/mcedit.desktop >>$OUTPUT 2>&1 - rm $MODULE_UPPER_DIR/usr/share/applications/pcmanfm-desktop-pref.desktop >>$OUTPUT 2>&1 - rm $MODULE_UPPER_DIR/usr/share/applications/python2.7.desktop >>$OUTPUT 2>&1 - rm $MODULE_UPPER_DIR/usr/share/applications/python3.7.desktop >>$OUTPUT 2>&1 - rm $MODULE_UPPER_DIR/usr/share/applications/vim.desktop >>$OUTPUT 2>&1 + rm -f /preinstall >>$OUTPUT 2>&1 + rm -f /install >>$OUTPUT 2>&1 + rm -f /install2 >>$OUTPUT 2>&1 + rm -f /cleanup >>$OUTPUT 2>&1 + rm -f /package.list >>$OUTPUT 2>&1 + rm -f /postinstall >>$OUTPUT 2>&1 + rm -rf /rootcopy >>$OUTPUT 2>&1 + rm -rf /patches >>$OUTPUT 2>&1 + + rm -f /etc/fstab >>$OUTPUT 2>&1 + rm -f /etc/mtab >>$OUTPUT 2>&1 + rm -f /etc/apt/sources.list~ >>$OUTPUT 2>&1 + rm -Rf /etc/systemd/system/timers.target.wants >>$OUTPUT 2>&1 + rm -f /etc/systemd/system/multi-user.target.wants/ssh.service >>$OUTPUT 2>&1 + rm -f /etc/systemd/system/multi-user.target.wants/dnsmasq.service >>$OUTPUT 2>&1 + + rm -f /etc/ssh/ssh_host* >>$OUTPUT 2>&1 + + rm -f /var/backups/* >>$OUTPUT 2>&1 + rm -f /var/cache/ldconfig/* >>$OUTPUT 2>&1 + rm -f /var/cache/debconf/* >>$OUTPUT 2>&1 + rm -f /var/cache/fontconfig/* >>$OUTPUT 2>&1 + rm -f /var/lib/apt/extended_states >>$OUTPUT 2>&1 + rm -f /var/lib/systemd/random-seed >>$OUTPUT 2>&1 + rm -f /var/lib/apt/lists/deb.* >>$OUTPUT 2>&1 + rm -Rf /root/.local/share/mc >>$OUTPUT 2>&1 + rm -Rf /root/.cache >>$OUTPUT 2>&1 + rm -f /root/.wget-hsts >>$OUTPUT 2>&1 + + rm -f /var/lib/dpkg/*-old >>$OUTPUT 2>&1 + rm -f /var/log/* >>$OUTPUT 2>&1 + rm -f /var/log/*/* >>$OUTPUT 2>&1 + rm -f /var/log/*/*/* >>$OUTPUT 2>&1 + rm -f /var/cache/apt/archives/*.deb >>$OUTPUT 2>&1 + rm -f /var/cache/apt/*.bin >>$OUTPUT 2>&1 + rm -f /var/cache/debconf/*-old >>$OUTPUT 2>&1 + rm -f /var/lib/dhcp/dhclient.leases >>$OUTPUT 2>&1 + rm -f /root/.bash_history >>$OUTPUT 2>&1 + rm -f /root/.wget-hsts >>$OUTPUT 2>&1 + rm -Rf /usr/share/doc/* >>$OUTPUT 2>&1 + rm -Rf /usr/share/info/* >>$OUTPUT 2>&1 + rm -f /usr/share/images/fluxbox/debian-squared.jpg >>$OUTPUT 2>&1 + rm -Rf /usr/share/fluxbox/nls/??* >>$OUTPUT 2>&1 + rm -Rf /usr/share/gnome/help >>$OUTPUT 2>&1 + + rm -Rf /usr/share/locale/?? >>$OUTPUT 2>&1 + rm -Rf /usr/share/locale/??_* >>$OUTPUT 2>&1 + rm -Rf /usr/share/locale/??@* >>$OUTPUT 2>&1 + rm -Rf /usr/share/locale/??? >>$OUTPUT 2>&1 + rm -Rf /usr/share/i18n/locales/*_* >>$OUTPUT 2>&1 + rm -Rf /usr/share/man/?? >>$OUTPUT 2>&1 + rm -Rf /usr/share/man/*_* >>$OUTPUT 2>&1 + + rm -Rf /usr/share/icons/elementaryXubuntu-dark >>$OUTPUT 2>&1 + rm -Rf /usr/share/icons/gnome/256x256 >>$OUTPUT 2>&1 + + rm /usr/share/applications/compton.desktop >>$OUTPUT 2>&1 + rm /usr/share/applications/debian-uxterm.desktop >>$OUTPUT 2>&1 + rm /usr/share/applications/debian-xterm.desktop >>$OUTPUT 2>&1 + rm /usr/share/applications/htop.desktop >>$OUTPUT 2>&1 + rm /usr/share/applications/mc.desktop >>$OUTPUT 2>&1 + rm /usr/share/applications/mcedit.desktop >>$OUTPUT 2>&1 + rm /usr/share/applications/pcmanfm-desktop-pref.desktop >>$OUTPUT 2>&1 + rm /usr/share/applications/python2.7.desktop >>$OUTPUT 2>&1 + rm /usr/share/applications/python3.7.desktop >>$OUTPUT 2>&1 + rm /usr/share/applications/vim.desktop >>$OUTPUT 2>&1 # Unzip gzipped files (man pages), so LZMA can compress 2times better. # First we fix symlinks, then uncompress files @@ -874,8 +902,8 @@ function build_cleanup() { find "$1" -type f -name "*.gz" | xargs -r gunzip >>$OUTPUT 2>&1 } - uncompress_files $MODULE_UPPER_DIR/etc/alternatives >>$OUTPUT 2>&1 - uncompress_files $MODULE_UPPER_DIR/usr/share/man >>$OUTPUT 2>&1 + uncompress_files /etc/alternatives >>$OUTPUT 2>&1 + uncompress_files /usr/share/man >>$OUTPUT 2>&1 # remove broken links # $1 = search directory @@ -883,13 +911,17 @@ function build_cleanup() { find "$1" -type l -exec test ! -e {} \; -print | xargs rm -vf >>$OUTPUT 2>&1 } - remove_broken_links $MODULE_UPPER_DIR/etc/alternatives >>$OUTPUT 2>&1 - remove_broken_links $MODULE_UPPER_DIR/usr/share/man >>$OUTPUT 2>&1 + remove_broken_links /etc/alternatives >>$OUTPUT 2>&1 + remove_broken_links /usr/share/man >>$OUTPUT 2>&1 set -e } +# ================================================================= +# +# +# ================================================================= function hostreq_pkg_list() { echo -e "${YELLOW}=====> installing required software for host system ...${ENDCOLOUR}" $APT_CMD update >>$OUTPUT 2>&1 @@ -902,6 +934,10 @@ function hostreq_pkg_list() { fi } +# ================================================================= +# +# +# ================================================================= function prereq_pkg_list() { echo -e "${YELLOW}=====> installing prerequested software for chroot system ...${ENDCOLOUR}" @@ -915,6 +951,10 @@ function prereq_pkg_list() { fi } +# ================================================================= +# +# +# ================================================================= function main_pkg_list() { echo -e "${YELLOW}=====> installing main packages for chroot system ...${ENDCOLOUR}" @@ -929,9 +969,9 @@ function main_pkg_list() { LIVE_TYPE=$LIVE_TYPE \ /linux-live/basesystem/01-core/preinstall fi - if [ "$(ls -A /linux-live/basesystem/01-core/rootcopy)" != "" ]; then + : ' if [ "$(ls -A /linux-live/basesystem/01-core/rootcopy)" != "" ]; then (cd /linux-live/basesystem/01-core/rootcopy && cp --parents -afr * /) - fi + fi' if [ -f /linux-live/basesystem/01-core/install ]; then chmod +x /linux-live/basesystem/01-core/install /usr/bin/env \ @@ -955,9 +995,13 @@ function main_pkg_list() { /linux-live/basesystem/01-core/postinstall fi - build_cleanup + chroot_build_cleanup } +# ================================================================= +# +# +# ================================================================= function chroot_pkg_install() { current_process @@ -970,11 +1014,13 @@ function chroot_pkg_install() { $APT_CMD clean $APT_OPTIONS >>$OUTPUT 2>&1 } +# ================================================================= +# +# +# ================================================================= function chroot_configure() { current_process - (cd /linux-live/basesystem/01-core/rootcopy && cp --parents -afr * /) - echo "Set up password for user 'root'" >>$OUTPUT 2>&1 echo root:toor | chpasswd >>$OUTPUT 2>&1 @@ -985,34 +1031,18 @@ function chroot_configure() { addgroup live adm >>$OUTPUT 2>&1 addgroup live sudo >>$OUTPUT 2>&1 + (cd /linux-live/basesystem/01-core/rootcopy && cp --parents -afr * /) + + chown live:live /home/live + chown -R live:live /home/live + cat </etc/sudoers.d/90-minios # live user is default user in minios. # It needs passwordless sudo functionality. live ALL=(ALL) NOPASSWD:ALL EOF - if [ ! -d /etc/NetworkManager ]; then - echo "Enable dhclient.service autostart." >>$OUTPUT 2>&1 - cat </lib/systemd/system/dhclient.service -[Unit] -Description=DHCP Client -Documentation=man:dhclient(8) -Wants=network.target -After=network-pre.target systemd-sysctl.service systemd-modules-load.service -Before=network.target shutdown.target network-online.target -ConditionPathExists=!/run/initramfs/net.up.flag - -[Service] -Type=forking -ExecStart=-/bin/sh -c 'udevadm settle && dhclient -nw' -PIDFile=/run/dhclient.pid - -[Install] -WantedBy=multi-user.target -WantedBy=network-online.target -EOF - systemctl enable dhclient >>$OUTPUT 2>&1 - fi + systemctl enable dhclient >>$OUTPUT 2>&1 if [ -f /etc/systemd/system/multi-user.target.wants/grub-initrd-fallback.service ]; then echo "Disable grub-initrd-fallback.service autostart." @@ -1021,7 +1051,7 @@ EOF if grep openssh-server $SCRIPT_DIR/basesystem/01-core/package.list >>$OUTPUT 2>&1; then echo "Enable ssh.service autostart." >>$OUTPUT 2>&1 - cat </lib/systemd/system/ssh-keygen.service + cat </usr/lib/systemd/system/ssh-keygen.service [Unit] Description=Generate sshd keys Before=ssh.service @@ -1072,45 +1102,14 @@ EOF -EOF - else - cat </etc/issue - - - \l - - - - - - Thank you for using MiniOS. - Based on Ubuntu. - - :::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: :::::::: - +:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+: - +:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ - +#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++ - +#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+ - #+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+# - ### ### ########### ### #### ########### ######## ######## - - : : - : Root login name: root : - : Password: toor : - : User login name: live : - : Password: evil : - - - - - - - EOF fi - } +# ================================================================= +# +# +# ================================================================= function chroot_finish_up() { current_process @@ -1154,6 +1153,10 @@ function chroot_finish_up() { # ================================================================= # ================================================================= +# ================================================================= +# +# +# ================================================================= function module_check_mounted() { echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..." if grep -qs "$MODULE_MERGED_DIR" /proc/mounts || grep -qs "$MODULE_MERGED_DIR/dev" /proc/mounts || grep -qs "$MODULE_MERGED_DIR/run" /proc/mounts || grep -qs "$MODULE_MERGED_DIR/proc" /proc/mounts || grep -qs "$MODULE_MERGED_DIR/sys" /proc/mounts || grep -qs "$MODULE_MERGED_DIR/dev/pts" /proc/mounts || grep -qs "$MODULE_MERGED_DIR/tmp" /proc/mounts; then @@ -1172,6 +1175,10 @@ function module_check_mounted() { fi } +# ================================================================= +# +# +# ================================================================= function module_check_build_dir() { echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..." if [ "$UNATTENDED" = "1" ]; then @@ -1195,6 +1202,10 @@ function module_check_build_dir() { fi } +# ================================================================= +# +# +# ================================================================= function module_chroot_mount_fs() { echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..." @@ -1262,37 +1273,61 @@ function module_chroot_mount_fs() { mount none -t tmpfs $MODULE_MERGED_DIR/tmp } +# ================================================================= +# +# +# ================================================================= function module_chroot_umount_fs() { echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..." local MODULES MODULE_LOWER_DIR set +e - umount $MODULE_MERGED_DIR/proc >>$OUTPUT 2>&1 - umount $MODULE_MERGED_DIR/sys >>$OUTPUT 2>&1 - umount $MODULE_MERGED_DIR/dev/pts >>$OUTPUT 2>&1 - umount $MODULE_MERGED_DIR/tmp >>$OUTPUT 2>&1 - umount $MODULE_MERGED_DIR/dev >>$OUTPUT 2>&1 - if [ -f /.dockerenv ] || [ "$container" = "podman" ]; then - umount $MODULE_MERGED_DIR/run/resolvconf/resolv.conf >>$OUTPUT 2>&1 - rm -f $MODULE_MERGED_DIR/run/resolvconf/resolv.conf - rmdir $MODULE_MERGED_DIR/run/resolvconf + if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then + umount $MODULE_MERGED_DIR/proc + umount $MODULE_MERGED_DIR/sys + umount $MODULE_MERGED_DIR/dev/pts + umount $MODULE_MERGED_DIR/tmp + umount $MODULE_MERGED_DIR/dev + if [ -f /.dockerenv ] || [ "$container" = "podman" ]; then + umount $MODULE_MERGED_DIR/run/resolvconf/resolv.conf + rm -f $MODULE_MERGED_DIR/run/resolvconf/resolv.conf + rmdir $MODULE_MERGED_DIR/run/resolvconf + else + umount $MODULE_MERGED_DIR/run + fi + umount $MODULE_MERGED_DIR else - umount $MODULE_MERGED_DIR/run >>$OUTPUT 2>&1 + umount $MODULE_MERGED_DIR/proc >>$OUTPUT 2>&1 + umount $MODULE_MERGED_DIR/sys >>$OUTPUT 2>&1 + umount $MODULE_MERGED_DIR/dev/pts >>$OUTPUT 2>&1 + umount $MODULE_MERGED_DIR/tmp >>$OUTPUT 2>&1 + umount $MODULE_MERGED_DIR/dev >>$OUTPUT 2>&1 + if [ -f /.dockerenv ] || [ "$container" = "podman" ]; then + umount $MODULE_MERGED_DIR/run/resolvconf/resolv.conf >>$OUTPUT 2>&1 + rm -f $MODULE_MERGED_DIR/run/resolvconf/resolv.conf + rmdir $MODULE_MERGED_DIR/run/resolvconf + else + umount $MODULE_MERGED_DIR/run >>$OUTPUT 2>&1 + fi + umount $MODULE_MERGED_DIR >>$OUTPUT 2>&1 fi - umount $MODULE_MERGED_DIR >>$OUTPUT 2>&1 - #set -e MODULES=($PARENT_DIR/image/$LIVEKITNAME/*.$BEXT) for ((i = ${#MODULES[@]} - 1; i >= 0; i--)); do MODULE_LOWER_DIR=$(basename ${MODULES[$i]} .$BEXT) umount $MODULES_DIR/lower/$MODULE_LOWER_DIR-lower done + set -e module_check_mounted } +# ================================================================= +# +# +# ================================================================= function module_cleanup() { echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..." if [ "$UNATTENDED" = "1" ]; then @@ -1317,6 +1352,10 @@ function module_cleanup() { fi } +# ================================================================= +# +# +# ================================================================= function module_chroot_finish_up() { echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..." @@ -1326,42 +1365,288 @@ truncate -s 0 /etc/machine-id EOF # remove diversion (why??) - chroot $MODULE_MERGED_DIR /bin/bash -x <>$OUTPUT 2>&1 dpkg-divert --rename --remove /sbin/initctl >>$OUTPUT 2>&1 EOF + fi } +# ================================================================= +# +# +# ================================================================= function module_chroot_cleanup() { echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..." # clean up useless stuff - rm -rf $MODULE_UPPER_DIR/boot $MODULE_UPPER_DIR/dev $MODULE_UPPER_DIR/proc $MODULE_UPPER_DIR/sys $MODULE_UPPER_DIR/rmp $MODULE_UPPER_DIR/run - rm -f $MODULE_UPPER_DIR/root/.bash_history >>$OUTPUT 2>&1 - rm -rf $MODULE_UPPER_DIR/.cache - find $MODULE_UPPER_DIR/var/log/ -type f | xargs rm -f >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/etc/ssh/ssh_host* - rm -f $MODULE_UPPER_DIR/var/backups/* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/cache/ldconfig/* >>$OUTPUT 2>&1 - #rm -f $MODULE_UPPER_DIR/var/cache/debconf/* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/cache/fontconfig/* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/cache/apt/archives/*.deb >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/cache/apt/*.bin >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/cache/debconf/*-old >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/lib/apt/extended_states >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/*Packages >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/*Translation* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/*InRelease >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/deb.* >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/var/lib/dpkg/*-old >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/preinstall >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/install >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/install2 >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/cleanup >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/package.list >>$OUTPUT 2>&1 - rm -f $MODULE_UPPER_DIR/postinstall >>$OUTPUT 2>&1 - rm -rf $MODULE_UPPER_DIR/rootcopy >>$OUTPUT 2>&1 + if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then + rm -rf $MODULE_UPPER_DIR/boot $MODULE_UPPER_DIR/dev $MODULE_UPPER_DIR/proc $MODULE_UPPER_DIR/sys $MODULE_UPPER_DIR/rmp $MODULE_UPPER_DIR/run + rm -f $MODULE_UPPER_DIR/root/.bash_history + rm -rf $MODULE_UPPER_DIR/.cache + find $MODULE_UPPER_DIR/var/log/ -type f | xargs rm -f + rm -f $MODULE_UPPER_DIR/etc/ssh/ssh_host* + rm -f $MODULE_UPPER_DIR/var/backups/* + rm -f $MODULE_UPPER_DIR/var/cache/ldconfig/* + #rm -f $MODULE_UPPER_DIR/var/cache/debconf/* + rm -f $MODULE_UPPER_DIR/var/cache/fontconfig/* + rm -f $MODULE_UPPER_DIR/var/cache/apt/archives/*.deb + rm -f $MODULE_UPPER_DIR/var/cache/apt/*.bin + rm -f $MODULE_UPPER_DIR/var/cache/debconf/*-old + rm -f $MODULE_UPPER_DIR/var/lib/apt/extended_states + rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/*Packages + rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/*Translation* + rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/*InRelease + rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/deb.* + rm -f $MODULE_UPPER_DIR/var/lib/dpkg/*-old + rm -f $MODULE_UPPER_DIR/preinstall + rm -f $MODULE_UPPER_DIR/install + rm -f $MODULE_UPPER_DIR/install2 + rm -f $MODULE_UPPER_DIR/cleanup + rm -f $MODULE_UPPER_DIR/package.list + rm -f $MODULE_UPPER_DIR/postinstall + rm -rf $MODULE_UPPER_DIR/rootcopy + else + rm -rf $MODULE_UPPER_DIR/boot $MODULE_UPPER_DIR/dev $MODULE_UPPER_DIR/proc $MODULE_UPPER_DIR/sys $MODULE_UPPER_DIR/rmp $MODULE_UPPER_DIR/run + rm -f $MODULE_UPPER_DIR/root/.bash_history >>$OUTPUT 2>&1 + rm -rf $MODULE_UPPER_DIR/.cache + find $MODULE_UPPER_DIR/var/log/ -type f | xargs rm -f >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/etc/ssh/ssh_host* + rm -f $MODULE_UPPER_DIR/var/backups/* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/cache/ldconfig/* >>$OUTPUT 2>&1 + #rm -f $MODULE_UPPER_DIR/var/cache/debconf/* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/cache/fontconfig/* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/cache/apt/archives/*.deb >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/cache/apt/*.bin >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/cache/debconf/*-old >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/lib/apt/extended_states >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/*Packages >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/*Translation* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/*InRelease >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/deb.* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/lib/dpkg/*-old >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/preinstall >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/install >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/install2 >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/cleanup >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/package.list >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/postinstall >>$OUTPUT 2>&1 + rm -rf $MODULE_UPPER_DIR/rootcopy >>$OUTPUT 2>&1 + fi +} + +# ================================================================= +# +# +# ================================================================= +function module_build_cleanup() { + echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..." + + set +e + + if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then + rm -f $MODULE_UPPER_DIR/preinstall + rm -f $MODULE_UPPER_DIR/install + rm -f $MODULE_UPPER_DIR/install2 + rm -f $MODULE_UPPER_DIR/cleanup + rm -f $MODULE_UPPER_DIR/package.list + rm -f $MODULE_UPPER_DIR/postinstall + rm -rf $MODULE_UPPER_DIR/rootcopy + rm -rf $MODULE_UPPER_DIR/patches + + rm -f $MODULE_UPPER_DIR/etc/fstab + rm -f $MODULE_UPPER_DIR/etc/mtab + rm -f $MODULE_UPPER_DIR/etc/apt/sources.list~ + rm -Rf $MODULE_UPPER_DIR/etc/systemd/system/timers.target.wants + rm -f $MODULE_UPPER_DIR/etc/systemd/system/multi-user.target.wants/ssh.service + rm -f $MODULE_UPPER_DIR/etc/systemd/system/multi-user.target.wants/dnsmasq.service + + rm -f $MODULE_UPPER_DIR/etc/ssh/ssh_host* + + rm -f $MODULE_UPPER_DIR/var/backups/* + rm -f $MODULE_UPPER_DIR/var/cache/ldconfig/* + rm -f $MODULE_UPPER_DIR/var/cache/debconf/* + rm -f $MODULE_UPPER_DIR/var/cache/fontconfig/* + rm -f $MODULE_UPPER_DIR/var/lib/apt/extended_states + rm -f $MODULE_UPPER_DIR/var/lib/systemd/random-seed + rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/deb.* + rm -Rf $MODULE_UPPER_DIR/root/.local/share/mc + rm -Rf $MODULE_UPPER_DIR/root/.cache + rm -f $MODULE_UPPER_DIR/root/.wget-hsts + + rm -f $MODULE_UPPER_DIR/var/lib/dpkg/*-old + rm -f $MODULE_UPPER_DIR/var/log/* + rm -f $MODULE_UPPER_DIR/var/log/*/* + rm -f $MODULE_UPPER_DIR/var/log/*/*/* + rm -f $MODULE_UPPER_DIR/var/cache/apt/archives/*.deb + rm -f $MODULE_UPPER_DIR/var/cache/apt/*.bin + rm -f $MODULE_UPPER_DIR/var/cache/debconf/*-old + rm -f $MODULE_UPPER_DIR/var/lib/dhcp/dhclient.leases + rm -f $MODULE_UPPER_DIR/root/.bash_history + rm -f $MODULE_UPPER_DIR/root/.wget-hsts + rm -Rf $MODULE_UPPER_DIR/usr/share/doc/* + rm -Rf $MODULE_UPPER_DIR/usr/share/info/* + rm -f $MODULE_UPPER_DIR/usr/share/images/fluxbox/debian-squared.jpg + rm -Rf $MODULE_UPPER_DIR/usr/share/fluxbox/nls/??* + rm -Rf $MODULE_UPPER_DIR/usr/share/gnome/help + + rm -Rf $MODULE_UPPER_DIR/usr/share/locale/?? + rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??_* + rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??@* + rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??? + rm -Rf $MODULE_UPPER_DIR/usr/share/i18n/locales/*_* + rm -Rf $MODULE_UPPER_DIR/usr/share/man/?? + rm -Rf $MODULE_UPPER_DIR/usr/share/man/*_* + + rm -Rf $MODULE_UPPER_DIR/usr/share/icons/elementaryXubuntu-dark + rm -Rf $MODULE_UPPER_DIR/usr/share/icons/gnome/256x256 + + rm $MODULE_UPPER_DIR/usr/share/applications/compton.desktop + rm $MODULE_UPPER_DIR/usr/share/applications/debian-uxterm.desktop + rm $MODULE_UPPER_DIR/usr/share/applications/debian-xterm.desktop + rm $MODULE_UPPER_DIR/usr/share/applications/htop.desktop + rm $MODULE_UPPER_DIR/usr/share/applications/mc.desktop + rm $MODULE_UPPER_DIR/usr/share/applications/mcedit.desktop + rm $MODULE_UPPER_DIR/usr/share/applications/pcmanfm-desktop-pref.desktop + rm $MODULE_UPPER_DIR/usr/share/applications/python2.7.desktop + rm $MODULE_UPPER_DIR/usr/share/applications/python3.7.desktop + rm $MODULE_UPPER_DIR/usr/share/applications/vim.desktop + + # Unzip gzipped files (man pages), so LZMA can compress 2times better. + # First we fix symlinks, then uncompress files + # $1 = search directory + uncompress_files() { + local LINK LINE + + find "$1" -type l -name "*.gz" | while read LINE; do + LINK="$(readlink "$LINE" | sed -r 's/.gz$//')" + FILE="$(echo "$LINE" | sed -r 's/.gz$//')" + ln -sfn "$LINK" "$FILE" + rm -f "$LINE" + done + find "$1" -type f -name "*.gz" | xargs -r gunzip + } + + uncompress_files $MODULE_UPPER_DIR/etc/alternatives + uncompress_files $MODULE_UPPER_DIR/usr/share/man + + # remove broken links + # $1 = search directory + remove_broken_links() { + find "$1" -type l -exec test ! -e {} \; -print | xargs rm -vf + } + + remove_broken_links $MODULE_UPPER_DIR/etc/alternatives + remove_broken_links $MODULE_UPPER_DIR/usr/share/man + else + rm -f $MODULE_UPPER_DIR/preinstall >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/install >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/install2 >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/cleanup >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/package.list >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/postinstall >>$OUTPUT 2>&1 + rm -rf $MODULE_UPPER_DIR/rootcopy >>$OUTPUT 2>&1 + rm -rf $MODULE_UPPER_DIR/patches >>$OUTPUT 2>&1 + + rm -f $MODULE_UPPER_DIR/etc/fstab >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/etc/mtab >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/etc/apt/sources.list~ >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/etc/systemd/system/timers.target.wants >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/etc/systemd/system/multi-user.target.wants/ssh.service >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/etc/systemd/system/multi-user.target.wants/dnsmasq.service >>$OUTPUT 2>&1 + + rm -f $MODULE_UPPER_DIR/etc/ssh/ssh_host* >>$OUTPUT 2>&1 + + rm -f $MODULE_UPPER_DIR/var/backups/* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/cache/ldconfig/* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/cache/debconf/* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/cache/fontconfig/* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/lib/apt/extended_states >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/lib/systemd/random-seed >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/deb.* >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/root/.local/share/mc >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/root/.cache >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/root/.wget-hsts >>$OUTPUT 2>&1 + + rm -f $MODULE_UPPER_DIR/var/lib/dpkg/*-old >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/log/* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/log/*/* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/log/*/*/* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/cache/apt/archives/*.deb >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/cache/apt/*.bin >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/cache/debconf/*-old >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/var/lib/dhcp/dhclient.leases >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/root/.bash_history >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/root/.wget-hsts >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/usr/share/doc/* >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/usr/share/info/* >>$OUTPUT 2>&1 + rm -f $MODULE_UPPER_DIR/usr/share/images/fluxbox/debian-squared.jpg >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/usr/share/fluxbox/nls/??* >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/usr/share/gnome/help >>$OUTPUT 2>&1 + + rm -Rf $MODULE_UPPER_DIR/usr/share/locale/?? >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??_* >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??@* >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??? >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/usr/share/i18n/locales/*_* >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/usr/share/man/?? >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/usr/share/man/*_* >>$OUTPUT 2>&1 + + rm -Rf $MODULE_UPPER_DIR/usr/share/icons/elementaryXubuntu-dark >>$OUTPUT 2>&1 + rm -Rf $MODULE_UPPER_DIR/usr/share/icons/gnome/256x256 >>$OUTPUT 2>&1 + + rm $MODULE_UPPER_DIR/usr/share/applications/compton.desktop >>$OUTPUT 2>&1 + rm $MODULE_UPPER_DIR/usr/share/applications/debian-uxterm.desktop >>$OUTPUT 2>&1 + rm $MODULE_UPPER_DIR/usr/share/applications/debian-xterm.desktop >>$OUTPUT 2>&1 + rm $MODULE_UPPER_DIR/usr/share/applications/htop.desktop >>$OUTPUT 2>&1 + rm $MODULE_UPPER_DIR/usr/share/applications/mc.desktop >>$OUTPUT 2>&1 + rm $MODULE_UPPER_DIR/usr/share/applications/mcedit.desktop >>$OUTPUT 2>&1 + rm $MODULE_UPPER_DIR/usr/share/applications/pcmanfm-desktop-pref.desktop >>$OUTPUT 2>&1 + rm $MODULE_UPPER_DIR/usr/share/applications/python2.7.desktop >>$OUTPUT 2>&1 + rm $MODULE_UPPER_DIR/usr/share/applications/python3.7.desktop >>$OUTPUT 2>&1 + rm $MODULE_UPPER_DIR/usr/share/applications/vim.desktop >>$OUTPUT 2>&1 + + # Unzip gzipped files (man pages), so LZMA can compress 2times better. + # First we fix symlinks, then uncompress files + # $1 = search directory + uncompress_files() { + local LINK LINE + + find "$1" -type l -name "*.gz" | while read LINE; do + LINK="$(readlink "$LINE" | sed -r 's/.gz$//')" + FILE="$(echo "$LINE" | sed -r 's/.gz$//')" + ln -sfn "$LINK" "$FILE" + rm -f "$LINE" + done + find "$1" -type f -name "*.gz" | xargs -r gunzip >>$OUTPUT 2>&1 + } + + uncompress_files $MODULE_UPPER_DIR/etc/alternatives >>$OUTPUT 2>&1 + uncompress_files $MODULE_UPPER_DIR/usr/share/man >>$OUTPUT 2>&1 + + # remove broken links + # $1 = search directory + remove_broken_links() { + find "$1" -type l -exec test ! -e {} \; -print | xargs rm -vf >>$OUTPUT 2>&1 + } + + remove_broken_links $MODULE_UPPER_DIR/etc/alternatives >>$OUTPUT 2>&1 + remove_broken_links $MODULE_UPPER_DIR/usr/share/man >>$OUTPUT 2>&1 + fi + + set -e + } +# ================================================================= +# +# +# ================================================================= function build_modules_chroot() { current_process @@ -1408,13 +1693,26 @@ function build_modules_chroot() { # copy files if [ ! -f $SCRIPT_DIR/linux-live/modules/$MODULE/is_internal_build ]; then - if [ "$(ls -A $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy)" != "" ] >>$OUTPUT 2>&1; then - (cd $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy && cp --parents -afr * $MODULE_MERGED_DIR/) + if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then + if [ "$(ls -A $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy)" != "" ]; then + (cd $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy && cp --parents -afr * $MODULE_MERGED_DIR/) + fi + else + if [ "$(ls -A $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy)" != "" ] >>$OUTPUT 2>&1; then + (cd $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy && cp --parents -afr * $MODULE_MERGED_DIR/) + fi fi else - if [ "$(ls -A $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy)" != "" ] >>$OUTPUT 2>&1; then - mkdir $MODULE_MERGED_DIR/rootcopy - (cd $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy && cp --parents -afr * $MODULE_MERGED_DIR/rootcopy/) + if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then + if [ "$(ls -A $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy)" != "" ]; then + mkdir $MODULE_MERGED_DIR/rootcopy + (cd $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy && cp --parents -afr * $MODULE_MERGED_DIR/rootcopy/) + fi + else + if [ "$(ls -A $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy)" != "" ] >>$OUTPUT 2>&1; then + mkdir $MODULE_MERGED_DIR/rootcopy + (cd $SCRIPT_DIR/linux-live/modules/$MODULE/rootcopy && cp --parents -afr * $MODULE_MERGED_DIR/rootcopy/) + fi fi fi @@ -1428,23 +1726,37 @@ function build_modules_chroot() { if [ -f $SCRIPT_DIR/linux-live/modules/$MODULE/package.list ]; then cp $SCRIPT_DIR/linux-live/modules/$MODULE/package.list $MODULE_MERGED_DIR/package.list fi - chroot $MODULE_MERGED_DIR /usr/bin/env \ - OUTPUT=$OUTPUT \ - LOGPATH=$LOGPATH \ - BUILD_TEST_ISO=$BUILD_TEST_ISO \ - CREATE_BACKUP=$CREATE_BACKUP \ - DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \ - APT_CMD=$APT_CMD \ - APT_OPTIONS=$APT_OPTIONS \ - APT_OPTIONS2=$APT_OPTIONS2 \ - LIVE_TYPE=$LIVE_TYPE \ - /install >>$OUTPUT 2>&1 + if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then + chroot $MODULE_MERGED_DIR /usr/bin/env \ + OUTPUT=$OUTPUT \ + LOGPATH=$LOGPATH \ + BUILD_TEST_ISO=$BUILD_TEST_ISO \ + CREATE_BACKUP=$CREATE_BACKUP \ + DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \ + APT_CMD=$APT_CMD \ + APT_OPTIONS=$APT_OPTIONS \ + APT_OPTIONS2=$APT_OPTIONS2 \ + LIVE_TYPE=$LIVE_TYPE \ + /install + else + chroot $MODULE_MERGED_DIR /usr/bin/env \ + OUTPUT=$OUTPUT \ + LOGPATH=$LOGPATH \ + BUILD_TEST_ISO=$BUILD_TEST_ISO \ + CREATE_BACKUP=$CREATE_BACKUP \ + DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \ + APT_CMD=$APT_CMD \ + APT_OPTIONS=$APT_OPTIONS \ + APT_OPTIONS2=$APT_OPTIONS2 \ + LIVE_TYPE=$LIVE_TYPE \ + /install >>$OUTPUT 2>&1 + fi fi if [ -f $SCRIPT_DIR/linux-live/modules/$MODULE/is_internal_build ]; then module_chroot_umount_fs - build_cleanup + module_build_cleanup # run external actions @@ -1455,7 +1767,7 @@ function build_modules_chroot() { cd $MODULE_UPPER_DIR >>$OUTPUT 2>&1 unsquashfs $MODULE-stock.$BEXT >>$OUTPUT 2>&1 else - echo -e "${MAGENTA}$BUILD_DIR${ENDCOLOUR} is empty. Nothing to do." + echo -e "${MAGENTA}$MODULE_UPPER_DIR${ENDCOLOUR} is empty. Nothing to do." fi #module_check_build_dir @@ -1471,34 +1783,62 @@ function build_modules_chroot() { mkdir $MODULE_MERGED_DIR/patches (cd $SCRIPT_DIR/linux-live/modules/$MODULE/patches && cp --parents -afr * $MODULE_MERGED_DIR/patches/) fi - chroot $MODULE_MERGED_DIR /usr/bin/env \ - OUTPUT=$OUTPUT \ - LOGPATH=$LOGPATH \ - BUILD_TEST_ISO=$BUILD_TEST_ISO \ - CREATE_BACKUP=$CREATE_BACKUP \ - DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \ - APT_CMD=$APT_CMD \ - APT_OPTIONS=$APT_OPTIONS \ - APT_OPTIONS2=$APT_OPTIONS2 \ - LIVE_TYPE=$LIVE_TYPE \ - /install2 >>$OUTPUT 2>&1 + if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then + chroot $MODULE_MERGED_DIR /usr/bin/env \ + OUTPUT=$OUTPUT \ + LOGPATH=$LOGPATH \ + BUILD_TEST_ISO=$BUILD_TEST_ISO \ + CREATE_BACKUP=$CREATE_BACKUP \ + DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \ + APT_CMD=$APT_CMD \ + APT_OPTIONS=$APT_OPTIONS \ + APT_OPTIONS2=$APT_OPTIONS2 \ + LIVE_TYPE=$LIVE_TYPE \ + /install2 + else + chroot $MODULE_MERGED_DIR /usr/bin/env \ + OUTPUT=$OUTPUT \ + LOGPATH=$LOGPATH \ + BUILD_TEST_ISO=$BUILD_TEST_ISO \ + CREATE_BACKUP=$CREATE_BACKUP \ + DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \ + APT_CMD=$APT_CMD \ + APT_OPTIONS=$APT_OPTIONS \ + APT_OPTIONS2=$APT_OPTIONS2 \ + LIVE_TYPE=$LIVE_TYPE \ + /install2 >>$OUTPUT 2>&1 + fi fi # run post-install script if [ -f $SCRIPT_DIR/linux-live/modules/$MODULE/postinstall ]; then cp $SCRIPT_DIR/linux-live/modules/$MODULE/postinstall $MODULE_MERGED_DIR/postinstall chmod +x $MODULE_MERGED_DIR/postinstall - chroot $MODULE_MERGED_DIR /usr/bin/env \ - OUTPUT=$OUTPUT \ - LOGPATH=$LOGPATH \ - BUILD_TEST_ISO=$BUILD_TEST_ISO \ - CREATE_BACKUP=$CREATE_BACKUP \ - DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \ - APT_CMD=$APT_CMD \ - APT_OPTIONS=$APT_OPTIONS \ - APT_OPTIONS2=$APT_OPTIONS2 \ - LIVE_TYPE=$LIVE_TYPE \ - /postinstall >>$OUTPUT 2>&1 + if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then + chroot $MODULE_MERGED_DIR /usr/bin/env \ + OUTPUT=$OUTPUT \ + LOGPATH=$LOGPATH \ + BUILD_TEST_ISO=$BUILD_TEST_ISO \ + CREATE_BACKUP=$CREATE_BACKUP \ + DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \ + APT_CMD=$APT_CMD \ + APT_OPTIONS=$APT_OPTIONS \ + APT_OPTIONS2=$APT_OPTIONS2 \ + LIVE_TYPE=$LIVE_TYPE \ + /postinstall + else + chroot $MODULE_MERGED_DIR /usr/bin/env \ + OUTPUT=$OUTPUT \ + LOGPATH=$LOGPATH \ + BUILD_TEST_ISO=$BUILD_TEST_ISO \ + CREATE_BACKUP=$CREATE_BACKUP \ + DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \ + APT_CMD=$APT_CMD \ + APT_OPTIONS=$APT_OPTIONS \ + APT_OPTIONS2=$APT_OPTIONS2 \ + LIVE_TYPE=$LIVE_TYPE \ + /postinstall >>$OUTPUT 2>&1 + fi fi # run external actions @@ -1511,15 +1851,26 @@ function build_modules_chroot() { module_chroot_umount_fs if [ ! -f $SCRIPT_DIR/linux-live/modules/$MODULE/is_internal_build ]; then - build_cleanup + module_build_cleanup fi module_chroot_cleanup if [ ! -f $SCRIPT_DIR/linux-live/modules/$MODULE/is_internal_build ]; then - ls -la $SCRIPT_DIR/linux-live/modules/$MODULE/ - if [ ! -f $PARENT_DIR/image/$LIVEKITNAME/$MODULE.$BEXT ]; then - build_modules_live + if [ ! -f $PARENT_DIR/image/$LIVEKITNAME/$MODULE-$COMP_TYPE.$BEXT ]; then + if [ "$(ls -A $MODULE_UPPER_DIR)" != "" ]; then + if [ $COMP_TYPE = "zstd" ]; then + mksquashfs $MODULE_UPPER_DIR $PARENT_DIR/image/$LIVEKITNAME/$MODULE-$COMP_TYPE.$BEXT -comp $COMP_TYPE -Xcompression-level 22 -b 1024K -always-use-fragments -noappend || exit + else + mksquashfs $MODULE_UPPER_DIR $PARENT_DIR/image/$LIVEKITNAME/$MODULE-$COMP_TYPE.$BEXT -comp $COMP_TYPE -b 1024K -always-use-fragments -noappend || exit + fi + else + echo -e "${MAGENTA}$MODULE_UPPER_DIR${ENDCOLOUR} is empty. Nothing to do." + fi + else + echo -e "${RED}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!${ENDCOLOUR}" + echo -e "Please remove ${MAGENTA}$PARENT_DIR/image/$LIVEKITNAME/$MODULE-$COMP_TYPE.$BEXT${ENDCOLOUR} if you want to build ${MAGENTA}$MODULE${ENDCOLOUR}." + echo -e "${RED}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!${ENDCOLOUR}" fi fi @@ -1527,6 +1878,10 @@ function build_modules_chroot() { done } +# ================================================================= +# +# +# ================================================================= function build_modules_live() { current_process echo "here 2" @@ -1559,7 +1914,7 @@ function build_modules_live() { mksquashfs $MODULE_UPPER_DIR $PARENT_DIR/image/$LIVEKITNAME/$MODULE-$COMP_TYPE.$BEXT -comp $COMP_TYPE -b 1024K -always-use-fragments -noappend || exit fi else - echo -e "${MAGENTA}$BUILD_DIR${ENDCOLOUR} is empty. Nothing to do." + echo -e "${MAGENTA}$MODULE_UPPER_DIR${ENDCOLOUR} is empty. Nothing to do." fi fi done diff --git a/linux-live/modules/02-xorg/install b/linux-live/modules/02-xorg/install index 5ef01af..2f187c4 100644 --- a/linux-live/modules/02-xorg/install +++ b/linux-live/modules/02-xorg/install @@ -17,5 +17,5 @@ if [ -f $SCRIPT_DIR/package.list ]; then $(grep -vE "^\s*#" $SCRIPT_DIR/package.list | tr "\n" " ") >>$OUTPUT 2>&1 fi -chown live.users /home/live -chown -R live.users /home/live \ No newline at end of file +chown live:live /home/live +chown -R live:live /home/live \ No newline at end of file diff --git a/linux-live/modules/03-desktop/install b/linux-live/modules/03-desktop/install index 37cd017..1cd7da8 100644 --- a/linux-live/modules/03-desktop/install +++ b/linux-live/modules/03-desktop/install @@ -19,8 +19,7 @@ apt-get install --no-install-recommends --yes \ (cd /rootcopy && cp --parents -afr * /) -chown live.users /home/live -chown -R live.users /home/live/.gtkrc-2.0 -chown -R live.users /home/live/.config - -chown -R live.users /home/live \ No newline at end of file +chown live:live /home/live +#chown -R live:live /home/live/.gtkrc-2.0 +#chown -R live:live /home/live/.config +chown -R live:live /home/live \ No newline at end of file diff --git a/linux-live/modules/04-apps/install b/linux-live/modules/04-apps/install index e4b9f63..b9b4dd1 100644 --- a/linux-live/modules/04-apps/install +++ b/linux-live/modules/04-apps/install @@ -14,5 +14,5 @@ apt-get install --no-install-recommends --yes \ (cd /rootcopy && cp --parents -afr * /) -chown live.users /home/live -chown -R live.users /home/live \ No newline at end of file +chown live:live /home/live +chown -R live:live /home/live \ No newline at end of file