From: Michael Jeanson Date: Fri, 29 Jun 2018 21:28:32 +0000 (-0400) Subject: Cleanup: move scripts to subdirectory X-Git-Tag: v2.11.0-rc1~13 X-Git-Url: http://git.lttng.org/?p=lttng-modules.git;a=commitdiff_plain;h=6c27a5ccba05b088fbfcf8cd982c25649838298d Cleanup: move scripts to subdirectory Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/Kbuild.common b/Kbuild.common index bd24e801..c7cbd0b2 100644 --- a/Kbuild.common +++ b/Kbuild.common @@ -1,52 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + # Work-around for distro-specific public modules ABI breakages. # Some distributions break the public module instrumentation ABI # compared to upstream stable kernels without providing other mean than # the kernel EXTRAVERSION to figure it out. Translate this information # into a define visible from the C preprocessor. -DEB_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/abi-debian-version.sh $(CURDIR)) +DEB_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-debian-version.sh $(CURDIR)) ifneq ($(DEB_API_VERSION), 0) ccflags-y += -DDEBIAN_API_VERSION=$(DEB_API_VERSION) endif -RHEL_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/abi-rhel-version.sh $(CURDIR)) +RHEL_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-rhel-version.sh $(CURDIR)) ifneq ($(RHEL_API_VERSION), 0) ccflags-y += -DRHEL_API_VERSION=$(RHEL_API_VERSION) endif -SLE_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/abi-sle-version.sh $(CURDIR)) +SLE_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-sle-version.sh $(CURDIR)) ifneq ($(SLE_API_VERSION), 0) ccflags-y += -DSLE_API_VERSION=$(SLE_API_VERSION) endif -FEDORA_REVISION_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/abi-fedora-version.sh $(CURDIR)) +FEDORA_REVISION_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-fedora-version.sh $(CURDIR)) ifneq ($(FEDORA_REVISION_VERSION), 0) ccflags-y += -DFEDORA_REVISION_VERSION=$(FEDORA_REVISION_VERSION) endif -RT_PATCH_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/rt-patch-version.sh $(CURDIR)) +RT_PATCH_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/rt-patch-version.sh $(CURDIR)) ifneq ($(RT_PATCH_VERSION), 0) ccflags-y += -DRT_PATCH_VERSION=$(RT_PATCH_VERSION) endif -EXTRA_VERSION_NAME:=$(shell $(TOP_LTTNG_MODULES_DIR)/extra-version-name.sh $(TOP_LTTNG_MODULES_DIR)) +EXTRA_VERSION_NAME:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-name.sh $(TOP_LTTNG_MODULES_DIR)) ifneq ($(EXTRA_VERSION_NAME), 0) ccflags-y += -DLTTNG_EXTRA_VERSION_NAME='"$(EXTRA_VERSION_NAME)"' endif -EXTRA_VERSION_GIT:=$(shell $(TOP_LTTNG_MODULES_DIR)/extra-version-git.sh $(TOP_LTTNG_MODULES_DIR)) +EXTRA_VERSION_GIT:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-git.sh $(TOP_LTTNG_MODULES_DIR)) ifneq ($(EXTRA_VERSION_GIT), 0) ccflags-y += -DLTTNG_EXTRA_VERSION_GIT='"$(EXTRA_VERSION_GIT)"' endif -EXTRA_VERSION_PATCHES:=$(shell $(TOP_LTTNG_MODULES_DIR)/extra-version-patches.sh $(TOP_LTTNG_MODULES_DIR)) +EXTRA_VERSION_PATCHES:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-patches.sh $(TOP_LTTNG_MODULES_DIR)) # Starting with kernel 4.12, the ftrace header was moved to private headers # and as such is not available when building against distro headers instead diff --git a/README.md b/README.md index 93e2dd35..201a579c 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,10 @@ kernel, do: ### Kernel built-in support It is also possible to build these modules as part of a kernel image. Simply -run the [`built-in.sh`](built-in.sh) script with the path to your kernel -source directory as an argument. It will symlink the lttng-modules directory -in the kernel sources and add an include in the kernel Makefile. +run the [`scripts/built-in.sh`](scripts/built-in.sh) script with the path to +your kernel source directory as an argument. It will symlink the +lttng-modules directory in the kernel sources and add an include in the kernel +Makefile. Then configure your kernel as usual and enable the `CONFIG_LTTNG` option. diff --git a/abi-debian-version.sh b/abi-debian-version.sh deleted file mode 100755 index 4f2c0886..00000000 --- a/abi-debian-version.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -# First argument is the path to the kernel headers. -KPATH="$1" - -if [ ! -f "${KPATH}/include/generated/package.h" ]; then - echo 0 - exit 0 -fi - -# Debian snippet courtesy of Ben Hutchings - -# Assuming KPATH is the target kernel headers directory -DEB_PACKAGE_VERSION=$(sed -rn 's/^#define LINUX_PACKAGE_ID " Debian (.*)"/\1/p' "${KPATH}/include/generated/package.h") - -# Ignore backports part -DEB_PACKAGE_VERSION=$(echo "${DEB_PACKAGE_VERSION}" | sed -r 's/~(bpo|deb).*//') - -# ckt (Canonical Kernel Team) kernels were used for a while during the jessie -# cycle, their versionning is a bit different. They track the upstream vanilla -# stable updates but they don't update the minor version number and instead add -# an additionnal -cktX. They were all 3.16.7-cktX and after a while the version -# switched back to upstream style at 3.16.36. - -# Get -ckt update number, if present -KERNEL_CKT_UPDATE=$(echo "${DEB_PACKAGE_VERSION}" | sed -rn 's/^[0-9]+\.[0-9]+\.[0-9]+-ckt([0-9]+).*/\1/p') -test -n "${KERNEL_CKT_UPDATE}" || KERNEL_CKT_UPDATE=0 - -# Get package revision -DEB_PACKAGE_REVISION=$(echo "${DEB_PACKAGE_VERSION}" | sed -r 's/.*-([^-]+)$/\1/') -# Get non-sec update number -DEB_PACKAGE_REVISION_BASE=$(echo "${DEB_PACKAGE_REVISION}" | sed -r 's/^([0-9]+).*/\1/') -# Get security update number, if present -DEB_PACKAGE_REVISION_SECURITY=$(echo "${DEB_PACKAGE_REVISION}" | sed -rn 's/.*\+(squeeze|deb[0-9]+)+u([0-9]+)$/\2/p') -test -n "${DEB_PACKAGE_REVISION_SECURITY}" || DEB_PACKAGE_REVISION_SECURITY=0 -# Combine all update numbers into one -DEB_API_VERSION=$((KERNEL_CKT_UPDATE * 10000 + DEB_PACKAGE_REVISION_BASE * 100 + DEB_PACKAGE_REVISION_SECURITY)) - -echo ${DEB_API_VERSION} diff --git a/abi-fedora-version.sh b/abi-fedora-version.sh deleted file mode 100755 index 52dd0446..00000000 --- a/abi-fedora-version.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -# First argument is the path to the kernel headers. -KPATH="$1" - -if [ ! -f "${KPATH}/include/generated/utsrelease.h" ]; then - echo 0 - exit 0 -fi - -# Assuming KPATH is the target kernel headers directory -UTS_RELEASE=$(sed -rn 's/^#define UTS_RELEASE "(.*)"/\1/p' "${KPATH}/include/generated/utsrelease.h") -FEDORA_VERSION=$(echo "${UTS_RELEASE}" | sed -n 's/.*\.fc\([0-9]*\)\..*/\1/p') - -if [ "x${FEDORA_VERSION}" = "x" ]; then - echo 0 - exit 0 -fi - -FEDORA_REVISION_VERSION=$(echo "${UTS_RELEASE}" | sed -n 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\-\([0-9]*\).*/\4/p') -echo "${FEDORA_REVISION_VERSION}" diff --git a/abi-rhel-version.sh b/abi-rhel-version.sh deleted file mode 100755 index bd5328ac..00000000 --- a/abi-rhel-version.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -# First argument is the path to the kernel headers. -KPATH="$1" - -if [ ! -f "${KPATH}/include/generated/uapi/linux/version.h" ]; then - echo 0 - exit 0 -fi - -# Assuming KPATH is the target kernel headers directory -RHEL_RELEASE=$(sed -rn 's/^#define RHEL_RELEASE "(.*)"/\1/p' "${KPATH}/include/generated/uapi/linux/version.h") - -RHEL_RELEASE_MAJOR=$(echo "${RHEL_RELEASE}" | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\1/') -RHEL_RELEASE_MINOR=$(echo "${RHEL_RELEASE}" | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\2/') -RHEL_RELEASE_PATCH=$(echo "${RHEL_RELEASE}" | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\3/') - -# Combine all update numbers into one -RHEL_API_VERSION=$((RHEL_RELEASE_MAJOR * 10000 + RHEL_RELEASE_MINOR * 100 + RHEL_RELEASE_PATCH)) - -echo ${RHEL_API_VERSION} diff --git a/abi-sle-version.sh b/abi-sle-version.sh deleted file mode 100755 index 0bd65b15..00000000 --- a/abi-sle-version.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -# First argument is the path to the kernel headers. -KPATH=$1 - -if [ ! -f "${KPATH}/include/generated/autoconf.h" ]; then - echo 0 - exit 0 -fi - -# Check if we are building against a Suse kernel -SUSE_KERNEL="$(sed -rn 's/^#define CONFIG_SUSE_KERNEL (.*)/\1/p' "${KPATH}/include/generated/autoconf.h")" - -if [ "$SUSE_KERNEL" != "1" ]; then - echo 0 - exit 0 -fi - - -if [ ! -f "${KPATH}/include/generated/utsrelease.h" ]; then - echo 0 - exit 0 -fi - -SLE_RELEASE="$(sed -rn 's/^#define UTS_RELEASE "(.*)-([0-9\.]+)-(.*)"/\2/p' "${KPATH}/include/generated/utsrelease.h")" - -SLE_RELEASE_MAJOR="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)(.*)$/\1/p')" -SLE_RELEASE_MINOR="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)\.([0-9]+)(.*)$/\2/p')" -SLE_RELEASE_PATCH="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)\.([0-9]+)\.([0-9]+)(.*)$/\3/p')" - -# Minor and patch versions can be omitted -if [ "x$SLE_RELEASE_MINOR" = "x" ]; then - SLE_RELEASE_MINOR=0 -fi -if [ "x$SLE_RELEASE_PATCH" = "x" ]; then - SLE_RELEASE_PATCH=0 -fi - -# Combine all update numbers into one -SLE_API_VERSION="$((SLE_RELEASE_MAJOR * 10000 + SLE_RELEASE_MINOR * 100 + SLE_RELEASE_PATCH))" - -echo ${SLE_API_VERSION} diff --git a/built-in.sh b/built-in.sh deleted file mode 100755 index 782985f9..00000000 --- a/built-in.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -e - -usage() { - echo "usage: $0 " >&2 - exit 1 -} - -[ "$#" -eq 1 ] || usage -KERNEL_DIR="$(readlink --canonicalize-existing "$1")" - -# Symlink the lttng-modules directory in the kernel source -ln -sf "$(pwd)" "${KERNEL_DIR}/lttng" - -# Graft ourself to the kernel build system -echo 'source "lttng/Kconfig"' >> "${KERNEL_DIR}/Kconfig" -sed -i 's#+= kernel/#+= kernel/ lttng/#' "${KERNEL_DIR}/Makefile" - -echo >&2 -echo " $0: done." >&2 -echo " $0: now you can build the kernel with LTTng support." >&2 -echo " $0: make sure you enable it (CONFIG_LTTNG) before building." >&2 -echo >&2 diff --git a/extra-version-git.sh b/extra-version-git.sh deleted file mode 100755 index e5a3e176..00000000 --- a/extra-version-git.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) - -# First argument is the path to the lttng modules sources. -TOP_LTTNG_MODULES_DIR="$1" - -GIT_VERSION="0" - -if test -x "$(which git 2>&1;true)" && test -r "${TOP_LTTNG_MODULES_DIR}/.git"; then - GIT_VERSION_STR="$(cd "${TOP_LTTNG_MODULES_DIR}" && git describe --tags --dirty)" - GIT_CURRENT_TAG="$(cd "${TOP_LTTNG_MODULES_DIR}" && git describe --tags --exact-match --match="v[0-9]*" HEAD 2> /dev/null)" - - GIT_VERSION="${GIT_VERSION_STR}" - - if ! echo "${GIT_VERSION_STR}" | grep -- "-dirty" >/dev/null && test "x$GIT_CURRENT_TAG" != "x"; then - GIT_VERSION="0" - fi -fi - -echo "${GIT_VERSION}" diff --git a/extra-version-name.sh b/extra-version-name.sh deleted file mode 100755 index f7042567..00000000 --- a/extra-version-name.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) - -# First argument is the path to the lttng modules sources. -TOP_LTTNG_MODULES_DIR="$1" - -EXTRA_VERSION_NAME="$(sed -n '1p' "${TOP_LTTNG_MODULES_DIR}/extra_version/name" 2> /dev/null)" - -if [ "x${EXTRA_VERSION_NAME}" != "x" ]; then - echo "${EXTRA_VERSION_NAME}" -else - echo "0" -fi diff --git a/extra-version-patches.sh b/extra-version-patches.sh deleted file mode 100755 index 4e8a1b52..00000000 --- a/extra-version-patches.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) - -# First argument is the path to the lttng modules sources. -TOP_LTTNG_MODULES_DIR="$1" - -if ! test -d "${TOP_LTTNG_MODULES_DIR}"; then - exit 1 -fi - -TMPFILE="$(mktemp)" - -find "${TOP_LTTNG_MODULES_DIR}/extra_version/patches/" -maxdepth 1 ! -name 'README' -type f -printf '%f\n' | sort -r \ - | sed -E 's/[^a-zA-Z0-9 \.]/-/g ; s/(.*)/MODULE_INFO(extra_version_patch, "\1");/g' >"${TMPFILE}" 2>/dev/null - -if test ! -f "${TOP_LTTNG_MODULES_DIR}/extra_version/patches.i" || \ - test x"$(cat "${TMPFILE}")" != x"$(cat "${TOP_LTTNG_MODULES_DIR}/extra_version/patches.i")"; then - mv "${TMPFILE}" "${TOP_LTTNG_MODULES_DIR}/extra_version/patches.i" -fi - -rm -f "${TMPFILE}" diff --git a/rt-patch-version.sh b/rt-patch-version.sh deleted file mode 100755 index 6a00fef0..00000000 --- a/rt-patch-version.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -# First argument is the path to the kernel headers. -KPATH="$1" - -VERSIONFILE="" - -if [ -f "${KPATH}/localversion-rt" ]; then - VERSIONFILE="${KPATH}/localversion-rt" - -elif [ -f "${KPATH}/source/localversion-rt" ]; then - VERSIONFILE="${KPATH}/source/localversion-rt" -else - echo 0 - exit 0 -fi - -RT_PATCH_VERSION=$(sed -rn 's/^-rt([0-9]+)$/\1/p' "${VERSIONFILE}") - -if [ "x${RT_PATCH_VERSION}" = "x" ]; then - echo 0 - exit 0 -fi - -echo "${RT_PATCH_VERSION}" diff --git a/scripts/abi-debian-version.sh b/scripts/abi-debian-version.sh new file mode 100755 index 00000000..ee8dbd80 --- /dev/null +++ b/scripts/abi-debian-version.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + +# First argument is the path to the kernel headers. +KPATH="$1" + +if [ ! -f "${KPATH}/include/generated/package.h" ]; then + echo 0 + exit 0 +fi + +# Debian snippet courtesy of Ben Hutchings + +# Assuming KPATH is the target kernel headers directory +DEB_PACKAGE_VERSION=$(sed -rn 's/^#define LINUX_PACKAGE_ID " Debian (.*)"/\1/p' "${KPATH}/include/generated/package.h") + +# Ignore backports part +DEB_PACKAGE_VERSION=$(echo "${DEB_PACKAGE_VERSION}" | sed -r 's/~(bpo|deb).*//') + +# ckt (Canonical Kernel Team) kernels were used for a while during the jessie +# cycle, their versionning is a bit different. They track the upstream vanilla +# stable updates but they don't update the minor version number and instead add +# an additionnal -cktX. They were all 3.16.7-cktX and after a while the version +# switched back to upstream style at 3.16.36. + +# Get -ckt update number, if present +KERNEL_CKT_UPDATE=$(echo "${DEB_PACKAGE_VERSION}" | sed -rn 's/^[0-9]+\.[0-9]+\.[0-9]+-ckt([0-9]+).*/\1/p') +test -n "${KERNEL_CKT_UPDATE}" || KERNEL_CKT_UPDATE=0 + +# Get package revision +DEB_PACKAGE_REVISION=$(echo "${DEB_PACKAGE_VERSION}" | sed -r 's/.*-([^-]+)$/\1/') +# Get non-sec update number +DEB_PACKAGE_REVISION_BASE=$(echo "${DEB_PACKAGE_REVISION}" | sed -r 's/^([0-9]+).*/\1/') +# Get security update number, if present +DEB_PACKAGE_REVISION_SECURITY=$(echo "${DEB_PACKAGE_REVISION}" | sed -rn 's/.*\+(squeeze|deb[0-9]+)+u([0-9]+)$/\2/p') +test -n "${DEB_PACKAGE_REVISION_SECURITY}" || DEB_PACKAGE_REVISION_SECURITY=0 +# Combine all update numbers into one +DEB_API_VERSION=$((KERNEL_CKT_UPDATE * 10000 + DEB_PACKAGE_REVISION_BASE * 100 + DEB_PACKAGE_REVISION_SECURITY)) + +echo ${DEB_API_VERSION} diff --git a/scripts/abi-fedora-version.sh b/scripts/abi-fedora-version.sh new file mode 100755 index 00000000..41534821 --- /dev/null +++ b/scripts/abi-fedora-version.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + +# First argument is the path to the kernel headers. +KPATH="$1" + +if [ ! -f "${KPATH}/include/generated/utsrelease.h" ]; then + echo 0 + exit 0 +fi + +# Assuming KPATH is the target kernel headers directory +UTS_RELEASE=$(sed -rn 's/^#define UTS_RELEASE "(.*)"/\1/p' "${KPATH}/include/generated/utsrelease.h") +FEDORA_VERSION=$(echo "${UTS_RELEASE}" | sed -n 's/.*\.fc\([0-9]*\)\..*/\1/p') + +if [ "x${FEDORA_VERSION}" = "x" ]; then + echo 0 + exit 0 +fi + +FEDORA_REVISION_VERSION=$(echo "${UTS_RELEASE}" | sed -n 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\-\([0-9]*\).*/\4/p') +echo "${FEDORA_REVISION_VERSION}" diff --git a/scripts/abi-rhel-version.sh b/scripts/abi-rhel-version.sh new file mode 100755 index 00000000..0296d8c8 --- /dev/null +++ b/scripts/abi-rhel-version.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + +# First argument is the path to the kernel headers. +KPATH="$1" + +if [ ! -f "${KPATH}/include/generated/uapi/linux/version.h" ]; then + echo 0 + exit 0 +fi + +# Assuming KPATH is the target kernel headers directory +RHEL_RELEASE=$(sed -rn 's/^#define RHEL_RELEASE "(.*)"/\1/p' "${KPATH}/include/generated/uapi/linux/version.h") + +RHEL_RELEASE_MAJOR=$(echo "${RHEL_RELEASE}" | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\1/') +RHEL_RELEASE_MINOR=$(echo "${RHEL_RELEASE}" | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\2/') +RHEL_RELEASE_PATCH=$(echo "${RHEL_RELEASE}" | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\3/') + +# Combine all update numbers into one +RHEL_API_VERSION=$((RHEL_RELEASE_MAJOR * 10000 + RHEL_RELEASE_MINOR * 100 + RHEL_RELEASE_PATCH)) + +echo ${RHEL_API_VERSION} diff --git a/scripts/abi-sle-version.sh b/scripts/abi-sle-version.sh new file mode 100755 index 00000000..bd6d5f1d --- /dev/null +++ b/scripts/abi-sle-version.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + +# First argument is the path to the kernel headers. +KPATH=$1 + +if [ ! -f "${KPATH}/include/generated/autoconf.h" ]; then + echo 0 + exit 0 +fi + +# Check if we are building against a Suse kernel +SUSE_KERNEL="$(sed -rn 's/^#define CONFIG_SUSE_KERNEL (.*)/\1/p' "${KPATH}/include/generated/autoconf.h")" + +if [ "$SUSE_KERNEL" != "1" ]; then + echo 0 + exit 0 +fi + + +if [ ! -f "${KPATH}/include/generated/utsrelease.h" ]; then + echo 0 + exit 0 +fi + +SLE_RELEASE="$(sed -rn 's/^#define UTS_RELEASE "(.*)-([0-9\.]+)-(.*)"/\2/p' "${KPATH}/include/generated/utsrelease.h")" + +SLE_RELEASE_MAJOR="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)(.*)$/\1/p')" +SLE_RELEASE_MINOR="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)\.([0-9]+)(.*)$/\2/p')" +SLE_RELEASE_PATCH="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)\.([0-9]+)\.([0-9]+)(.*)$/\3/p')" + +# Minor and patch versions can be omitted +if [ "x$SLE_RELEASE_MINOR" = "x" ]; then + SLE_RELEASE_MINOR=0 +fi +if [ "x$SLE_RELEASE_PATCH" = "x" ]; then + SLE_RELEASE_PATCH=0 +fi + +# Combine all update numbers into one +SLE_API_VERSION="$((SLE_RELEASE_MAJOR * 10000 + SLE_RELEASE_MINOR * 100 + SLE_RELEASE_PATCH))" + +echo ${SLE_API_VERSION} diff --git a/scripts/built-in.sh b/scripts/built-in.sh new file mode 100755 index 00000000..5e57e934 --- /dev/null +++ b/scripts/built-in.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + +set -e + +usage() { + echo "usage: $0 " >&2 + exit 1 +} + +[ "$#" -eq 1 ] || usage +KERNEL_DIR="$(readlink --canonicalize-existing "$1")" + +# Symlink the lttng-modules directory in the kernel source +ln -sf "$(pwd)" "${KERNEL_DIR}/lttng" + +# Graft ourself to the kernel build system +echo 'source "lttng/Kconfig"' >> "${KERNEL_DIR}/Kconfig" +sed -i 's#+= kernel/#+= kernel/ lttng/#' "${KERNEL_DIR}/Makefile" + +echo >&2 +echo " $0: done." >&2 +echo " $0: now you can build the kernel with LTTng support." >&2 +echo " $0: make sure you enable it (CONFIG_LTTNG) before building." >&2 +echo >&2 diff --git a/scripts/extra-version-git.sh b/scripts/extra-version-git.sh new file mode 100755 index 00000000..e5a3e176 --- /dev/null +++ b/scripts/extra-version-git.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + +# First argument is the path to the lttng modules sources. +TOP_LTTNG_MODULES_DIR="$1" + +GIT_VERSION="0" + +if test -x "$(which git 2>&1;true)" && test -r "${TOP_LTTNG_MODULES_DIR}/.git"; then + GIT_VERSION_STR="$(cd "${TOP_LTTNG_MODULES_DIR}" && git describe --tags --dirty)" + GIT_CURRENT_TAG="$(cd "${TOP_LTTNG_MODULES_DIR}" && git describe --tags --exact-match --match="v[0-9]*" HEAD 2> /dev/null)" + + GIT_VERSION="${GIT_VERSION_STR}" + + if ! echo "${GIT_VERSION_STR}" | grep -- "-dirty" >/dev/null && test "x$GIT_CURRENT_TAG" != "x"; then + GIT_VERSION="0" + fi +fi + +echo "${GIT_VERSION}" diff --git a/scripts/extra-version-name.sh b/scripts/extra-version-name.sh new file mode 100755 index 00000000..f7042567 --- /dev/null +++ b/scripts/extra-version-name.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + +# First argument is the path to the lttng modules sources. +TOP_LTTNG_MODULES_DIR="$1" + +EXTRA_VERSION_NAME="$(sed -n '1p' "${TOP_LTTNG_MODULES_DIR}/extra_version/name" 2> /dev/null)" + +if [ "x${EXTRA_VERSION_NAME}" != "x" ]; then + echo "${EXTRA_VERSION_NAME}" +else + echo "0" +fi diff --git a/scripts/extra-version-patches.sh b/scripts/extra-version-patches.sh new file mode 100755 index 00000000..4e8a1b52 --- /dev/null +++ b/scripts/extra-version-patches.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + +# First argument is the path to the lttng modules sources. +TOP_LTTNG_MODULES_DIR="$1" + +if ! test -d "${TOP_LTTNG_MODULES_DIR}"; then + exit 1 +fi + +TMPFILE="$(mktemp)" + +find "${TOP_LTTNG_MODULES_DIR}/extra_version/patches/" -maxdepth 1 ! -name 'README' -type f -printf '%f\n' | sort -r \ + | sed -E 's/[^a-zA-Z0-9 \.]/-/g ; s/(.*)/MODULE_INFO(extra_version_patch, "\1");/g' >"${TMPFILE}" 2>/dev/null + +if test ! -f "${TOP_LTTNG_MODULES_DIR}/extra_version/patches.i" || \ + test x"$(cat "${TMPFILE}")" != x"$(cat "${TOP_LTTNG_MODULES_DIR}/extra_version/patches.i")"; then + mv "${TMPFILE}" "${TOP_LTTNG_MODULES_DIR}/extra_version/patches.i" +fi + +rm -f "${TMPFILE}" diff --git a/scripts/rt-patch-version.sh b/scripts/rt-patch-version.sh new file mode 100755 index 00000000..27049657 --- /dev/null +++ b/scripts/rt-patch-version.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + +# First argument is the path to the kernel headers. +KPATH="$1" + +VERSIONFILE="" + +if [ -f "${KPATH}/localversion-rt" ]; then + VERSIONFILE="${KPATH}/localversion-rt" + +elif [ -f "${KPATH}/source/localversion-rt" ]; then + VERSIONFILE="${KPATH}/source/localversion-rt" +else + echo 0 + exit 0 +fi + +RT_PATCH_VERSION=$(sed -rn 's/^-rt([0-9]+)$/\1/p' "${VERSIONFILE}") + +if [ "x${RT_PATCH_VERSION}" = "x" ]; then + echo 0 + exit 0 +fi + +echo "${RT_PATCH_VERSION}"