#!/usr/bin/env bash

# Update changes
function _5_2_2_2_changes() {
    echo ":: Update 5.2.2-2: A new command line option was added: add page_alloc.shuffle=1"
}

function _5_2_9_6_changes() {
    echo ":: Update 5.2.9-6: Microcode is no longer builtin. See https://wiki.archlinux.org/index.php/Microcode"
}


# Clear Linux patchset fork CTA
function print_deprecation_notice() {
    echo ":: DEPRECATION NOTICE"
    echo ""
    echo "   This package is now deprecated due to the recent Clear Linux patchset fork.
    echo "   The new package is named \"linux-tachyon\", please install it instead."
    echo ""
    echo "   Thank you for using this package!"
}


# Standard methods
function post_upgrade() {
    local version upgrades=(
        "5.2.2-2"
        "5.2.9-6"
    )
    
    for version in "${upgrades[@]}"; do
        if [[ "$(vercmp "${version}" "$2")" -eq "1" ]]; then
            "_${version//[.-]/_}_changes"
        fi
    done
    
    # Print the fork CTA
    print_deprecation_notice
}

function post_install() {
    echo ":: Tachyon Linux provides the following recommended command line:"
    echo "   quiet console=tty0 console=ttyS0,115200n8 cryptomgr.notests initcall_debug"
    echo "   intel_iommu=igfx_off kvm-intel.nested=1 no_timer_check noreplace-smp"
    echo "   page_alloc.shuffle=1 rcupdate.rcu_expedited=1"
    echo "   rootfstype=ext4,btrfs,xfs,f2fs tsc=reliable rw"
    
    # Print the fork CTA
    print_deprecation_notice
}
