kernel/kernel.sh

863 lines
32 KiB
Bash
Raw Normal View History

2023-11-22 09:24:46 +00:00
#!/bin/bash
UPDATED="2023-11-22"
doBuildSystem() {
echo "v$UPDATED"
}
# Display introduction
doIntro() {
echo
echo "Debian Kernel Builder: $HOSTNAME"
doBuildSystem
echo
}
# Show date/time header
doHeader() {
NOW=`date +"%Y/%m/%d %H:%M:%S"`
echo "- $NOW"
echo ""
}
if [ "$(id -u)" != "0" ]; then
doIntro
doHeader
echo
echo "This script must be run as root" 1>&2
echo
exit 1
fi
KERNEL=/opt/kernel
WORK=/opt/work
BACKUPS=/opt/backups
LOGNAME=kernel
LOGEXT=log
LOGFILE=""
HOSTNAME=$(hostname)
SELF=$(realpath $0)
SCRIPT=$(basename $SELF)
CWD=$(dirname $SELF)
CURRENT=$CWD
BRANCH=$1
BRANCH="${BRANCH:=help}"
VERSION=$2
VERSION="${VERSION:=help}"
STEPS=$3
STEPS="${STEPS:=help}"
WORKDIR=""
cd $CURRENT
# Force sync & flush
doSync() {
sync
echo 3 > /proc/sys/vm/drop_caches
}
doHead() {
doIntro
doHeader
}
# Display help
doHelp() {
doIntro
doHeader
if [ $BRANCH != "help" ]; then
echo ">>> Unspecified, unknown or invalid option specified !"
echo
fi
echo "Usage: $SCRIPT 'branch' 'version'"
echo
echo "branch : Main branch (eg. 6.x)"
echo "version: Full version tag (eg. 6.6.1)"
echo
}
doEchoStep() {
NOW=`date +"%Y/%m/%d %H:%M:%S"`
echo "### $NOW - $1"
}
# Download
doDownload() {
if [ -d $WORKDIR ]; then
doEchoStep "$BRANCH/$VERSION already present (don't download)"
else
mkdir -p $WORKDIR
cd $WORKDIR
doEchoStep "Download branch '$BRANCH' version '$VERSION'"
wget --inet4-only https://cdn.kernel.org/pub/linux/kernel/v$BRANCH/linux-$VERSION.tar.sign
wget --inet4-only https://cdn.kernel.org/pub/linux/kernel/v$BRANCH/linux-$VERSION.tar.xz
doSync
result=$?
if [ ! result==0 ]; then
echo ">>> Error in download !"
exit 1
fi
fi
}
# Uncompress
doUncompress() {
cd $WORKDIR
doEchoStep "Uncompress"
rm -rf linux-$VERSION
tar -xaf linux-$VERSION.tar.xz
result=$?
if [ ! result==0 ]; then
echo ">>> Error in uncompress !"
exit 1
fi
doSync
}
# Clean folder
doCleanup() {
cd $WORKDIR
doEchoStep "Cleanup"
make -j$(nproc) CC="ccache gcc" mrproper
result=$?
if [ ! result==0 ]; then
echo ">>> Error in cleanup !"
exit 1
fi
}
# Clean folder
doOldOne() {
cd $WORKDIR
doEchoStep "Generate config from old (current) kernel .config"
make -j$(nproc) CC="ccache gcc" olddefconfig
result=$?
if [ ! result==0 ]; then
echo ">>> Error in generate .config !"
exit 1
fi
cp .config .config.2.olddefconfig
}
# Define all modules not included in kernel
doAllMods() {
cd $WORKDIR
doEchoStep "Set all modules to be 'module'"
make -j$(nproc) CC="ccache gcc" allmodconfig
result=$?
if [ ! result==0 ]; then
echo ">>> Error in set all modules not in kernel !"
exit 1
fi
cp .config .config.3.allmodconfig
}
# Define permissions (user/group) to first user created (default 1000)
doPermissions() {
cd $WORKDIR
doEchoStep "Define user/group"
chown -R 1000:1000 $CURRENT/$BRANCH/$VERSION/.
result=$?
if [ ! result==0 ]; then
echo ">>> Error in chown !"
exit 1
fi
doSync
}
# Strip signature
doStripSig() {
cd $WORKDIR
doEchoStep "Remove signature/keys"
./scripts/config --disable MODULE_SIG_ALL
./scripts/config --set-str MODULE_SIG_KEY ""
./scripts/config --set-str SYSTEM_TRUSTED_KEYS ""
./scripts/config --set-str SYSTEM_REVOCATION_KEYS ""
result=$?
if [ ! result==0 ]; then
echo ">>> Error in chown !"
exit 1
fi
cp .config .config.7.stripsigskeys
}
# Strip debug informations
doStripDebug() {
cd $WORKDIR
doEchoStep "Remove debug informations"
./scripts/config --disable DEBUG_INFO
./scripts/config --enable DEBUG_INFO_NONE
result=$?
if [ ! result==0 ]; then
echo ">>> Error in chown !"
exit 1
fi
cp .config .config.8.stripdebug
}
# Generate defaults options for this kernel
doDefaults() {
cd $WORKDIR
doEchoStep "Define default options"
./scripts/config --set-str CONFIG_LOCALVERSION '-zogg'
./scripts/config --enable CONFIG_ADDRESS_MASKING
./scripts/config --enable CONFIG_AF_KCM
./scripts/config --enable CONFIG_AF_KCM
./scripts/config --enable CONFIG_ARCH_CPUIDLE_HALTPOLL
./scripts/config --enable CONFIG_BINFMT_MISC
./scripts/config --enable CONFIG_BINFMT_SCRIPT
./scripts/config --enable CONFIG_BLK_CGROUP
./scripts/config --enable CONFIG_BLK_DEV
./scripts/config --enable CONFIG_BLK_DEV_INITRD
./scripts/config --enable CONFIG_BLK_WBT
./scripts/config --enable CONFIG_BOOT_CONFIG
./scripts/config --enable CONFIG_BPF_JIT
./scripts/config --enable CONFIG_BPF_SYSCALL
./scripts/config --enable CONFIG_BSD_PROCESS_ACCT
./scripts/config --enable CONFIG_CALL_DEPTH_TRACKING
./scripts/config --enable CONFIG_CALL_THUNKS_DEBUG
./scripts/config --enable CONFIG_CGROUP_CPUACCT
./scripts/config --enable CONFIG_CGROUP_DEVICE
./scripts/config --enable CONFIG_CGROUP_MISC
./scripts/config --enable CONFIG_CGROUP_NET_CLASSID
./scripts/config --enable CONFIG_CGROUP_NET_PRIO
./scripts/config --enable CONFIG_CGROUP_PIDS
./scripts/config --enable CONFIG_CGROUP_RDMA
./scripts/config --enable CONFIG_CGROUP_SCHED
./scripts/config --enable CONFIG_CGROUPS
./scripts/config --enable CONFIG_CIFS
./scripts/config --enable CONFIG_CIFS_ALLOW_INSECURE_LEGACY
./scripts/config --enable CONFIG_CIFS_DFS_UPCALL
./scripts/config --enable CONFIG_CIFS_STATS2
./scripts/config --enable CONFIG_CIFS_SWN_UPCALL
./scripts/config --enable CONFIG_CIFS_XATTR
./scripts/config --enable CONFIG_COMPAT_32BIT_TIME
./scripts/config --enable CONFIG_CONFIGFS_FS
./scripts/config --enable CONFIG_CPU_FREQ
./scripts/config --enable CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND
./scripts/config --enable CONFIG_CPU_FREQ_GOV_CONSERVATIVE
./scripts/config --enable CONFIG_CPU_FREQ_GOV_ONDEMAND
./scripts/config --enable CONFIG_CPU_FREQ_GOV_PERFORMANCE
./scripts/config --enable CONFIG_CPU_FREQ_GOV_POWERSAVE
./scripts/config --enable CONFIG_CPU_FREQ_GOV_USERSPACE
./scripts/config --enable CONFIG_CPU_IBPB_ENTRY
./scripts/config --enable CONFIG_CPU_IBRS_ENTRY
./scripts/config --enable CONFIG_CPU_UNRET_ENTRY
./scripts/config --enable CONFIG_DEVTMPFS
./scripts/config --enable CONFIG_DRM_VIRTIO_GPU
./scripts/config --enable CONFIG_DRM_VIRTIO_GPU_KMS
./scripts/config --enable CONFIG_EFI
./scripts/config --enable CONFIG_EFI_BOOTLOADER_CONTROL
./scripts/config --enable CONFIG_EFI_MIXED
./scripts/config --enable CONFIG_EFI_PARTITION
./scripts/config --enable CONFIG_EFI_VARS_PSTORE
./scripts/config --enable CONFIG_EFIVAR_FS
./scripts/config --enable CONFIG_ETHERNET
./scripts/config --enable CONFIG_ETHTOOL_NETLINK
./scripts/config --enable CONFIG_ETHTOOL_NETLINK
./scripts/config --enable CONFIG_EXT2_FS
./scripts/config --enable CONFIG_EXT4_FS
./scripts/config --enable CONFIG_EXT4_USE_FOR_EXT2
./scripts/config --enable CONFIG_FANOTIFY
./scripts/config --enable CONFIG_FORTIFY_SOURCE
./scripts/config --enable CONFIG_GDS_FORCE_MITIGATION
./scripts/config --enable CONFIG_HANGCHECK_TIMER
./scripts/config --enable CONFIG_HARDENED_USERCOPY
./scripts/config --enable CONFIG_HIGH_RES_TIMERS
./scripts/config --enable CONFIG_HYPERVISOR_GUEST
./scripts/config --enable CONFIG_HZ_100
./scripts/config --enable CONFIG_IA32_EMULATION
./scripts/config --enable CONFIG_IKCONFIG
./scripts/config --enable CONFIG_IKCONFIG_PROC
./scripts/config --enable CONFIG_IKHEADERS
./scripts/config --enable CONFIG_INET
./scripts/config --enable CONFIG_INET_AH
./scripts/config --enable CONFIG_INET_ESP
./scripts/config --enable CONFIG_INET_IPCOMP
./scripts/config --enable CONFIG_INET_RAW_DIAG
./scripts/config --enable CONFIG_INET_UDP_DIAG
./scripts/config --enable CONFIG_INET6_AH
./scripts/config --enable CONFIG_INET6_ESP
./scripts/config --enable CONFIG_INET6_IPCOMP
./scripts/config --enable CONFIG_INTEL_HFI_THERMAL
./scripts/config --enable CONFIG_INTEL_IDLE
./scripts/config --enable CONFIG_INTEL_POWERCLAMP
./scripts/config --enable CONFIG_INTEL_RST
./scripts/config --enable CONFIG_IOMMU_SUPPORT
./scripts/config --enable CONFIG_IOSCHED_BFQ
./scripts/config --enable CONFIG_IP_NF_ARPTABLES
./scripts/config --enable CONFIG_IP_NF_IPTABLES
./scripts/config --enable CONFIG_IP6_NF_IPTABLES
./scripts/config --enable CONFIG_IPV6
./scripts/config --enable CONFIG_IPV6_VTI
./scripts/config --enable CONFIG_JUMP_LABEL
./scripts/config --enable CONFIG_KERNEL_XZ
./scripts/config --enable CONFIG_KVM
./scripts/config --enable CONFIG_KVM_INTEL
./scripts/config --enable CONFIG_LOCALVERSION_AUTO
./scripts/config --enable CONFIG_LRU_GEN
./scripts/config --enable CONFIG_LRU_GEN_ENABLED
./scripts/config --enable CONFIG_MEDIA_SUBDRV_AUTOSELECT
./scripts/config --enable CONFIG_MEDIA_SUPPORT
./scripts/config --enable CONFIG_MEDIA_SUPPORT_FILTER
./scripts/config --enable CONFIG_MEMCG
./scripts/config --enable CONFIG_MODULE_COMPRESS_NONE
./scripts/config --enable CONFIG_MODULE_FORCE_LOAD
./scripts/config --enable CONFIG_MODULE_UNLOAD
./scripts/config --enable CONFIG_MODULES
./scripts/config --enable CONFIG_MQ_IOSCHED_DEADLINE
./scripts/config --enable CONFIG_MQ_IOSCHED_KYBER
./scripts/config --enable CONFIG_MSDOS_PARTITION
./scripts/config --enable CONFIG_NET
./scripts/config --enable CONFIG_NET_CLS_BPF
./scripts/config --enable CONFIG_NET_CLS_CGROUP
./scripts/config --enable CONFIG_NET_CLS_FLOWER
./scripts/config --enable CONFIG_NET_CLS_FW
./scripts/config --enable CONFIG_NET_CLS_ROUTE4
./scripts/config --enable CONFIG_NET_CORE
./scripts/config --enable CONFIG_NET_FOU
./scripts/config --enable CONFIG_NET_FOU_IP_TUNNELS
./scripts/config --enable CONFIG_NET_IPVTI
./scripts/config --enable CONFIG_NET_SCH_CBS
./scripts/config --enable CONFIG_NET_SCH_ETF
./scripts/config --enable CONFIG_NET_SCH_GRED
./scripts/config --enable CONFIG_NET_SCH_HFSC
./scripts/config --enable CONFIG_NET_SCH_HHF
./scripts/config --enable CONFIG_NET_SCH_HTB
./scripts/config --enable CONFIG_NET_SCH_PRIO
./scripts/config --enable CONFIG_NET_SCH_RED
./scripts/config --enable CONFIG_NET_SCH_SFB
./scripts/config --enable CONFIG_NET_SCH_SFQ
./scripts/config --enable CONFIG_NET_SCH_TAPRIO
./scripts/config --enable CONFIG_NET_SCH_TBF
./scripts/config --enable CONFIG_NET_SCH_TEQL
./scripts/config --enable CONFIG_NET_SCHED
./scripts/config --enable CONFIG_NETDEVICES
./scripts/config --enable CONFIG_NETFILTER
./scripts/config --enable CONFIG_NETFILTER_XTABLES
./scripts/config --enable CONFIG_NETLINK_DIAG
./scripts/config --enable CONFIG_NETWORK_FILESYSTEMS
./scripts/config --enable CONFIG_NF_SOCKET_IPV4
./scripts/config --enable CONFIG_NF_SOCKET_IPV6
./scripts/config --enable CONFIG_NF_TABLES
./scripts/config --enable CONFIG_PACKET
./scripts/config --enable CONFIG_PACKET_DIAG
./scripts/config --enable CONFIG_PAGE_REPORTING
./scripts/config --enable CONFIG_PAGE_TABLE_ISOLATION
./scripts/config --enable CONFIG_PARAVIRT
./scripts/config --enable CONFIG_PARTITION_ADVANCED
./scripts/config --enable CONFIG_PCI
./scripts/config --enable CONFIG_PCI_IOV
./scripts/config --enable CONFIG_PCI_PASID
./scripts/config --enable CONFIG_PCI_PRI
./scripts/config --enable CONFIG_PCIE_BUS_PERFORMANCE
./scripts/config --enable CONFIG_PCIEASPM
./scripts/config --enable CONFIG_PM_AUTOSLEEP
./scripts/config --enable CONFIG_PNP
./scripts/config --enable CONFIG_PREEMPT_NONE
./scripts/config --enable CONFIG_PROC_KCORE
./scripts/config --enable CONFIG_PSAMPLE
./scripts/config --enable CONFIG_PVH
./scripts/config --enable CONFIG_PVPANIC
./scripts/config --enable CONFIG_RCU_BOOST
./scripts/config --enable CONFIG_RCU_EXPERT
./scripts/config --enable CONFIG_RETHUNK
./scripts/config --enable CONFIG_RETPOLINE
./scripts/config --enable CONFIG_SCHED_AUTOGROUP
./scripts/config --enable CONFIG_SHUFFLE_PAGE_ALLOCATOR
./scripts/config --enable CONFIG_SLS
./scripts/config --enable CONFIG_SMB_SERVER
./scripts/config --enable CONFIG_SMB_SERVER_CHECK_CAP_NET_ADMIN
./scripts/config --enable CONFIG_SPECULATION_MITIGATIONS
./scripts/config --enable CONFIG_SYN_COOKIES
./scripts/config --enable CONFIG_SYSFB_SIMPLEFB
./scripts/config --enable CONFIG_SYSVIPC
./scripts/config --enable CONFIG_TCP_CONG_ADVANCED
./scripts/config --enable CONFIG_TCP_CONG_BBR
./scripts/config --enable CONFIG_TMPFS
./scripts/config --enable CONFIG_TRANSPARENT_HUGEPAGE
./scripts/config --enable CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS
./scripts/config --enable CONFIG_UNIX
./scripts/config --enable CONFIG_VGA_ARB
./scripts/config --enable CONFIG_VHOST_NET
./scripts/config --enable CONFIG_VIRT_DRIVERS
./scripts/config --enable CONFIG_VIRTIO_BLK
./scripts/config --enable CONFIG_VIRTIO_CONSOLE
./scripts/config --enable CONFIG_VIRTIO_IOMMU
./scripts/config --enable CONFIG_VIRTUALIZATION
./scripts/config --enable CONFIG_VMGENID
./scripts/config --enable CONFIG_WATCH_QUEUE
./scripts/config --enable CONFIG_WLAN
./scripts/config --enable CONFIG_X86_ACPI_CPUFREQ
./scripts/config --enable CONFIG_X86_CPUID
./scripts/config --enable CONFIG_X86_INTEL_PSTATE
./scripts/config --enable CONFIG_X86_INTEL_TSX_MODE_AUTO
./scripts/config --enable CONFIG_X86_MSR
./scripts/config --enable CONFIG_X86_PKG_TEMP_THERMAL
./scripts/config --enable CONFIG_X86_PLATFORM_DEVICES
./scripts/config --enable CONFIG_X86_PMEM_LEGACY
./scripts/config --enable CONFIG_X86_X32_ABI
./scripts/config --enable CONFIG_ZRAM
./scripts/config --enable DEFAULT_BBR
./scripts/config --enable FAIR_GROUP_SCHED
./scripts/config --enable VIRTIO_MENU
./scripts/config --enable ZRAM_DEF_COMP_ZSTD
./scripts/config --disable CONFIG_ACCESSIBILITY
./scripts/config --disable CONFIG_ACORN_PARTITION
./scripts/config --disable CONFIG_ACPI_DEBUG
./scripts/config --disable CONFIG_ACPI_DEBUGGER
./scripts/config --disable CONFIG_ACPI_EC_DEBUGFS
./scripts/config --disable CONFIG_ACRN_GUEST
./scripts/config --disable CONFIG_AF_RXRPC
./scripts/config --disable CONFIG_AIX_PARTITION
./scripts/config --disable CONFIG_AMD_IOMMU
./scripts/config --disable CONFIG_AMIGA_PARTITION
./scripts/config --disable CONFIG_APPLE_DART
./scripts/config --disable CONFIG_APPLE_PROPERTIES
./scripts/config --disable CONFIG_ARCH_MEMORY_PROBE
./scripts/config --disable CONFIG_ARM_INTEGRATOR_LM
./scripts/config --disable CONFIG_ARM_SCMI_PROTOCOL
./scripts/config --disable CONFIG_ARM_SCPI_PROTOCOL
./scripts/config --disable CONFIG_ARM_SMMU
./scripts/config --disable CONFIG_ATA_OVER_ETH
./scripts/config --disable CONFIG_ATARI_PARTITION
./scripts/config --disable CONFIG_ATM_DRIVERS
# ./scripts/config --disable CONFIG_BFQ_CGROUP_DEBUG
# ./scripts/config --disable CONFIG_BLK_CGROUP_IOLATENCY
# ./scripts/config --disable CONFIG_BLK_DEBUG_FS
# ./scripts/config --disable CONFIG_BLK_DEV_BSGLIB
# ./scripts/config --disable CONFIG_BLK_DEV_INTEGRITY
# ./scripts/config --disable CONFIG_BLK_DEV_THROTTLING_LOW
# ./scripts/config --disable CONFIG_BLK_DEV_ZONED
# ./scripts/config --disable CONFIG_BSD_DISKLABEL
# ./scripts/config --disable CONFIG_BT
# ./scripts/config --disable CONFIG_BTRFS_ASSERT
# ./scripts/config --disable CONFIG_BTRFS_DEBUG
# ./scripts/config --disable CONFIG_BTRFS_FS
# ./scripts/config --disable CONFIG_BTRFS_FS_CHECK_INTEGRITY
# ./scripts/config --disable CONFIG_BTRFS_FS_POSIX_ACL
# ./scripts/config --disable CONFIG_BTRFS_FS_REF_VERIFY
# ./scripts/config --disable CONFIG_BTRFS_FS_RUN_SANITY_TESTS
# ./scripts/config --disable CONFIG_CACHEFILES_DEBUG
# ./scripts/config --disable CONFIG_CACHEFILES_ONDEMAND
# ./scripts/config --disable CONFIG_CAIF
# ./scripts/config --disable CONFIG_CAN
# ./scripts/config --disable CONFIG_CDROM_PKTCDVD
# ./scripts/config --disable CONFIG_CEPH_LIB
# ./scripts/config --disable CONFIG_CFG80211
# ./scripts/config --disable CONFIG_CGROUP_DEBUG
# ./scripts/config --disable CONFIG_CIFS_DEBUG
# ./scripts/config --disable CONFIG_CMA
# ./scripts/config --disable CONFIG_CMA_DEBUG
# ./scripts/config --disable CONFIG_CMA_DEBUGFS
# ./scripts/config --disable CONFIG_CMA_SYSFS
# ./scripts/config --disable CONFIG_COMPAT_VDSO
# ./scripts/config --disable CONFIG_COMPILE_TEST
# ./scripts/config --disable CONFIG_CPA_DEBUG
# ./scripts/config --disable CONFIG_CPU_SRSO
# ./scripts/config --disable CONFIG_CPU_SUP_AMD
# ./scripts/config --disable CONFIG_CPU_SUP_CENTAUR
# ./scripts/config --disable CONFIG_CPU_SUP_HYGON
# ./scripts/config --disable CONFIG_CPU_SUP_ZHAOXIN
# ./scripts/config --disable CONFIG_CRASH_DUMP
# ./scripts/config --disable CONFIG_DAMON
# ./scripts/config --disable CONFIG_DEBUG_BOOT_PARAMS
# ./scripts/config --disable CONFIG_DEBUG_CGROUP_REF
# ./scripts/config --disable CONFIG_DEBUG_CREDENTIALS
# ./scripts/config --disable CONFIG_DEBUG_DEVRES
# ./scripts/config --disable CONFIG_DEBUG_DRIVER
# ./scripts/config --disable CONFIG_DEBUG_ENTRY
# ./scripts/config --disable CONFIG_DEBUG_KERNEL
# ./scripts/config --disable CONFIG_DEBUG_KOBJECT
# ./scripts/config --disable CONFIG_DEBUG_KOBJECT_RELEASE
# ./scripts/config --disable CONFIG_DEBUG_LIST
# ./scripts/config --disable CONFIG_DEBUG_MAPLE_TREE
# ./scripts/config --disable CONFIG_DEBUG_MISC
# ./scripts/config --disable CONFIG_DEBUG_NMI_SELFTEST
# ./scripts/config --disable CONFIG_DEBUG_NOTIFIERS
# ./scripts/config --disable CONFIG_DEBUG_PERF_USE_VMALLOC
# ./scripts/config --disable CONFIG_DEBUG_PLIST
# ./scripts/config --disable CONFIG_DEBUG_PREEMPT
# ./scripts/config --disable CONFIG_DEBUG_RSEQ
# ./scripts/config --disable CONFIG_DEBUG_SG
# ./scripts/config --disable CONFIG_DEBUG_SHIRQ
# ./scripts/config --disable CONFIG_DEBUG_TEST_DRIVER_REMOVE
# ./scripts/config --disable CONFIG_DEBUG_TIMEKEEPING
# ./scripts/config --disable CONFIG_DEBUG_TLBFLUSH
# ./scripts/config --disable CONFIG_DEBUG_WQ_FORCE_RR_CPU
# ./scripts/config --disable CONFIG_DRM_AMDGPU
# ./scripts/config --disable CONFIG_DRM_HDLCD
# ./scripts/config --disable CONFIG_DRM_KOMEDA
# ./scripts/config --disable CONFIG_DRM_LEGACY
# ./scripts/config --disable CONFIG_DRM_MALI_DISPLAY
# ./scripts/config --disable CONFIG_DRM_RADEON
# ./scripts/config --disable CONFIG_DVB_DUMMY_FE
# ./scripts/config --disable CONFIG_DVB_MMAP
# ./scripts/config --disable CONFIG_EARLY_PRINTK
# ./scripts/config --disable CONFIG_EDD
# ./scripts/config --disable CONFIG_EFI_FAKE_MEMMAP
# ./scripts/config --disable CONFIG_EFI_MIXED
# ./scripts/config --disable CONFIG_EFI_PGT_DUMP
# ./scripts/config --disable CONFIG_EISA
# ./scripts/config --disable CONFIG_EXT2_FS
# ./scripts/config --disable CONFIG_EXT3_FS
# ./scripts/config --disable CONFIG_EXT4_DEBUG
# ./scripts/config --disable CONFIG_EXT4_FS_POSIX_ACL
# ./scripts/config --disable CONFIG_EXT4_FS_SECURITY
# ./scripts/config --disable CONFIG_EXT4_KUNIT_TESTS
# ./scripts/config --disable CONFIG_F2FS_FS
# ./scripts/config --disable CONFIG_FAT_KUNIT_TEST
# ./scripts/config --disable CONFIG_FAULT_INJECTION
# ./scripts/config --disable CONFIG_FDDI
# ./scripts/config --disable CONFIG_FIREWIRE
# ./scripts/config --disable CONFIG_FIREWIRE_NOSY
# ./scripts/config --disable CONFIG_FS_DAX
# ./scripts/config --disable CONFIG_FSCACHE_DEBUG
# ./scripts/config --disable CONFIG_FTRACE
# ./scripts/config --disable CONFIG_FUJITSU_ES
# ./scripts/config --disable CONFIG_FUNCTION_ERROR_INJECTION
# ./scripts/config --disable CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT
# ./scripts/config --disable CONFIG_GCOV_KERNEL
# ./scripts/config --disable CONFIG_GENERIC_IRQ_DEBUGFS
# ./scripts/config --disable CONFIG_GENERIC_IRQ_DEBUGFS
# ./scripts/config --disable CONFIG_GFS2_FS
# ./scripts/config --disable CONFIG_GNSS
# ./scripts/config --disable CONFIG_GOOGLE_FIRMWARE
# ./scripts/config --disable CONFIG_HAMRADIO
# ./scripts/config --disable CONFIG_HIBERNATION
# ./scripts/config --disable CONFIG_HIPPI
# ./scripts/config --disable CONFIG_HOTPLUG_PCI
# ./scripts/config --disable CONFIG_HYPERV_NET
# ./scripts/config --disable CONFIG_HYPERV_TESTING
# ./scripts/config --disable CONFIG_IOSF_MBI
# ./scripts/config --disable CONFIG_IOSF_MBI_DEBUG
# ./scripts/config --disable CONFIG_IRQ_TIME_ACCOUNTING
# ./scripts/config --disable CONFIG_ISA_BUS
# ./scripts/config --disable CONFIG_ISDN
# ./scripts/config --disable CONFIG_JBD2_DEBUG
# ./scripts/config --disable CONFIG_JFS_FS
# ./scripts/config --disable CONFIG_KARMA_PARTITION
# ./scripts/config --disable CONFIG_KCOV
# ./scripts/config --disable CONFIG_KEXEC_BZIMAGE_VERIFY_SIG
# ./scripts/config --disable CONFIG_KEXEC_SIG
# ./scripts/config --disable CONFIG_KEXEC_SIG_FORCE
# ./scripts/config --disable CONFIG_KVM_PROVE_MMU
# ./scripts/config --disable CONFIG_KVM_XEN
# ./scripts/config --disable CONFIG_LDM_PARTITION
# ./scripts/config --disable CONFIG_LIB80211_DEBUG
# ./scripts/config --disable CONFIG_LOCK_EVENT_COUNTS
# ./scripts/config --disable CONFIG_LRU_GEN_STATS
# ./scripts/config --disable CONFIG_MAC_PARTITION
# ./scripts/config --disable CONFIG_MAC80211
# ./scripts/config --disable CONFIG_MACINTOSH_DRIVERS
# ./scripts/config --disable CONFIG_MEDIA_CONTROLLER_DVB
# ./scripts/config --disable CONFIG_MEMORY_FAILURE
# ./scripts/config --disable CONFIG_MEMTEST
# ./scripts/config --disable CONFIG_MICROCODE_LATE_LOADING
# ./scripts/config --disable CONFIG_MINIX_SUBPARTITION
# ./scripts/config --disable CONFIG_MODIFY_LDT_SYSCALL
# ./scripts/config --disable CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS
# ./scripts/config --disable CONFIG_MODULE_DEBUG
# ./scripts/config --disable CONFIG_MODULE_FORCE_LOAD
# ./scripts/config --disable CONFIG_MODULE_FORCE_UNLOAD
# ./scripts/config --disable CONFIG_MODULE_SIG
# ./scripts/config --disable CONFIG_MODULE_SRCVERSION_ALL
# ./scripts/config --disable CONFIG_MODULE_UNLOAD_TAINT_TRACKING
# ./scripts/config --disable CONFIG_MODVERSIONS
# ./scripts/config --disable CONFIG_NET_9P
# ./scripts/config --disable CONFIG_NET_SB1000
# ./scripts/config --disable CONFIG_NETDEVSIM
# ./scripts/config --disable CONFIG_NFC
# ./scripts/config --disable CONFIG_NILFS2_FS
# ./scripts/config --disable CONFIG_NO_HZ
# ./scripts/config --disable CONFIG_NTFS_DEBUG
# ./scripts/config --disable CONFIG_NTFS3_64BIT_CLUSTER
# ./scripts/config --disable CONFIG_NTFS3_FS_POSIX_ACL
# ./scripts/config --disable CONFIG_OCFS2_FS
# ./scripts/config --disable CONFIG_OSF_PARTITION
# ./scripts/config --disable CONFIG_PAGE_POOL_STATS
# ./scripts/config --disable CONFIG_PARAVIRT_DEBUG
# ./scripts/config --disable CONFIG_PARAVIRT_TIME_ACCOUNTING
# ./scripts/config --disable CONFIG_PARPORT
# ./scripts/config --disable CONFIG_PCCARD
# ./scripts/config --disable CONFIG_PCI_CNB20LE_QUIRK
# ./scripts/config --disable CONFIG_PCI_DEBUG
# ./scripts/config --disable CONFIG_PCI_EPF_TEST
# ./scripts/config --disable CONFIG_PCI_P2PDMA
# ./scripts/config --disable CONFIG_PCI_PF_STUB
# ./scripts/config --disable CONFIG_PCI_STUB
# ./scripts/config --disable CONFIG_PCIE_ECRC
# ./scripts/config --disable CONFIG_PCIEAER_INJECT
# ./scripts/config --disable CONFIG_PERF_EVENTS_AMD_UNCORE
# ./scripts/config --disable CONFIG_PM_DEBUG
# ./scripts/config --disable CONFIG_PPS
# ./scripts/config --disable CONFIG_PROVE_RCU_LIST
# ./scripts/config --disable CONFIG_PROVIDE_OHCI1394_DMA_INIT
# ./scripts/config --disable CONFIG_PSE_CONTROLLER
# ./scripts/config --disable CONFIG_PUNIT_ATOM_DEBUG
# ./scripts/config --disable CONFIG_QCOM_IPA
# ./scripts/config --disable CONFIG_QFMT_V1
# ./scripts/config --disable CONFIG_QFMT_V2
# ./scripts/config --disable CONFIG_QUOTA_DEBUG
# ./scripts/config --disable CONFIG_RADIO_ADAPTERS
# ./scripts/config --disable CONFIG_RAPIDIO
# ./scripts/config --disable CONFIG_RCU_CPU_STALL_CPUTIME
# ./scripts/config --disable CONFIG_RCU_EQS_DEBUG
# ./scripts/config --disable CONFIG_RCU_STRICT_GRACE_PERIOD
# ./scripts/config --disable CONFIG_RCU_TRACE
# ./scripts/config --disable CONFIG_READ_ONLY_THP_FOR_FS
# ./scripts/config --disable CONFIG_REISERFS_FS
# ./scripts/config --disable CONFIG_RFKILL
# ./scripts/config --disable CONFIG_SAMPLES
# ./scripts/config --disable CONFIG_SECCOMP_CACHE_DEBUG
# ./scripts/config --disable CONFIG_SGI_PARTITION
# ./scripts/config --disable CONFIG_SMP
# ./scripts/config --disable CONFIG_SMS_SIANO_DEBUGFS
# ./scripts/config --disable CONFIG_SOLARIS_X86_PARTITION
# ./scripts/config --disable CONFIG_STRICT_SIGALTSTACK_SIZE
# ./scripts/config --disable CONFIG_SUN_PARTITION
# ./scripts/config --disable CONFIG_SYSV68_PARTITION
# ./scripts/config --disable CONFIG_TEST_ASYNC_DRIVER_PROBE
# ./scripts/config --disable CONFIG_TIME_KUNIT_TEST
# ./scripts/config --disable CONFIG_TIME_KUNIT_TEST
# ./scripts/config --disable CONFIG_ULTRIX_PARTITION
# ./scripts/config --disable CONFIG_UNIXWARE_DISKLABEL
# ./scripts/config --disable CONFIG_USB4_NET
# ./scripts/config --disable CONFIG_USELIB
# ./scripts/config --disable CONFIG_VMXNET3
# ./scripts/config --disable CONFIG_WAN
# ./scripts/config --disable CONFIG_WARN_ABI_ERRORS
# ./scripts/config --disable CONFIG_WARN_ALL_UNSEEDED_RANDOM
# ./scripts/config --disable CONFIG_WARN_MISSING_DOCUMENTS
# ./scripts/config --disable CONFIG_WLAN
# ./scripts/config --disable CONFIG_WQ_POWER_EFFICIENT_DEFAULT
# ./scripts/config --disable CONFIG_WWAN
# ./scripts/config --disable CONFIG_X86_16BIT
# ./scripts/config --disable CONFIG_X86_5LEVEL
# ./scripts/config --disable CONFIG_X86_AMD_PLATFORM_DEVICE
# ./scripts/config --disable CONFIG_X86_AMD_PSTATE
# ./scripts/config --disable CONFIG_X86_AMD_PSTATE_UT
# ./scripts/config --disable CONFIG_X86_CHECK_BIOS_CORRUPTION
# ./scripts/config --disable CONFIG_X86_CPU_RESCTRL
# ./scripts/config --disable CONFIG_X86_DEBUG_FPU
# ./scripts/config --disable CONFIG_X86_EXTENDED_PLATFORM
# ./scripts/config --disable CONFIG_X86_GOLDFISH
# ./scripts/config --disable CONFIG_X86_INTEL_LPSS
# ./scripts/config --disable CONFIG_X86_INTEL_MID
# ./scripts/config --disable CONFIG_X86_IOPL_IOPERM
# ./scripts/config --disable CONFIG_X86_MCE_INJECT
# ./scripts/config --disable CONFIG_X86_MCELOG_LEGACY
# ./scripts/config --disable CONFIG_X86_MPPARSE
# ./scripts/config --disable CONFIG_X86_P4_CLOCKMOD
# ./scripts/config --disable CONFIG_X86_POWERNOW_K8
# ./scripts/config --disable CONFIG_X86_SPEEDSTEP_CENTRINO
# ./scripts/config --disable CONFIG_X86_VSYSCALL_EMULATION
# ./scripts/config --disable CONFIG_X86_X2APIC
# ./scripts/config --disable CONFIG_XEN
# ./scripts/config --disable CONFIG_XFS_ASSERT_FATAL
# ./scripts/config --disable CONFIG_XFS_DEBUG
# ./scripts/config --disable CONFIG_XFS_ONLINE_REPAIR
# ./scripts/config --disable CONFIG_XFS_ONLINE_SCRUB
# ./scripts/config --disable CONFIG_XFS_ONLINE_SCRUB_STATS
# ./scripts/config --disable CONFIG_XFS_POSIX_ACL
# ./scripts/config --disable CONFIG_XFS_QUOTA
# ./scripts/config --disable CONFIG_XFS_RT
# ./scripts/config --disable CONFIG_XFS_SUPPORT_ASCII_CI
# ./scripts/config --disable CONFIG_XFS_SUPPORT_V4
# ./scripts/config --disable USB_NET_DRIVER
# ./scripts/config --disable WIRELESS
cp .config .config.5.defaulted
}
# Edit .config
doEditSettings() {
cd $WORKDIR
doEchoStep "Settings tuning !"
make -j$(nproc) CC="ccache gcc" menuconfig
result=$?
if [ ! result==0 ]; then
echo ">>> Error in settings edit !"
exit 1
fi
cp .config .config.6.menuconfig
}
# Generate uninstall script
doGenerateUninstall() {
# remove old files
READY=$CURRENT/$BRANCH/$VERSION/ready
mkdir -p $READY
rm -rf $READY/*.*
# find .deb packages and generate
# uninstall commands
# package name
PACKAGES=
TAG="_$VERSION-1_amd64.deb"
search_dir=$WORKDIR/../
for entry in "$search_dir"/*.deb
do
name="${entry##*/}"
pname=${name//$TAG/}
if [ ! "$pname" == "linux-libc-dev" ]; then
PACKAGES="$PACKAGES $pname"
fi
echo "$name" >> $READY/packages.log
done
# move files to destination folder
mv -f $WORKDIR/../*.deb $READY/
mv -f $WORKDIR/../uninstall.sh $READY/
mv -f $WORKDIR/../packages.log $READY/
# prepare uninstall script
cat <<EOF > $READY/uninstall.sh
#!/bin/bash
# ${UPDATED}
dpkg --remove ${PACKAGES}
sudo sync
exit 0
EOF
# generate install script
cat <<EOF > $READY/install.sh
#!/bin/bash
# ${UPDATED}
echo 'blacklist pcspkr' > /etc/modprobe.d/blacklist-pcspkr.conf
sudo dpkg -i *.deb
sudo sync
exit 0
EOF
# setup execution rights on packages
chown -R root:root $READY/.
chmod +x $READY/*.sh
}
# Print compilation end informations
doEnding() {
clear
doHead
doEchoStep "Generated packages :"
echo
cat $CURRENT/$BRANCH/$VERSION/ready/packages.log
echo
echo "In folder: $CURRENT/$BRANCH/$VERSION/ready"
doSync
}
# Perform effective compilation
doCompile() {
cd $WORKDIR
doStripSig
doStripDebug
doEchoStep "Compilation time... Be patient!"
NB_CORES=$(grep -c '^processor' /proc/cpuinfo)
export MAKEFLAGS="-j$((NB_CORES+1)) -l${NB_CORES} -Werror=maybe-uninitialized -Werror=nonnull -Wno-maybe-uninitialized -Wno-uninitialized -Wno-free-nonheap-object -Wno-nonnull"
doEchoStep "make bindeb-pkg"
make \
CC='ccache gcc' \
bindeb-pkg \
LOCALVERSION=-"$(dpkg --print-architecture)" \
KDEB_PKGVERSION="$(make kernelversion)-1"
result=$?
doEchoStep "make bindeb-pkg: $result"
if [ ! result==0 ]; then
echo ">>> Error in 'make bindeb-pkg' !"
exit 1
fi
doSync
doGenerateUninstall
doEnding
}
# Proceed for Kernel build
doKernel() {
WORKDIR=$CURRENT/$BRANCH/$VERSION
LOGFILE=$WORKDIR/$LOGNAME.$LOGEXT
rm -rf $LOGFILE
touch $LOGFILE
if [ "$STEPS" != "compile" ]; then
doDownload > >(tee -a $LOGFILE) 2>&1
doUncompress > >(tee -a $LOGFILE) 2>&1
fi
WORKDIR=$WORKDIR/linux-$VERSION
doCleanup > >(tee -a $LOGFILE) 2>&1
doOldOne > >(tee -a $LOGFILE) 2>&1
# doAllMods > >(tee -a $LOGFILE) 2>&1
# doStripDebug > >(tee -a $LOGFILE) 2>&1
doDefaults > >(tee -a $LOGFILE) 2>&1
doPermissions > >(tee -a $LOGFILE) 2>&1
doEditSettings
while true; do
read -p "Do you wish to run compile? " yn
case $yn in
[Yy]* ) doCompile > >(tee -a $LOGFILE) 2>&1; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
}
# Entrypoint of operations
if [[ -z $BRANCH || "$BRANCH" == "help" || -z $VERSION || "$VERSION" == "help" ]]; then
doHelp
exit 1
else
clear
doHead
doKernel
fi
exit 0