mirror of
https://github.com/dynup/kpatch
synced 2025-02-16 09:36:55 +00:00
Merge pull request #1368 from wardenjohn/devel
Support Anolis OS in a more elegant way
This commit is contained in:
commit
0edd6e42bf
@ -65,6 +65,21 @@ LLD="${CROSS_COMPILE:-}ld.lld"
|
|||||||
READELF="${CROSS_COMPILE:-}readelf"
|
READELF="${CROSS_COMPILE:-}readelf"
|
||||||
OBJCOPY="${CROSS_COMPILE:-}objcopy"
|
OBJCOPY="${CROSS_COMPILE:-}objcopy"
|
||||||
|
|
||||||
|
|
||||||
|
declare -rA SUPPORTED_DEB_DISTROS=(
|
||||||
|
["debian"]="Debian OS"
|
||||||
|
["ubuntu"]="Ubuntu OS")
|
||||||
|
|
||||||
|
declare -rA SUPPORTED_RPM_DISTROS=(
|
||||||
|
["anolis"]="Anolis OS"
|
||||||
|
["centos"]="CentOS"
|
||||||
|
["fedora"]="Fedora"
|
||||||
|
["openEuler"]="OpenEuler"
|
||||||
|
["ol"]="Oracle"
|
||||||
|
["photon"]="Photon OS"
|
||||||
|
["rhel"]="RHEL")
|
||||||
|
|
||||||
|
|
||||||
warn() {
|
warn() {
|
||||||
echo "ERROR: $1" >&2
|
echo "ERROR: $1" >&2
|
||||||
}
|
}
|
||||||
@ -649,6 +664,25 @@ module_name_string() {
|
|||||||
echo "${1//[^a-zA-Z0-9_-]/-}" | cut -c 1-55
|
echo "${1//[^a-zA-Z0-9_-]/-}" | cut -c 1-55
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_supported_deb_distro(){
|
||||||
|
[[ -n "${SUPPORTED_DEB_DISTROS[$1]:-}" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
is_supported_rpm_distro(){
|
||||||
|
[[ -n "${SUPPORTED_RPM_DISTROS[$1]:-}" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
print_supported_distro(){
|
||||||
|
if is_supported_deb_distro "$DISTRO"; then
|
||||||
|
echo "${SUPPORTED_DEB_DISTROS[$DISTRO]} distribution detected"
|
||||||
|
elif is_supported_rpm_distro "$DISTRO"; then
|
||||||
|
echo "${SUPPORTED_RPM_DISTROS[$DISTRO]} distribution detected"
|
||||||
|
else
|
||||||
|
echo "$DISTRO is not supported"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "usage: $(basename "$0") [options] <patch1 ... patchN>" >&2
|
echo "usage: $(basename "$0") [options] <patch1 ... patchN>" >&2
|
||||||
echo " patchN Input patchfile(s)" >&2
|
echo " patchN Input patchfile(s)" >&2
|
||||||
@ -869,16 +903,14 @@ fi
|
|||||||
|
|
||||||
[[ -z "$TARGETS" ]] && TARGETS="vmlinux modules"
|
[[ -z "$TARGETS" ]] && TARGETS="vmlinux modules"
|
||||||
|
|
||||||
if [[ "$DISTRO" = fedora ]] || [[ "$DISTRO" = rhel ]] || [[ "$DISTRO" = ol ]] ||
|
if is_supported_rpm_distro "$DISTRO"; then
|
||||||
[[ "$DISTRO" = centos ]] || [[ "$DISTRO" = openEuler ]] ||
|
|
||||||
[[ "$DISTRO" = photon ]]; then
|
|
||||||
|
|
||||||
[[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/lib/modules/$ARCHVERSION/vmlinux"
|
[[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/lib/modules/$ARCHVERSION/vmlinux"
|
||||||
[[ -e "$VMLINUX" ]] || die "kernel-debuginfo-$ARCHVERSION not installed"
|
[[ -e "$VMLINUX" ]] || die "kernel-debuginfo-$ARCHVERSION not installed"
|
||||||
|
|
||||||
export PATH="/usr/lib64/ccache:$PATH"
|
export PATH="/usr/lib64/ccache:$PATH"
|
||||||
|
|
||||||
elif [[ "$DISTRO" = ubuntu ]] || [[ "$DISTRO" = debian ]]; then
|
elif is_supported_deb_distro "$DISTRO"; then
|
||||||
[[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/boot/vmlinux-$ARCHVERSION"
|
[[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/boot/vmlinux-$ARCHVERSION"
|
||||||
|
|
||||||
if [[ "$DISTRO" = ubuntu ]]; then
|
if [[ "$DISTRO" = ubuntu ]]; then
|
||||||
@ -910,14 +942,9 @@ elif [[ -e "$KERNEL_SRCDIR"/.config ]] && [[ -e "$VERSIONFILE" ]] && [[ "$(cat "
|
|||||||
echo "Using cache at $KERNEL_SRCDIR"
|
echo "Using cache at $KERNEL_SRCDIR"
|
||||||
|
|
||||||
else
|
else
|
||||||
if [[ "$DISTRO" = fedora ]] || [[ "$DISTRO" = rhel ]] || [[ "$DISTRO" = ol ]] || [[ "$DISTRO" = centos ]] || [[ "$DISTRO" = openEuler ]] || [[ "$DISTRO" = photon ]]; then
|
if is_supported_rpm_distro "$DISTRO"; then
|
||||||
|
|
||||||
[[ "$DISTRO" = fedora ]] && echo "Fedora distribution detected"
|
print_supported_distro "$DISTRO"
|
||||||
[[ "$DISTRO" = rhel ]] && echo "RHEL distribution detected"
|
|
||||||
[[ "$DISTRO" = ol ]] && echo "Oracle Linux distribution detected"
|
|
||||||
[[ "$DISTRO" = centos ]] && echo "CentOS distribution detected"
|
|
||||||
[[ "$DISTRO" = openEuler ]] && echo "OpenEuler distribution detected"
|
|
||||||
[[ "$DISTRO" = photon ]] && echo "Photon OS distribution detected"
|
|
||||||
|
|
||||||
clean_cache
|
clean_cache
|
||||||
|
|
||||||
@ -1013,9 +1040,9 @@ else
|
|||||||
|
|
||||||
(cd "$KERNEL_SRCDIR" && make mrproper 2>&1 | logger) || die
|
(cd "$KERNEL_SRCDIR" && make mrproper 2>&1 | logger) || die
|
||||||
|
|
||||||
elif [[ "$DISTRO" = ubuntu ]] || [[ "$DISTRO" = debian ]]; then
|
elif is_supported_deb_distro "$DISTRO"; then
|
||||||
|
|
||||||
echo "Debian/Ubuntu distribution detected"
|
print_supported_distro "$DISTRO"
|
||||||
|
|
||||||
if [[ "$DISTRO" = ubuntu ]]; then
|
if [[ "$DISTRO" = ubuntu ]]; then
|
||||||
|
|
||||||
|
@ -120,6 +120,18 @@ kpatch_photon_dependencies()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kpatch_anolis_dependencies()
|
||||||
|
{
|
||||||
|
local kernel_version
|
||||||
|
local arch
|
||||||
|
kernel_version=$(uname -r)
|
||||||
|
arch=$(uname -m)
|
||||||
|
sudo yum install -y make gcc patch bison flex openssl-devel dwarves \
|
||||||
|
rpm-build dnf-plugins-core python3-devel openssl-devel ncurses-devel elfutils-libelf-devel
|
||||||
|
sudo yum install -y "kernel-debuginfo-${kernel_version%.*}"\
|
||||||
|
"kernel-devel-${kernel_version%.*}"
|
||||||
|
}
|
||||||
|
|
||||||
kpatch_dependencies()
|
kpatch_dependencies()
|
||||||
{
|
{
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
|
Loading…
Reference in New Issue
Block a user