From 8cdf4a93dd9a0a1e52d5adeb275a468e56b3395d Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Wed, 16 Oct 2024 11:54:06 +0000 Subject: [PATCH] * refs #904 , #960 * Creates Ubuntu chroot for deploy * Set root passw in live cd * Update Network manager in live-cd * Mount and dismount partitions for Calamares * Updates bootloader * Configures mount for deploying with calamares * Creates upackfs to use minimal fs * Updates users.conf file --- builder.sh | 13 +++++++++++ calamares/modules/bootloader.conf | 17 +++++++++++++++ calamares/modules/mount.conf | 19 ++++++++++++++++ calamares/modules/unpackfs.conf | 6 ++++++ calamares/modules/users.conf | 36 +++++++++++++++++++++++++++++++ calamares/settings.conf | 2 ++ chroot_setup.sh | 15 +++++++------ 7 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 calamares/modules/bootloader.conf create mode 100644 calamares/modules/mount.conf create mode 100644 calamares/modules/unpackfs.conf create mode 100644 calamares/modules/users.conf diff --git a/builder.sh b/builder.sh index b483ac2..2f5ddba 100755 --- a/builder.sh +++ b/builder.sh @@ -10,6 +10,7 @@ VARIANT=minbase CLEAN=${CLEAN:-1} CLEAN_CHROOT=${CLEAN_CHROOT:-1} OUTPUT_DIR=/media/sf_Downloads/ +UBUNTU_CHROOT_DIR=$DIR/ubuntu_chroot ## FUNCIONES @@ -99,6 +100,7 @@ umount_in_host $CHROOT_DIR/run # Compress the chroot exec_as_sudo mv chroot/image . + # Create squashfs imagesudo exec_as_sudo mksquashfs $CHROOT_DIR image/casper/filesystem.squashfs \ -noappend -no-duplicates -no-recovery \ @@ -108,6 +110,17 @@ exec_as_sudo mksquashfs $CHROOT_DIR image/casper/filesystem.squashfs \ printf $(exec_as_sudo du -sx --block-size=1 chroot | cut -f1) | sudo tee image/casper/filesystem.size +# Deboot strap real Ubuntu image +exec_as_sudo debootstrap --arch=amd64 --variant=minbase noble $UBUNTU_CHROOT_DIR http://us.archive.ubuntu.com/ubuntu/ +# Compress the ububtu chroot +exec_as_sudo mksquashfs $UBUNTU_CHROOT_DIR image/casper/filesystem.ubuntu.squashfs \ + -noappend -no-duplicates -no-recovery \ + -wildcards \ + -comp xz -b 1M -Xdict-size 100% \ + -e "var/cache/apt/archives/*" -e "root/*" -e "root/.*" -e "tmp/*" -e "tmp/.*" -e "swapfile" + + + # Create ISO image cd image && \ diff --git a/calamares/modules/bootloader.conf b/calamares/modules/bootloader.conf new file mode 100644 index 0000000..a046392 --- /dev/null +++ b/calamares/modules/bootloader.conf @@ -0,0 +1,17 @@ +--- +efiBootLoader: "grub" +kernelSearchPath: "/boot/" +kernelInstallPath: "/boot/" +kernelPattern: "^vmlinuz.*" +loaderEntries: + - "timeout 5" + - "console-mode keep" + +kernelParams: [ "quiet" ] + +grubInstall: "grub-install" +grubMkconfig: "grub-mkconfig" +grubCfg: "/boot/grub/grub.cfg" +grubProbe: "grub-probe" +efiBootMgr: "efibootmgr" + diff --git a/calamares/modules/mount.conf b/calamares/modules/mount.conf new file mode 100644 index 0000000..8493a04 --- /dev/null +++ b/calamares/modules/mount.conf @@ -0,0 +1,19 @@ +--- +extraMounts: + - device: proc + fs: proc + mountPoint: /proc + - device: sys + fs: sysfs + mountPoint: /sys + - device: /dev + mountPoint: /dev + options: bind + - device: tmpfs + fs: tmpfs + mountPoint: /run + - device: /run/dev + mountPoint: /run/dev + options: bind + + diff --git a/calamares/modules/unpackfs.conf b/calamares/modules/unpackfs.conf new file mode 100644 index 0000000..16ff036 --- /dev/null +++ b/calamares/modules/unpackfs.conf @@ -0,0 +1,6 @@ +--- +unpack: + - source: "/cdrom/casper/filesystem.ubuntu.squashfs" + sourcefs: squashfs + destination: "/" + diff --git a/calamares/modules/users.conf b/calamares/modules/users.conf new file mode 100644 index 0000000..612b8e9 --- /dev/null +++ b/calamares/modules/users.conf @@ -0,0 +1,36 @@ +defaultGroups: + - name: users + system: true + - adm: + system: true + - cdrom: + system: true + - sudo: + system: true + - dip: + system: true + - plugdev: + system: true + - lxd: + system: true + +sudoersGroup: sudo +setRootPassword: false +passwordRequirements: + minLength: -1 # Password at least this many characters + maxLength: -1 # Password at most this many characters + libpwquality: + - minlen=0 + - minclass=0 + +user: + shell: /bin/bash + forbidden_names: [ root ] + home_permissions: "0700" + +hostname: + location: EtcFile + writeHostsFile: true + template: "derp-${cpu}" + forbidden_names: [ localhost ] + diff --git a/calamares/settings.conf b/calamares/settings.conf index d079132..bf6a74c 100644 --- a/calamares/settings.conf +++ b/calamares/settings.conf @@ -14,10 +14,12 @@ sequence: - summary - exec: - partition + - mount - machineid - locale - keyboard - users + - umount - bootloader - show: - finished diff --git a/chroot_setup.sh b/chroot_setup.sh index ace5587..05ddbf3 100644 --- a/chroot_setup.sh +++ b/chroot_setup.sh @@ -5,6 +5,10 @@ set -e export HOME=/root export LC_ALL=C +function set_root_passwd(){ + echo "root:root" | chpasswd +} + function setup_sources_list () { echo "Setting up sources.list" cat < $CHROOT_DIR/etc/apt/sources.list @@ -86,18 +90,16 @@ function reconfigure_network_manager() { mkdir -p /etc/NetworkManager cat < /etc/NetworkManager/NetworkManager.conf [main] -rc-manager=none -plugins=ifupdown,keyfile -dns=systemd-resolved +plugins=keyfile -[ifupdown] -managed=false +[keyfile] +unmanaged-devices=none EOF mkdir -p /etc/NetworkManager/system-connections/ cat < /etc/NetworkManager/system-connections/dhcp-all.nmconnection [connection] -id=Auto DHCP +id=Cable type=ethernet autoconnect=true @@ -262,6 +264,7 @@ install_mesa_repo install_packages sudo ubuntu-standard sudo casper dbus-bin mesa-utils mesa-vulkan-drivers discover isc-dhcp-client laptop-detect unzip os-prober network-manager net-tools wireless-tools wpagui locales grub-common grub-gfxpayload-lists grub-pc grub-pc-bin grub2-common grub-efi-amd64-signed shim-signed mtools binutils virtualbox-guest-utils virtualbox-guest-x11 install_non_interactive xorg xinit openbox lightdm plymouth calamares install_no_recommends linux-image-generic +set_root_passwd configure_divert configure_lightdm autostart_calamares