mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-20 03:50:37 +02:00
reformat code
This commit is contained in:
parent
692695068c
commit
5f46086c61
6 changed files with 61 additions and 31 deletions
|
@ -14,7 +14,9 @@ _GRUB_ISO="/usr/share/archboot/grub/archboot-iso-grub.cfg"
|
|||
|
||||
_grub_mkstandalone() {
|
||||
#shellcheck disable=SC2086
|
||||
${1} ${2} grub-mkstandalone -d "/usr/lib/grub/${_GRUB_ARCH}" -O "${_GRUB_ARCH}" --sbat=/usr/share/grub/sbat.csv --fonts=ter-u16n --locales="" --themes="" -o "grub-efi/${_GRUB_EFI}" "boot/grub/grub.cfg=${_GRUB_ISO}"
|
||||
${1} ${2} grub-mkstandalone -d "/usr/lib/grub/${_GRUB_ARCH}" -O "${_GRUB_ARCH}" \
|
||||
--sbat=/usr/share/grub/sbat.csv --fonts=ter-u16n --locales="" --themes="" \
|
||||
-o "grub-efi/${_GRUB_EFI}" "boot/grub/grub.cfg=${_GRUB_ISO}"
|
||||
}
|
||||
|
||||
_prepare_shim_files () {
|
||||
|
|
|
@ -67,10 +67,14 @@ _clean_container() {
|
|||
rm -r "${1}"/usr/share/{aclocal,applications,audit,awk,common-lisp,emacs,et,fish,gdb,gettext,gettext-[0-9]*,glib-[0-9]*,gnupg,gtk-doc,iana-etc,icons,icu,keyutils,libalpm,libgpg-error,makepkg-template,misc,pixmaps,pkgconfig,screen,smartmontools,ss,tabset,vala,xml,man,doc,info,xtables}
|
||||
rm -r "${1}"/usr/lib/{audit,awk,binfmt.d,cmake,dracut,e2fsprogs,environment.d,gawk,getconf,gettext,girepository-[0-9]*,glib-[0-9]*,gnupg,gssproxy,icu,krb5,ldscripts,libnl,pkgconfig,sasl2,siconv,tar,xfsprogs,xtables}
|
||||
# locale cleaning
|
||||
find "${1}"/usr/share/locale/ -mindepth 2 ! -path '*/be/*' ! -path '*/bg/*' ! -path '*/cs/*' ! -path '*/da/*' ! -path '*/de/*' \
|
||||
! -path '*/en/*' ! -path '*/el/*' ! -path '*/es/*' ! -path '*/fi/*' ! -path '*/fr/*' ! -path '*/hu/*' ! -path '*/it/*' \
|
||||
! -path '*/lt/*' ! -path '*/lv/*' ! -path '*/mk/*' ! -path '*/nl/*' ! -path '*/nn/*' ! -path '*/pl/*' ! -path '*/pt/*' \
|
||||
! -path '*/ro/*' ! -path '*/ru/*' ! -path '*/sk/*' ! -path '*/sr/*' ! -path '*/sv/*' ! -path '*/tr/*' ! -path '*/uk/*' -delete &>"${_NO_LOG}"
|
||||
find "${1}"/usr/share/locale/ -mindepth 2 ! -path '*/be/*' ! -path '*/bg/*' \
|
||||
! -path '*/cs/*' ! -path '*/da/*' ! -path '*/de/*' ! -path '*/en/*' \
|
||||
! -path '*/el/*' ! -path '*/es/*' ! -path '*/fi/*' ! -path '*/fr/*' \
|
||||
! -path '*/hu/*' ! -path '*/it/*' ! -path '*/lt/*' ! -path '*/lv/*' \
|
||||
! -path '*/mk/*' ! -path '*/nl/*' ! -path '*/nn/*' ! -path '*/pl/*' \
|
||||
! -path '*/pt/*' ! -path '*/ro/*' ! -path '*/ru/*' ! -path '*/sk/*' \
|
||||
! -path '*/sr/*' ! -path '*/sv/*' ! -path '*/tr/*' ! -path '*/uk/*' \
|
||||
-delete &>"${_NO_LOG}"
|
||||
find "${1}"/usr/share/i18n/charmaps ! -name 'UTF-8.gz' -delete &>"${_NO_LOG}"
|
||||
fi
|
||||
}
|
||||
|
@ -149,22 +153,26 @@ _install_base_packages() {
|
|||
echo "Downloading ${_KEYRING} ${_PACKAGES} to ${1}..."
|
||||
if grep -q 'archboot' /etc/hostname; then
|
||||
#shellcheck disable=SC2086
|
||||
${_PACMAN} -Syw ${_KEYRING} ${_PACKAGES} ${_PACMAN_DEFAULTS} ${_PACMAN_DB} &>"${_LOG}" || exit 1
|
||||
${_PACMAN} -Syw ${_KEYRING} ${_PACKAGES} ${_PACMAN_DEFAULTS} \
|
||||
${_PACMAN_DB} &>"${_LOG}" || exit 1
|
||||
else
|
||||
#shellcheck disable=SC2086
|
||||
${_PACMAN} -Syw ${_KEYRING} ${_PACKAGES} ${_PACMAN_DEFAULTS} ${_PACMAN_DB} &>"${_NO_LOG}" || exit 1
|
||||
${_PACMAN} -Syw ${_KEYRING} ${_PACKAGES} ${_PACMAN_DEFAULTS} \
|
||||
${_PACMAN_DB} &>"${_NO_LOG}" || exit 1
|
||||
fi
|
||||
fi
|
||||
echo "Installing ${_KEYRING} ${_PACKAGES} to ${1}..."
|
||||
if grep -q 'archboot' /etc/hostname; then
|
||||
#shellcheck disable=SC2086
|
||||
${_PACMAN} -Sy --assume-installed ${_MKINITCPIO} ${_KEYRING} ${_PACKAGES} ${_PACMAN_DEFAULTS} &>"${_LOG}" || exit 1
|
||||
${_PACMAN} -Sy --assume-installed ${_MKINITCPIO} ${_KEYRING} ${_PACKAGES} \
|
||||
${_PACMAN_DEFAULTS} &>"${_LOG}" || exit 1
|
||||
echo "Downloading mkinitcpio to ${1}..."
|
||||
#shellcheck disable=SC2086
|
||||
${_PACMAN} -Syw mkinitcpio ${_PACMAN_DEFAULTS} >"${_LOG}" 2>&1 || exit 1
|
||||
else
|
||||
#shellcheck disable=SC2086
|
||||
${_PACMAN} -Sy --assume-installed ${_MKINITCPIO} ${_KEYRING} ${_PACKAGES} ${_PACMAN_DEFAULTS} &>"${_NO_LOG}" || exit 1
|
||||
${_PACMAN} -Sy --assume-installed ${_MKINITCPIO} ${_KEYRING} ${_PACKAGES} \
|
||||
${_PACMAN_DEFAULTS} &>"${_NO_LOG}" || exit 1
|
||||
echo "Downloading mkinitcpio to ${1}..."
|
||||
#shellcheck disable=SC2086
|
||||
${_PACMAN} -Syw mkinitcpio ${_PACMAN_DEFAULTS} >"${_NO_LOG}" 2>&1 || exit 1
|
||||
|
@ -183,13 +191,15 @@ _install_archboot() {
|
|||
${_PACMAN} -Sy ${_ARCHBOOT} ${_PACMAN_DEFAULTS} &>"${_LOG}" || exit 1
|
||||
echo "Downloading ${_MAN_INFO_PACKAGES} to ${1}..."
|
||||
#shellcheck disable=SC2086
|
||||
${_PACMAN} -Syw ${_MAN_INFO_PACKAGES} ${_PACMAN_DEFAULTS} ${_PACMAN_DB} &>"${_LOG}" || exit 1
|
||||
${_PACMAN} -Syw ${_MAN_INFO_PACKAGES} ${_PACMAN_DEFAULTS} \
|
||||
${_PACMAN_DB} &>"${_LOG}" || exit 1
|
||||
else
|
||||
#shellcheck disable=SC2086
|
||||
${_PACMAN} -Sy ${_ARCHBOOT} ${_PACMAN_DEFAULTS} &>"${_NO_LOG}" || exit 1
|
||||
echo "Downloading ${_MAN_INFO_PACKAGES} to ${1}..."
|
||||
#shellcheck disable=SC2086
|
||||
${_PACMAN} -Syw ${_MAN_INFO_PACKAGES} ${_PACMAN_DEFAULTS} ${_PACMAN_DB} &>"${_NO_LOG}" || exit 1
|
||||
${_PACMAN} -Syw ${_MAN_INFO_PACKAGES} ${_PACMAN_DEFAULTS} \
|
||||
${_PACMAN_DB} &>"${_NO_LOG}" || exit 1
|
||||
fi
|
||||
# cleanup
|
||||
if ! [[ "${2}" == "use_binfmt" ]]; then
|
||||
|
|
|
@ -74,7 +74,8 @@ _prepare_kernel_initrd_files() {
|
|||
cp "./init-${_ARCH}.img" "${_ISODIR}/boot/"
|
||||
else
|
||||
echo "Running archboot-cpio.sh for init-${_ARCH}.img..."
|
||||
archboot-cpio.sh -c "/etc/archboot/${_ARCH}-init.conf" -k "${_KERNEL}" -g "${_ISODIR}/boot/init-${_ARCH}.img" || exit 1
|
||||
archboot-cpio.sh -c "/etc/archboot/${_ARCH}-init.conf" -k "${_KERNEL}" \
|
||||
-g "${_ISODIR}/boot/init-${_ARCH}.img" || exit 1
|
||||
# save init ramdisk for further images
|
||||
if [[ -n "${_SAVE_INIT}" ]]; then
|
||||
cp "${_ISODIR}/boot/init-${_ARCH}.img" ./
|
||||
|
@ -90,7 +91,8 @@ _prepare_kernel_initrd_files() {
|
|||
if ! [[ -f "${_ISODIR}/boot/initrd-${_ARCH}.img" ]]; then
|
||||
echo "Running archboot-cpio.sh for initrd-${_ARCH}.img..."
|
||||
#shellcheck disable=SC2154
|
||||
archboot-cpio.sh -c "${_CONFIG}" -k "${_KERNEL}" -g "${_ISODIR}/boot/initrd-${_ARCH}.img" || exit 1
|
||||
archboot-cpio.sh -c "${_CONFIG}" -k "${_KERNEL}" \
|
||||
-g "${_ISODIR}/boot/initrd-${_ARCH}.img" || exit 1
|
||||
fi
|
||||
# delete cachedir on archboot environment
|
||||
if grep -qw 'archboot' /etc/hostname; then
|
||||
|
@ -253,7 +255,13 @@ _grub_mkrescue() {
|
|||
[[ "${_ARCH}" == "x86_64" ]] && _RESCUE_REMOVE="mach_kernel /System /boot/grub/i386-efi /boot/grub/x86_64-efi"
|
||||
[[ "${_ARCH}" == "aarch64" ]] && _RESCUE_REMOVE="/boot/grub/arm64-efi"
|
||||
#shellcheck disable=SC2086
|
||||
grub-mkrescue --set_all_file_dates 'Jan 1 00:00:00 UTC 1970' --modification-date=1970010100000000 --compress=xz --fonts="ter-u16n" --locales="" --themes="" -o "${_IMAGENAME}.iso" "${_ISODIR}"/ "boot/grub/archboot-main-grub.cfg=${_GRUB_CONFIG}" "boot/grub/grub.cfg=/usr/share/archboot/grub/archboot-iso-grub.cfg" -volid "ARCHBOOT" -- -rm_r /boot/grub/{roms,locale} /efi .disk/ ${_RESCUE_REMOVE} &> "${_IMAGENAME}.log"
|
||||
grub-mkrescue --set_all_file_dates 'Jan 1 00:00:00 UTC 1970' \
|
||||
--modification-date=1970010100000000 --compress=xz --fonts="ter-u16n" \
|
||||
--locales="" --themes="" -o "${_IMAGENAME}.iso" "${_ISODIR}"/ \
|
||||
"boot/grub/archboot-main-grub.cfg=${_GRUB_CONFIG}" \
|
||||
"boot/grub/grub.cfg=/usr/share/archboot/grub/archboot-iso-grub.cfg" \
|
||||
-volid "ARCHBOOT" -- -rm_r /boot/grub/{roms,locale} /efi .disk/ \
|
||||
${_RESCUE_REMOVE} &> "${_IMAGENAME}.log"
|
||||
}
|
||||
|
||||
_unify_gpt_partitions() {
|
||||
|
@ -268,7 +276,8 @@ _unify_gpt_partitions() {
|
|||
echo "Creating reproducible GUID, UUIDs, hide partitions, disable automount and move main table sector on ISO GPT..."
|
||||
sgdisk -j 2 -U 00000000-0000-0000-0000-0000-000000000000 "${_IMAGENAME}.iso" &>"${_NO_LOG}"
|
||||
for i in 1 2 3 4; do
|
||||
sgdisk -A ${i}:set:62 -A ${i}:set:63 -u ${i}:${i}0000000-0000-0000-0000-0000-000000000000 "${_IMAGENAME}.iso" &>"${_NO_LOG}"
|
||||
sgdisk -A ${i}:set:62 -A ${i}:set:63 -u ${i}:${i}0000000-0000-0000-0000-0000-000000000000 \
|
||||
"${_IMAGENAME}.iso" &>"${_NO_LOG}"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,13 @@ _local_mode () {
|
|||
fi
|
||||
}
|
||||
|
||||
_memory_error () {
|
||||
echo -e "\e[1m\e[91mMemory check failed:\e[m"
|
||||
echo -e "\e[91m- Not engough memory detected! \e[m"
|
||||
echo -e "\e[93m- Please add \e[1mmore\e[m\e[93m than \e[1m${1}\e[m\e[93m RAM.\e[m"
|
||||
echo -e "\e[91mAborting...\e[m"
|
||||
}
|
||||
|
||||
# use -o discard for RAM cleaning on delete
|
||||
# (online fstrimming the block device!)
|
||||
# fstrim <mountpoint> for manual action
|
||||
|
@ -40,7 +47,8 @@ if [[ "${TTY}" = "tty1" ]]; then
|
|||
mv /lib/firmware/regulatory* /tmp/ &>"${_NO_LOG}"
|
||||
rm -rf /lib/firmware/*
|
||||
mv /tmp/regulatory* /lib/firmware/ &>"${_NO_LOG}"
|
||||
rm -rf /lib/modules/*/kernel/drivers/{acpi,ata,gpu,bcma,block,bluetooth,hid,input,platform,net,scsi,soc,spi,usb,video}
|
||||
rm -rf /lib/modules/*/kernel/drivers/{acpi,ata,gpu,bcma,block,bluetooth,hid,input,\
|
||||
platform,net,scsi,soc,spi,usb,video}
|
||||
rm -rf /lib/modules/*/extramodules
|
||||
: > /.archboot
|
||||
(tar -C / --exclude="./dev/*" --exclude="./proc/*" --exclude="./sys/*" \
|
||||
|
@ -164,19 +172,13 @@ if [[ -e /usr/bin/setup ]]; then
|
|||
# latest image, fail if less than 2GB RAM available
|
||||
elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 1970000 ]]; then
|
||||
_welcome
|
||||
echo -e "\e[1m\e[91mMemory check failed:\e[m"
|
||||
echo -e "\e[91m- Not engough memory detected! \e[m"
|
||||
echo -e "\e[93m- Please add \e[1mmore\e[m\e[93m than \e[1m2.0GB\e[m\e[93m RAM.\e[m"
|
||||
echo -e "\e[91mAborting...\e[m"
|
||||
_memory_error "2.0GB"
|
||||
_enter_shell
|
||||
# local image, fail if less than 3.3GB RAM available
|
||||
elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 2571000 &&\
|
||||
-e "${_LOCAL_DB}" ]]; then
|
||||
_welcome
|
||||
echo -e "\e[1m\e[91mMemory check failed:\e[m"
|
||||
echo -e "\e[91m- Not engough memory detected! \e[m"
|
||||
echo -e "\e[93m- Please add \e[1mmore\e[m\e[93m than \e[1m2.6GB\e[m\e[93m RAM.\e[m"
|
||||
echo -e "\e[91mAborting...\e[m"
|
||||
_memory_error "2.6GB"
|
||||
_enter_shell
|
||||
else
|
||||
_welcome
|
||||
|
|
|
@ -194,14 +194,20 @@ _create_iso() {
|
|||
echo "Tobias Powalowski <tpowa@archlinux.org>"
|
||||
echo ""
|
||||
echo "Requirement: ${_ARCH} with 700M RAM and higher"
|
||||
echo "Archboot:$(${_NSPAWN} "${_W_DIR}" pacman -Qi "${_ARCHBOOT}" | grep Version | cut -d ":" -f2 | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g")"
|
||||
[[ "${_ARCH}" == "riscv64" ]] || echo "Grub: $(${_NSPAWN} "${_W_DIR}" pacman -Qi grub | grep Version | cut -d ":" -f3 | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g")"
|
||||
echo "Linux:$(${_NSPAWN} "${_W_DIR}" pacman -Qi linux | grep Version | cut -d ":" -f2 | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g")"
|
||||
echo "Pacman:$(${_NSPAWN} "${_W_DIR}" pacman -Qi pacman | grep Version | cut -d ":" -f2 | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g")"
|
||||
echo "Systemd:$(${_NSPAWN} "${_W_DIR}" pacman -Qi systemd | grep Version | cut -d ":" -f2 | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g")"
|
||||
echo "Archboot:$(${_NSPAWN} "${_W_DIR}" pacman -Qi "${_ARCHBOOT}" | grep Version |\
|
||||
cut -d ":" -f2 | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g")"
|
||||
[[ "${_ARCH}" == "riscv64" ]] || echo "Grub: $(${_NSPAWN} "${_W_DIR}" pacman -Qi grub |\
|
||||
grep Version | cut -d ":" -f3 | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g")"
|
||||
echo "Linux:$(${_NSPAWN} "${_W_DIR}" pacman -Qi linux | grep Version |\
|
||||
cut -d ":" -f2 | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g")"
|
||||
echo "Pacman:$(${_NSPAWN} "${_W_DIR}" pacman -Qi pacman | grep Version |\
|
||||
cut -d ":" -f2 | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g")"
|
||||
echo "Systemd:$(${_NSPAWN} "${_W_DIR}" pacman -Qi systemd | grep Version |\
|
||||
cut -d ":" -f2 | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g")"
|
||||
echo ""
|
||||
echo "---Complete Package List---"
|
||||
${_NSPAWN} "${_W_DIR}" pacman -Q | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g" -e "s/\x1b\[.*[0-9][h;l]//g") >>Release.txt
|
||||
${_NSPAWN} "${_W_DIR}" pacman -Q | sed -e "s/\r//g" -e "s/\x1b\[[0-9;]*m//g" \
|
||||
-e "s/\x1b\[.*[0-9][h;l]//g") >>Release.txt
|
||||
# removing container
|
||||
echo "Removing container ${_W_DIR}..."
|
||||
rm -r "${_W_DIR}"
|
||||
|
|
|
@ -33,7 +33,8 @@ _update_pacman_chroot() {
|
|||
# update container to latest packages
|
||||
echo "Updating container to latest packages..."
|
||||
# fix mirrorlist
|
||||
[[ "${_ARCH}" == "riscv64" ]] && sed -i -e 's|^#Server = https://riscv|Server = https://riscv|g' "${_ARCH_DIR}"/etc/pacman.d/mirrorlist
|
||||
[[ "${_ARCH}" == "riscv64" ]] && sed -i -e 's|^#Server = https://riscv|Server = https://riscv|g' \
|
||||
"${_ARCH_DIR}"/etc/pacman.d/mirrorlist
|
||||
${_NSPAWN} "${_ARCH_DIR}" pacman -Syu --noconfirm &>"${_NO_LOG}" || exit 1
|
||||
_fix_network "${_ARCH_DIR}"
|
||||
_CLEANUP_CONTAINER="1" _clean_container "${_ARCH_DIR}" &>"${_NO_LOG}"
|
||||
|
|
Loading…
Reference in a new issue