Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ UNITTEST_DIR = test/unit
INTEGRATION_DIR = test/integration
CLEAN_DIRS += clean-$(UNITTEST_DIR)

.PHONY: all install uninstall clean check unit
.PHONY: all dependencies install uninstall clean check unit
.PHONY: $(SUBDIRS) $(BUILD_DIRS) $(INSTALL_DIRS) $(CLEAN_DIRS)
.PHONY: integration integration-slow integration-quick
.PHONY: vagrant-integration-slow vagrant-integration-quick vagrant-integration
.PHONY: vagrant-install
.PHONY: help


all: $(BUILD_DIRS)
$(BUILD_DIRS):
$(MAKE) -C $(@:build-%=%)

dependencies: SHELL:=/bin/bash
dependencies:
source test/integration/lib.sh && kpatch_dependencies

install: $(INSTALL_DIRS)
$(INSTALL_DIRS):
$(MAKE) -C $(@:install-%=%) install
Expand Down Expand Up @@ -67,3 +72,24 @@ check:
test/integration/lib.sh test/integration/rebase-patches \
test/integration/test-vagrant \
test/integration/vm-integration-run

help:
@echo "kpatch Makefile"
@echo
@echo "Targets:"
@echo " make dependencies install build dependencies [1]"
@echo " make all build entire project"
@echo " make install install programs to system [1]"
@echo " make uninstall remove programs from system [1]"
@echo " make clean clean build files"
@echo
@echo "Test targets:"
@echo " make check run static code analyzers"
@echo " make integration build and run integration tests [2]"
@echo " make integration-slow build and run integration tests [2]"
@echo " make integration-quick build and run integration tests [2]"
@echo " make unit run unit tests"
@echo
@echo "[1] requires admin privileges"
@echo "[2] installs test kpatch kernel modules, run at your own risk"
@echo
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I skipped the vagrant targets since we don't document them on any markdown page.)

10 changes: 4 additions & 6 deletions doc/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ architecture is supported.
Install the dependencies for compiling kpatch and running kpatch-build:

```bash
source test/integration/lib.sh
# Will request root privileges
kpatch_dependencies
make dependencies
```

### Oracle Linux 7
Expand Down Expand Up @@ -78,12 +77,12 @@ ccache --max-size=5G
Install the dependencies for compiling kpatch and running kpatch-build

```bash
source test/integration/lib.sh
# required on ppc64le
# e.g., on Ubuntu 18.04 for gcc-7.3
apt-get install gcc-7-plugin-dev

# Will request root privileges
kpatch_dependencies
make dependencies
```

### Debian 9 (Stretch)
Expand Down Expand Up @@ -200,9 +199,8 @@ to see its documents. This document describes how to run mainline kpatch in open
Install the dependencies for compiling kpatch and running kpatch-build:

```bash
source test/integration/lib.sh
# Will request root privileges
kpatch_dependencies
make dependencies
```

Before running kpatch-build, two more things need to be checked:
Expand Down
97 changes: 35 additions & 62 deletions test/integration/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ kpatch_set_ccache_max_size()
ccache --max-size="${ccache_max_size}"
}

kpatch_fedora_dependencies()
{
local kernel_version
kernel_version=$(uname -r)

sudo dnf install -y gcc "kernel-devel-${kernel_version%.*}" elfutils elfutils-devel
sudo dnf install -y pesign yum-utils openssl wget numactl-devel
sudo dnf builddep -y "kernel-${kernel_version%.*}"
sudo dnf debuginfo-install -y "kernel-${kernel_version%.*}"

sudo dnf install -y ccache

if [[ "$(uname -m)" == "ppc64le" ]]; then
sudo yum install -y gcc-plugin-devel
fi
}

kpatch_ubuntu_dependencies()
{
sudo sed -i 's/# deb-src/deb-src/' /etc/apt/sources.list
Expand Down Expand Up @@ -58,62 +41,52 @@ kpatch_rhel_dependencies()
local kernel_version
local arch
local rhel_major
local py_version
local yum_utils_version
kernel_version=$(uname -r)
arch=$(uname -m)
rhel_major=${VERSION_ID%%.*}

if [ "${rhel_major}" -ge 8 ]; then
py_version="3"
else
py_version="2"
fi

sudo yum install -y git gcc gcc-c++ "kernel-devel-${kernel_version%.*}" elfutils elfutils-devel
sudo yum install -y yum-utils zlib-devel binutils-devel newt-devel \
python${py_version}-devel perl-ExtUtils-Embed audit-libs-devel numactl-devel \
pciutils-devel bison ncurses-devel rpm-build java-devel
sudo yum-builddep -y "kernel-${kernel_version%.*}"
# kpatch-build dependencies
sudo yum install -y \
elfutils \
elfutils-devel \
gcc \
gcc-c++ \
git \
"kernel-devel-${kernel_version%.*}" \
rpm-build \
wget \
yum-utils
sudo debuginfo-install -y "kernel-${kernel_version%.*}"
[[ "$arch" == "ppc64le" ]] && sudo yum install -y gcc-plugin-devel

case "${arch}" in
"x86_64")
sudo yum install -y pesign
;;
"ppc64le")
sudo yum install -y gcc-plugin-devel
if [ "${rhel_major}" -ge 8 ]; then
# yum-builddep doesn't provide everything we need :(
sudo yum install -y flex openssl-devel
fi
;;
*)
;;
esac

sudo yum install -y "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
sudo yum install -y ccache
sudo yum remove -y epel-release
# kernel dependencies
yum_utils_version=$(rpm -q --queryformat="%{version}" yum-utils)
if [[ "${yum_utils_version}" = "$(echo -e "${yum_utils_version}\\n4.0.12" | sort -rV | head -n1)" ]]; then
sudo yum-builddep -y --skip-unavailable "kernel-${kernel_version%.*}"
else
sudo yum-builddep -y "kernel-${kernel_version%.*}"
fi
[[ "$arch" == "x86_64" ]] && sudo yum install -y pesign

# ccache
if ! command -v ccache &> /dev/null; then
if ! sudo yum install -y ccache; then
sudo yum install -y "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${rhel_major}.noarch.rpm" && \
sudo yum install -y ccache && \
sudo yum remove -y epel-release
fi
fi
}

kpatch_centos_dependencies()
{
local kernel_version
local arch
kernel_version=$(uname -r)
arch=$(uname -m)

sudo yum install -y gcc gcc-c++ "kernel-devel-${kernel_version%.*}" elfutils elfutils-devel
sudo yum install -y yum-utils zlib-devel binutils-devel newt-devel \
python-devel perl-ExtUtils-Embed audit-libs-devel numactl-devel \
pciutils-devel bison ncurses-devel rpm-build java-devel pesign
sudo yum-config-manager --enable debug
sudo yum-builddep -y "kernel-${kernel_version%.*}"
sudo debuginfo-install -y "kernel-${kernel_version%.*}"
kpatch_rhel_dependencies
}

sudo yum install -y "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
sudo yum install -y ccache
sudo yum remove -y epel-release
kpatch_fedora_dependencies()
{
kpatch_rhel_dependencies
}

kpatch_openEuler_dependencies()
Expand Down