From e19e2856285715d2895ee53e7d4dbe347bf1c633 Mon Sep 17 00:00:00 2001 From: aerth Date: Mon, 7 Apr 2025 03:29:54 +0000 Subject: [PATCH 1/2] add package installer menu for first-boot --- .../local/sbin/9999-aerthos-bootpackages.bash | 70 ++++++++++++++----- .../var/lib/aerthos/package-list-huge.txt | 3 + 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/config/includes.chroot/usr/local/sbin/9999-aerthos-bootpackages.bash b/config/includes.chroot/usr/local/sbin/9999-aerthos-bootpackages.bash index 43409dc..2af219b 100755 --- a/config/includes.chroot/usr/local/sbin/9999-aerthos-bootpackages.bash +++ b/config/includes.chroot/usr/local/sbin/9999-aerthos-bootpackages.bash @@ -1,35 +1,71 @@ #!/bin/bash -if [ $(id -u) -ne 0 ]; then - echo "This script must be run as root" - exec sudo "$0" "$@" -fi pkgs=() -for pkg in $(cat /var/lib/aerthos/package-list.txt); do - if [ -z "$pkg" ] || [[ $pkg == \#* ]]; then +test ! -f /var/lib/aerthos/package-list.txt || for pkg in $(cat /var/lib/aerthos/package-list.txt); do + if [ -z "${pkg/# }" ] || [[ $pkg == \#* ]]; then continue fi - if dpkg -L $pkg 1>/dev/null 2>&1; then - echo "Package $pkg already installed" - else - echo "We will install $pkg" + if ! dpkg -L $pkg 1>/dev/null 2>&1; then pkgs+=("$pkg") fi done -for pkg in $(cat /var/lib/aerthos/package-list-huge.txt); do - if [ -z "$pkg" ] || [[ $pkg == \#* ]]; then +test ! -f /var/lib/aerthos/package-list-huge.txt || for pkg in $(cat /var/lib/aerthos/package-list-huge.txt); do + if [ -z "${pkg/# }" ] || [[ $pkg == \#* ]]; then continue fi - if dpkg -L $pkg 1>/dev/null 2>&1; then - echo "Package $pkg already installed" - else - echo "We will install $pkg" + if ! dpkg -L $pkg 1>/dev/null 2>&1; then pkgs+=("$pkg") fi done +if [ ${#pkgs[@]} -eq 0 ]; then + echo "No packages to install" + exit 0 +fi +menupkgs=() +for pkg in "${pkgs[@]}"; do + if [ -z "${pkg/# }" ] || [[ $pkg == \#* ]]; then + continue + fi + # menupkgs+=("$pkg" "$(apt show ${pkg} | grep Installed-Size | awk '{print $2 " " $3}')" "on") + # filesize=$(dpkg-query -W -f="${Installed-Size;8} ${pkg}" "${pkg}" 2>/dev/null) + pkginfo=$(apt show "${pkg}" 2>/dev/null) + if [ $? -ne 0 ]; then + echo "Package $pkg not found" + continue + fi + # Extract the human-readable installed size and synopsis from the package info + filesize=$(echo "$pkginfo" | grep -i "Installed-Size:" | awk '{print $2 $3}') + synopsis=$(echo "$pkginfo" | grep -i "Synopsis:" | cut -d' ' -f2-) + if [ $? -ne 0 ]; then + echo "Package $pkg not found" + continue + fi + menupkgs+=("$pkg" "${filesize} ${synopsis}" "on") +done +echo All packages: "${menupkgs[@]}" +if [ ${#menupkgs[@]} -eq 0 ]; then + echo "No packages to install" + exit 0 +fi +message="Free space: $(df -h / | grep / | awk '{print $4}')\nPersistence: $(test -d /run/live/persistence/* && echo "enabled" || echo "disabled")\n\n" +option=$(dialog --no-clear --checklist "Choose packages to install:\n$message" 0 0 0 "${menupkgs[@]}" 2>&1 1>/dev/tty) +exitstatus=$? +if [ $exitstatus -ne 0 ]; then + echo "Cancel" + exit 0 +fi +if [ -z "$option" ]; then + echo "No packages selected for installation" + exit 0 +fi +pkgs=${option//\"/} +if [ ${#pkgs[@]} -eq 0 ]; then + echo "No packages selected for installation" + exit 0 +fi if [ ${#pkgs[@]} -gt 0 ]; then echo "Installing packages: ${pkgs[@]}" - apt install -y "${pkgs[@]}" | logger -s || true + sudo apt install -y "${pkgs[@]}" | logger -s || true else echo "No new packages to install" fi diff --git a/config/includes.chroot/var/lib/aerthos/package-list-huge.txt b/config/includes.chroot/var/lib/aerthos/package-list-huge.txt index 559c208..099f258 100644 --- a/config/includes.chroot/var/lib/aerthos/package-list-huge.txt +++ b/config/includes.chroot/var/lib/aerthos/package-list-huge.txt @@ -1,3 +1,6 @@ google-chrome-stable code +brave-browser +firefox +thunderbird From c28c1e26703425aa916ae447d074d09bc5305448 Mon Sep 17 00:00:00 2001 From: aerth Date: Mon, 7 Apr 2025 03:47:41 +0000 Subject: [PATCH 2/2] update makeskel --- .../includes.chroot/etc/skel/.makeskel.bash | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/config/includes.chroot/etc/skel/.makeskel.bash b/config/includes.chroot/etc/skel/.makeskel.bash index 9d64131..83d943f 100755 --- a/config/includes.chroot/etc/skel/.makeskel.bash +++ b/config/includes.chroot/etc/skel/.makeskel.bash @@ -3,6 +3,11 @@ # Copyright (c) 2025 aerth # This file is part of the aerthOS project (https://aerth.github.io/aerthOS) +test ! -e ~/.config/aerthos/setup.txt || { + echo "Error: ~/.config/aerthos/setup.txt already exists. If you want to reconfigure, remove it." >&2 + sleep 3 + exit 0 +} _log() { echo "aerthos-makeskel: $@" | tee -a /tmp/aerthos-makeskel.log 1>&2 } @@ -121,7 +126,9 @@ themer() { if [ $? -ne 0 ]; then _log "Failed to set xfce4 dark" fi +} +save_home_for_skel(){ if command -v tree >/dev/null 2>&1; then tree -a ${HOME}/.config ${HOME}/Desktop -L 1 >/tmp/aerthos-home-config.txt || true _log "Created directory listing: /tmp/aerthos-home-config.txt" @@ -162,6 +169,17 @@ do_themer() { } } -do_themer & -xfce4-terminal -x sudo bash -c -x '/usr/local/sbin/9999-aerthos-bootpackages.bash || echo failed; sleep 60' | sudo logger -s -cat /proc/cmdline | grep nodot || (git clone https://gitlab.com/aerth/dot ~/.local/dot) +grep 'color-background-vary' ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-terminal.xml || do_themer +xfce4-terminal --show-borders --title "aerthos Package Installation" -x sudo bash -c -x '/usr/local/sbin/9999-aerthos-bootpackages.bash || (echo package installation failed, you can close this window; sleep 60)' +cat /proc/cmdline | grep nodot || (git clone https://gitlab.com/aerth/dot ~/.local/dot) +mkdir -p ~/.config/aerthos +touch ~/.config/aerthos/setup.txt +echo all done +# for example, nuke home dir and run this for creating /etc/skel config +if "$1" == "save_home" ]; then + save_home_for_skel + if [ $? -ne 0 ]; then + _log "Failed to save home directory" + exit 1 + fi +fi