Compare commits
2 Commits
d24327a69e
...
597ececb69
Author | SHA1 | Date |
---|---|---|
BodgeMaster | 597ececb69 | |
BodgeMaster | 0d56e70688 |
|
@ -157,11 +157,13 @@ the chosen mirror from the config file it generates.
|
|||
press_any_key
|
||||
|
||||
xmirror
|
||||
#TODO: also remove CPU architecture
|
||||
TARGET_MIRROR="$(sed 's/repository=//;s|/musl$||' /etc/xbps.d/00-repository-main.conf)"
|
||||
|
||||
#TODO: select installation type
|
||||
TARGET_TYPE="x86_64"
|
||||
|
||||
#TODO: also add CPU architecture
|
||||
if grep "musl" <<< "$TARGET_TYPE"; then
|
||||
TARGET_MIRROR="$TARGET_MIRROR/musl"
|
||||
fi
|
||||
|
@ -283,7 +285,16 @@ chmod 755 /mnt/target/opt/void-usb
|
|||
wget --output-document=/mnt/target/opt/void-usb/grub-config https://lostcave.ddnss.de/git/BodgeMaster/void-minecraft-usb/raw/branch/master/opt/grub-config
|
||||
chmod 744 /mnt/target/opt/void-usb/grub-config
|
||||
|
||||
run_in_target /opt/void-usb/grub-config
|
||||
#TODO: ensure that this is being run by xbps-reconfigure -fa, if not add it here
|
||||
# run_in_target /opt/void-usb/grub-config
|
||||
|
||||
wget --output-document=/mnt/target/etc/kernel.d/pre-install/99-void-usb https://lostcave.ddnss.de/git/BodgeMaster/void-minecraft-usb/raw/branch/master/kernel.d/pre-install/99-void-usb
|
||||
chmod 744 /mnt/target/kernel.d/pre-install/99-void-usb
|
||||
wget --output-document=/mnt/target/etc/kernel.d/post-install/99-void-usb https://lostcave.ddnss.de/git/BodgeMaster/void-minecraft-usb/raw/branch/master/kernel.d/post-install/99-void-usb
|
||||
chmod 744 /mnt/target/kernel.d/post-install/99-void-usb
|
||||
wget --output-document=/mnt/target/etc/kernel.d/post-remove/99-void-usb https://lostcave.ddnss.de/git/BodgeMaster/void-minecraft-usb/raw/branch/master/kernel.d/post-remove/99-void-usb
|
||||
chmod 744 /mnt/target/kernel.d/post-remove/99-void-usb
|
||||
|
||||
run_in_target xbps-reconfigure -fa
|
||||
|
||||
#
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Kernel post-install hook for Void-USB
|
||||
# This script generates the symlinks for default /boot/{vmlinuz,initramfs}.
|
||||
# It also re-generates the GRUB config.
|
||||
#
|
||||
# Arguments: $1 package name, $2 kernel version
|
||||
|
||||
PKGNAME="$1"
|
||||
VERSION="$2"
|
||||
|
||||
echo "Updating default kernel and initramfs symlinks..."
|
||||
|
||||
#####################
|
||||
# Delete old symlinks
|
||||
#####################
|
||||
OLD_LINUX=/boot/vmlinu?
|
||||
if [ ! -f "$OLD_LINUX" ]; then
|
||||
# in cases where it’s a .gz or .xz or whatever
|
||||
OLD_LINUX=$(find /boot -type l -name "vmlinu*" 2>/dev/null | sort | head -n1)
|
||||
fi
|
||||
[ -f "$OLD_LINUX" ] && rm "$OLD_LINUX"
|
||||
|
||||
OLD_INITRAMFS=/boot/initramfs.img
|
||||
if [ ! -f "$OLD_INITRAMFS" ]; then
|
||||
# hope to find anything named initramfs or initrd
|
||||
OLD_INITRAMFS=$(find /boot -type l -name "init*" 2>/dev/null | sort | head -n1)
|
||||
fi
|
||||
[ -f "$OLD_INITRAMFS" ] && rm "$OLD_INITRAMFS"
|
||||
|
||||
#####################
|
||||
# Create new symlinks
|
||||
#####################
|
||||
NEW_LINUX_FILE="$(find /boot -name "*$VERSION*" 2>/dev/null | sed 's|^/boot/||' | grep -e '^vmlinu' -e '^linux' -e '^linuz' -e '^kernel')"
|
||||
NEW_LINUX_SYMLINK="vmlinuz"
|
||||
if grep -e '^vmlinux' -e '^linux' -e '^kernel' >/dev/null 2>&1 <<< "$NEW_LINUX_FILE"; then
|
||||
NEW_LINUX_SYMLINK="vmlinux"
|
||||
fi
|
||||
if grep -e ".gz$" -e ".xz$" -e ".bz$" -e ".bz2$" -e ".lzma$" -e ".lz$" -e ".img$" >/dev/null 2>&1 <<< "$NEW_LINUX_FILE"; then
|
||||
NEW_LINUX_SYMLINK="$NEW_LINUX_SYMLINK$(grep -o -e ".gz$" -e ".xz$" -e ".bz$" -e ".bz2$" -e ".lzma$" -e ".lz$" -e ".img$" 2>/dev/null <<< "$NEW_LINUX_FILE")"
|
||||
fi
|
||||
ln -s "$NEW_LINUX_FILE" "/boot/$NEW_LINUX_SYMLINK"
|
||||
|
||||
NEW_INITRAMFS_FILE="$(find /boot -name "init*$VERSION*" 2>/dev/null | sed 's|^/boot/||')"
|
||||
NEW_INITRAMFS_SYMLINK="initramfs"
|
||||
if grep '^initrd' >/dev/null 2>&1 <<< "$NEW_INITRAMFS_FILE"; then
|
||||
NEW_INITRAMFS_SYMLINK="initrd"
|
||||
fi
|
||||
if grep -e ".gz$" -e ".xz$" -e ".bz$" -e ".bz2$" -e ".lzma$" -e ".lz$" -e ".img$" >/dev/null 2>&1 <<< "$NEW_INITRAMFS_FILE"; then
|
||||
NEW_INITRAMFS_SYMLINK="$NEW_INITRAMFS_SYMLINK$(grep -o -e ".gz$" -e ".xz$" -e ".bz$" -e ".bz2$" -e ".lzma$" -e ".lz$" -e ".img$" 2>/dev/null <<< "$NEW_INITRAMFS_FILE")"
|
||||
fi
|
||||
ln -s "$NEW_INITRAMFS_FILE" "/boot/$NEW_INITRAMFS_SYMLINK"
|
||||
|
||||
echo "Default kernel and initramfs are now: $NEW_LINUX_FILE, $NEW_INITRAMFS_FILE"
|
||||
|
||||
####################
|
||||
# Update GRUB config
|
||||
####################
|
||||
/opt/void-usb/grub-config
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Kernel post-remove hook for Void-USB
|
||||
# This script regenerates the GRUB config.
|
||||
#
|
||||
# Arguments: $1 package name, $2 kernel version
|
||||
PKGNAME="$1"
|
||||
VERSION="$2"
|
||||
|
||||
/opt/void-usb/grub-config
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Kernel pre-install hook for Void-USB
|
||||
# This script removes old kernels when disk space is low.
|
||||
#
|
||||
# Arguments: $1 package name, $2 kernel version
|
||||
PKGNAME="$1"
|
||||
VERSION="$2"
|
||||
|
||||
MB_LOW=250
|
||||
MB_FREE="$(df --block-size=1M --output=avail /boot | tail -n1)"
|
||||
|
||||
if [ "$MB_FREE" -lt "$MB_LOW" ]; then
|
||||
echo
|
||||
OLDEST_KERNEL="$(vkpurge list | sort | head -n1)"
|
||||
if [ -z "$OLDEST_KERNEL" ]; then
|
||||
echo -e "\033[31m================================================\n\033[33mWARNING:\033[0m Failed to find an old kernel to remove.\nThe /boot partition is running out of space.\nThis will become an issue if left unaddressed.\n\033[31m================================================\033[0m"
|
||||
else
|
||||
echo "Removing old kernel $OLDEST_KERNEL using vkpurge..."
|
||||
vkpurge rm "$OLDEST_KERNEL"
|
||||
fi
|
||||
else
|
||||
echo "Not doing anything, /boot has plenty of space."
|
||||
fi
|
|
@ -22,12 +22,12 @@ function make_menuentry {
|
|||
# $1 is the kernel path
|
||||
|
||||
# We don’t want duplicate entries for /boot/vmlinuz symlink
|
||||
if [ -L $1 ]; then
|
||||
if [ -L "$1" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# exclude garbage globbing results
|
||||
if [ ! -f $1 ]; then
|
||||
if [ ! -f "$1" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue