#!/bin/bash # Copyright (C) 2017-2018 Daniel Tartavel-jeannot # Copyright (C) 2019-2020 Jean-Baptiste Biernacki # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . export ARCH=arm64 /usr/bin/chown :shadow /etc/shadow /etc/gshadow /etc/login.defs /etc/pam.d/chage-chfn-chsh /etc/pam.d/chpasswd-newusers /etc/pam.d/system-auth /etc/pam.d/user-group-mod /bin/passwd /bin/chage /usr/bin/chown :systemd-journal -R /var/log/journal # #################################################### # ## To embed a module inside the early boot initrd ## # #################################################### # #Set the list space separated of added modules and omitted modules : # DRIVER_ADD_LIST="sunxi-mmc mmcblk" # DRIVER_OMI_LIST="drm" MODULE_ADD_LIST=" fs-lib" #Create a configuration file inside the FS, it will be used by dracut for all kernel update mkdir -p /etc/dracut.conf.d/ echo -e "# Module to add :\nadd_dracutmodules+=\" ${MODULE_ADD_LIST} \"\n" > /etc/dracut.conf.d/30-kvm.conf #Install all packages you need basesystem grub2-efi efibootmgr chrony polkit lockdev rng-tools man openssh-server rfkill wireless-tools make rsync binutils ldetect usbutils cloud-init #For the wifi : # /sbin/urpmi.update "Nonfree Release" # /sbin/urpmi.update "Nonfree Updates" # --media "Nonfree Release" --media "Nonfree Updates" kernel-firmware-nonfree # grub2-uboot # --noscripts ./grub2-common-2.02.0-16.mga7.armv7hl.rpm ./grub2-efi-2.02.0-16.mga7.armv7hl.rpm ./grub2-mageia-theme-2.02.0-16.mga7.noarch.rpm # --noscripts efibootmgr util-linux /usr/bin/sed -i -e 's/GRUB_CMDLINE_LINUX_DEFAULT="\(.*\)"/GRUB_CMDLINE_LINUX_DEFAULT="\1 audit=0"/' /etc/default/grub # /usr/bin/sed -i -e 's/GRUB_TIMEOUT=.*$/GRUB_TIMEOUT=1/' /etc/default/grub /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg /usr/sbin/grub2-install --skip-fs-probe --target=arm64-efi --removable --no-nvram #For dracut : # mindi-busybox plymouth-scripts #systemd-bootchart libcap-utils keyutils lvm2 #dmsetup # ############################ # ## For compiling a module ## # ############################ # BUG : Make does not like to build inside chroot. It doesn't find tools. Impossible to build any module there. # kernel-source-latest # #See if it is a Server or Desktop kernel : # rpm -q kernel-serveur-latest # if [ 0 -ne ${?} ]; then # K_INST_VERSION=$(rpm -q kernel-desktop-latest | sed -e 's/kernel-\([[:alnum:]]*\)-latest-\([\.[:digit:]]*\)-\([\.[:alnum:]]*\).*$/\2-\1-\3/' ) # else # K_INST_VERSION=$(rpm -q kernel-serveur-latest | sed -e 's/kernel-\([[:alnum:]]*\)-latest-\([\.[:digit:]]*\)-\([\.[:alnum:]]*\).*$/\2-\1-\3/' ) # fi # #Recover the kernel module path : # K_MOD_PATH=$(urpmf "modules/${K_INST_VERSION}$" | cut -d ':' -f 2) # #Recover the source version : # K_SRC_VERSION=$(rpm -q kernel-source-latest | sed -e 's/kernel-source-latest-\([\.[:digit:]]*\)-\([\.[:alnum:]]*\).*$/\1-\2/' ) # #Recover the source path : # K_SRC_PATH=$(urpmf "src/kernel-${K_SRC_VERSION}$" | cut -d ':' -f 2) # #Set the default Mageia's configuration file into the source path : # cp /boot/config-${K_INST_VERSION} ${K_SRC_PATH}/.config # ## Can't go further... Make does not like to build inside chroot. It doesn't find tools. # ## Impossible to build any module there. # ########################### # ## Regenerate the initrd ## # ########################### # #Generate the initrd : # OUTPUT=$(ARCH=arm CROSS_COMPILE=arm-linux-gnu- dracut --no-compress --force --no-hostonly --local --no-early-microcode --confdir "/etc/dracut.conf.d" --kmoddir="/lib/modules/${K_INST_VERSION}" --xz --printsize --kernel-image /boot/vmlinuz --fstab initrd-${K_INST_VERSION}.img ${K_INST_VERSION} 2>&1 | tee /dev/tty ) # dracut --no-compress --force --no-hostonly --local --no-early-microcode --confdir "/etc/dracut.conf.d" --kmoddir="/lib/modules/${K_INST_VERSION}" --xz --printsize --kernel-image /boot/vmlinuz --fstab /boot/initrd-${K_INST_VERSION}.img ${K_INST_VERSION} ########################################### ## Install a package from testing repo : ## ########################################### # urpmi.update Testing # urpmi --auto --media Testing kernel-desktop-latest # dnf --refresh --enablerepo=updates_testing-\* --assumeyes install kernel-desktop-latest ############################################ ## Installing the kernel (not on testing) ## ############################################ # urpmi --auto kernel-desktop-latest # dnf --refresh --assumeyes install kernel-desktop-latest ############################################### ## Create a symlink for the lastest kernel : ## ############################################### ## As long as the first installed kernel remains installed, the boot.scr script will continue to work, even if the extlinux.conf file is not working with uboot anymore. # #Last rpm package : # KERNELRPM=$(rpm -qa --last | grep "^kernel-[sd]e[[:alpha:]]*-[[:digit:]]" | head -n 1 | cut -d ' ' -f 1 | sed -e 's/\(kernel-[[:alnum:]]*-[\.[:digit:]]*-[\.[:alnum:]]*\)-.*/\1/' ) # #Get the vmlinuz file : # VMLINUZ=$(urpmf ${KERNELRPM} | grep "boot/vmlinuz" | cut -d ':' -f 2) #Get the vmlinuz file : # VMLINUZ=$(ls --sort=time -1 /boot/vmlinuz-[[:digit:]]* | head -n 1) # rm -f /boot/uvmlinuz # ln -r -s "${VMLINUZ}" /boot/uvmlinuz #For the uboot script # Normally, /boot/vmlinuz is generated with the /sbin/installkernel script, but it is not generated with chroot. # rm -f /boot/vmlinuz # ln -r -s "${VMLINUZ}" /boot/vmlinuz #For extlinux.conf /usr/bin/chown :chrony -R /etc/chrony.keys /var/log/chrony /usr/bin/chown :daemon /etc/wpa_supplicant.conf /usr/bin/chown :tty /bin/write /bin/wall /usr/bin/chown :lock /sbin/lockdev /usr/bin/chown :bin /sbin/traceroute /usr/bin/chown polkitd /etc/polkit-1/rules.d ## DO NOT EXIT THE SCRIPT. A second part is automatically added in this script during the process in order to create the default user and set root password.