packaging: merge packaging repository

git-subtree-dir: tools/packaging
git-subtree-mainline: f818b46a41
git-subtree-split: 1f22d72d5d

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao
2020-06-23 22:49:04 -07:00
645 changed files with 292694 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
# Installation variables
DESTDIR :=
DEFAULTSDIR := /usr/share/
PROJECT_DIR := Kata-containers
VMLINUX := @VMLINUX@
VMLINUZ := @VMLINUZ@
DESTSYSCONFDIR := $(abspath $(DESTDIR)/$(DEFAULTSDIR)/$(PROJECT_DIR))
VMLINUX_DEST := $(abspath $(DESTSYSCONFDIR)/$(VMLINUX))
VMLINUZ_DEST := $(abspath $(DESTSYSCONFDIR)/$(VMLINUZ))
install:
install -D --owner root --group root --mode 0644 $(VMLINUX) $(VMLINUX_DEST)
install -D --owner root --group root --mode 0644 $(VMLINUZ) $(VMLINUZ_DEST)
ln -sf $(VMLINUX_DEST) $(DESTSYSCONFDIR)/vmlinuz.container
ln -sf $(VMLINUZ_DEST) $(DESTSYSCONFDIR)/vmlinux.container

View File

@@ -0,0 +1,13 @@
<!--- XML Structure defined here: https://en.opensuse.org/openSUSE:Build_Service_Concept_SourceService -->
<services>
<service name="download_url">
<param name="protocol">https</param>
<param name="host">cdn.kernel.org</param>
<param name="path">/pub/linux/kernel/v5.x/linux-@VERSION@.tar.xz</param>
</service>
<service name="verify_file">
<param name="file">_service:download_url:linux-@VERSION@.tar.xz</param>
<param name="verifier">sha256</param>
<param name="checksum">@KERNEL_SHA256@</param>
</service>
</services>

View File

@@ -0,0 +1 @@
9

View File

@@ -0,0 +1,18 @@
Source: kata-linux-container
Section: devel
Priority: optional
Maintainer: Kata containers team <https://github.com/kata-containers/>
Build-Depends: debhelper (>= 9), cpio, libelf-dev, libnewt-dev, libiberty-dev, rsync, libdw-dev, libpci-dev, pkg-config, flex, bison, libunwind8-dev, openssl, libaudit-dev, bc, python-dev, gawk, autoconf, automake, libtool, libssl-dev
Standards-Version: 3.9.6
Homepage: https://katacontainers.io
Package: kata-linux-container
Architecture: @deb_arch@
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends},
Description: linux kernel optimised for container-like workloads.
Linux kernel optimised for container-like workloads
Package: kata-linux-container-debug
Architecture: @deb_arch@
Description: Debug components for the kata-linux-container package.
This package includes the kernel config and the kernel map.

View File

@@ -0,0 +1,30 @@
This is the Kata containers prepackaged version of the Linux kernel.
Linux was written by Linus Torvalds <Linus.Torvalds@cs.Helsinki.FI>
and others.
This package was put together by the Kata containers team, from
sources retrieved from upstream linux git.
The sources may be found at most Linux download websites, including
https://www.kernel.org/pub/linux/kernel/
This package is currently maintained by the
Kata containers team <https://github.com/kata-containers/
Linux is copyrighted by Linus Torvalds and others.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 dated June, 1991.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
On your Linux system, the complete text of the GNU General
Public License v2 can be found in `/usr/share/common-licenses/GPL-2'.
copyright (END)

View File

@@ -0,0 +1 @@
usr/share/Kata-containers

View File

@@ -0,0 +1,63 @@
#!/usr/bin/make -f
include /usr/share/dpkg/default.mk
KernelDir=debian/kata-linux-container/usr/share/kata-containers
DebugDir=debian/kata-linux-container-debug/usr/share/kata-containers
KernelVer=${DEB_VERSION_UPSTREAM_REVISION}.container
HOST_ARCH=$(shell arch)
KATA_MULTIARCH="/usr/src/packages/SOURCES/kata-multiarch.sh"
KERNEL_ARCH=$(shell /bin/bash $(KATA_MULTIARCH) -a $(HOST_ARCH))
KERNEL_IMAGE=$(shell /bin/bash $(KATA_MULTIARCH) -i $(HOST_ARCH))
KERNEL_CONFIGS=kata-kernel-configs
KERNEL_FRAG_COMMON_DIR="$(KERNEL_CONFIGS)/fragments/common"
KERNEL_FRAG_ARCH_DIR="$(KERNEL_CONFIGS)/fragments/$(KERNEL_ARCH)"
# used in merge_config.sh
export KCONFIG_CONFIG=.config
export ARCH=$(KERNEL_ARCH)
%:
dh $@
override_dh_auto_build:
sed -i "s/^EXTRAVERSION.*/EXTRAVERSION = -$$(echo $(KernelVer) | cut -d'-' -f2)/" Makefile
tar xzf /usr/src/packages/SOURCES/$(KERNEL_CONFIGS).tar.gz
rm -f .config
find $(KERNEL_CONFIGS) -name "$(KERNEL_ARCH)_kata_kvm_*" -exec cp {} .config \;
if [ ! -f .config ]; then \
scripts/kconfig/merge_config.sh -r -n $(KERNEL_FRAG_COMMON_DIR)/*.conf $(KERNEL_FRAG_ARCH_DIR)/* ; \
if [ ! -f .config ]; then \
echo "ERROR: cannot find the kernel config file for the $(KERNEL_ARCH) architecture"; \
exit 1; \
fi \
fi
# https://github.com/kata-containers/packaging/issues/394 enable reproducible builds:
export KBUILD_BUILD_USER=katabuilduser
export KBUILD_BUILD_HOST=katabuildhost
# Default to zero seconds after midnight 1970-01-01 (the epoch)
export KBUILD_BUILD_TIMESTAMP="$(LANG=C date -u -d "@${SOURCE_DATE_EPOCH:-0}")"
make -s ARCH=$(KERNEL_ARCH) oldconfig > /dev/null
make -s CONFIG_DEBUG_SECTION_MISMATCH=y ARCH=$(KERNEL_ARCH)
override_dh_auto_install:
override_dh_auto_clean:
override_dh_install:
dh_install
mkdir -p $(DebugDir)
mkdir -p $(KernelDir)
install -m 644 .config $(DebugDir)/config-$(KernelVer)
install -m 644 System.map $(DebugDir)/System.map-$(KernelVer)
if [ -n "$(KERNEL_IMAGE)" ]; then \
cp $$(realpath $(KERNEL_IMAGE)) $(KernelDir)/vmlinuz-$(KernelVer); \
chmod 755 $(KernelDir)/vmlinuz-$(KernelVer); \
ln -sf vmlinuz-$(KernelVer) $(KernelDir)/vmlinuz.container; \
fi
cp vmlinux $(KernelDir)/vmlinux-$(KernelVer)
chmod 755 $(KernelDir)/vmlinux-$(KernelVer)
ln -sf vmlinux-$(KernelVer) $(KernelDir)/vmlinux.container
override_dh_strip:
override_dh_shlibdeps:

View File

@@ -0,0 +1,20 @@
Format: 3.0 (quilt)
Source: kata-linux-container
Version: @VERSION@.@CONFIG_VERSION@-@RELEASE@
Section: devel
Priority: optional
Maintainer: Kata containers team <https://github.com/kata-containers/>
Build-Depends: debhelper (>= 9), cpio, libelf-dev, libnewt-dev, libiberty-dev, rsync, libdw-dev, libpci-dev, pkg-config, flex, bison, libunwind8-dev, openssl, libaudit-dev, bc, python-dev, gawk, autoconf, automake, libtool, libssl-dev
Standards-Version: 3.9.6
Homepage: https://katacontainers.io
Debtransform-Tar: linux-@VERSION@.tar.xz
Package: kata-linux-container
Architecture: @deb_arch@
Description: linux kernel optimised for container-like workloads.
Linux kernel optimised for container-like workloads
Package: kata-linux-container-debug
Architecture: @deb_arch@
Description: Debug components for the kata-linux-container package.
This package includes the kernel config and the kernel map.

View File

@@ -0,0 +1,165 @@
#
# This is a special configuration of the Linux kernel, aimed exclusively
# for running inside a container
# This specialization allows us to optimize memory footprint and boot time.
#
Name: kata-linux-container
Version: @VERSION@.@CONFIG_VERSION@
Release: @RELEASE@
License: GPL-2.0
Summary: The Linux kernel optimized for running inside a container
Group: System/Kernel
Url: http://www.kernel.org/
Source0: https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-@VERSION@.tar.xz
Source1: kata-kernel-configs.tar.gz
Source2: kata-multiarch.sh
%define kversion %{version}-%{release}.container
BuildRequires: bash >= 2.03
BuildRequires: bc
BuildRequires: binutils-devel
%if 0%{?rhel_version}
BuildRequires: elfutils-devel
%endif
%if 0%{?suse_version}
BuildRequires: libelf-devel
BuildRequires: fdupes
%endif
%if 0%{?fedora} || 0%{?centos} <= 7
BuildRequires: pkgconfig(libelf)
%endif
%if 0%{?centos} >= 8
BuildRequires: elfutils-libelf-devel
%endif
BuildRequires: make >= 3.78
BuildRequires: openssl-devel
BuildRequires: flex
BuildRequires: bison
# don't strip .ko files!
%global __os_install_post %{nil}
%define debug_package %{nil}
%define __strip /bin/true
# Patches
@RPM_PATCH_LIST@
%description
The Linux kernel.
%package debug
Summary: Debug components for the %{name} package
Group: System/Kernel
%description debug
Debug components for the kata-linux-container package.
This package includes the kernel config and the kernel map.
%prep
%setup -q -n linux-@VERSION@
%setup -q -T -D -n linux-@VERSION@ -a 1
cp %{SOURCE2} .
chmod +x $(basename %{SOURCE2})
# Patches
@RPM_APPLY_PATCHES@
%build
BuildKernel() {
local kernelArch=$(./kata-multiarch.sh -a %{_arch})
ExtraVer="-%{release}.container"
perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${ExtraVer}/" Makefile
make -s mrproper
# Runtime .config selection based on kernelArch
rm -f .config
find kata-kernel-configs -name "${kernelArch}_kata_kvm_*" -exec cp {} .config \;
if [ ! -f .config ]; then
# Use fragments to generate the .config
frag_dir="kata-kernel-configs/fragments"
KCONFIG_CONFIG=.config ARCH=${kernelArch} scripts/kconfig/merge_config.sh -r -n ${frag_dir}/common/*.conf ${frag_dir}/${kernelArch}/*
fi
[ -f .config ] || (echo "ERROR: cannot find the kernel config file for the ${kernelArch} architecture"; exit 1)
%if 0%{?rhel_version} || 0%{?suse_version}
# RHEL in OBS has updated gcc.
# https://github.com/kata-containers/packaging/pull/370#issuecomment-469620154
sed -i -e 's/CONFIG_RETPOLINE=y/CONFIG_RETPOLINE=n/g' .config
%endif
%if 0%{?fedora}
#Fedora uses gcc 8, build is failing due to warnings.
export CFLAGS="-Wno-error=restrict"
export EXTRA_CFLAGS="-Wno-format-truncation -Wno-cast-function-type -Wno-error=restrict -Wno-error"
%endif
# https://github.com/kata-containers/packaging/issues/394 enable reproducible builds:
export KBUILD_BUILD_USER=katabuilduser
export KBUILD_BUILD_HOST=katabuildhost
# Default to zero seconds after midnight 1970-01-01 (the epoch)
export KBUILD_BUILD_TIMESTAMP="$(LANG=C date -u -d "@${SOURCE_DATE_EPOCH:-0}")"
make -s ARCH=$kernelArch oldconfig > /dev/null
make -s CONFIG_DEBUG_SECTION_MISMATCH=y %{?_smp_mflags} ARCH=$kernelArch %{?sparse_mflags} || exit 1
}
BuildKernel
%install
InstallKernel() {
compressedImage=$(./kata-multiarch.sh -i %{_arch})
rawImage="vmlinux"
KernelVer=%{kversion}
KernelDir=%{buildroot}/usr/share/kata-containers
mkdir -p ${KernelDir}
if [ -n "$compressedImage" ]; then
cp "$compressedImage" ${KernelDir}/vmlinuz-$KernelVer
chmod 755 ${KernelDir}/vmlinuz-$KernelVer
ln -sf vmlinuz-$KernelVer ${KernelDir}/vmlinuz.container
fi
cp $rawImage ${KernelDir}/vmlinux-$KernelVer
chmod 755 ${KernelDir}/vmlinux-$KernelVer
ln -sf vmlinux-$KernelVer ${KernelDir}/vmlinux.container
cp .config "${KernelDir}/config-${KernelVer}"
cp System.map "${KernelDir}/System.map-${KernelVer}"
rm -f %{buildroot}/usr/lib/modules/$KernelVer/build
rm -f %{buildroot}/usr/lib/modules/$KernelVer/source
}
InstallKernel
rm -rf %{buildroot}/usr/lib/firmware
%if 0%{?suse_version}
%fdupes -s %{buildroot}
%endif
%files
%dir /usr/share/kata-containers
/usr/share/kata-containers/vmlinux-%{kversion}
/usr/share/kata-containers/vmlinux.container
%ifnarch ppc64le
/usr/share/kata-containers/vmlinuz-%{kversion}
/usr/share/kata-containers/vmlinuz.container
%endif
%files debug
%defattr(-,root,root,-)
/usr/share/kata-containers/config-%{kversion}
/usr/share/kata-containers/System.map-%{kversion}

View File

@@ -0,0 +1,60 @@
#!/usr/bin/env bash
set -e
# Convert architecture to the name used by the Linux kernel build system
arch_to_kernel() {
local -r arch="$1"
case "${arch}" in
aarch64) echo "arm64";;
ppc64le) echo "powerpc";;
s390|s390x) echo "s390";;
x86_64) echo "${arch}";;
*) echo "unsupported architecture: ${arch}" >&2; exit 1;;
esac
}
# Convert architecture to the location of the compressed linux image
arch_to_image() {
local -r arch="$1"
case "${arch}" in
aarch64)
echo "arch/arm64/boot/Image"
;;
ppc64le)
# No compressed image
;;
s390|s390x)
echo "arch/s390/boot/image"
;;
*)
echo "arch/${arch}/boot/bzImage"
;;
esac
}
usage() {
echo "$(basename $0) FLAG ARCHITECTURE"
echo "Allowed flags:"
echo " -a : Print kernel architecture"
echo " -i : Print kernel compressed image location (may be empty)"
}
if [ "$#" != "2" ]; then
echo -e "Invalid options\n\n$(usage)" >&2
exit 1
fi
case "$1" in
-a)
arch_to_kernel $2
;;
-i)
arch_to_image $2
;;
*)
echo -e "Invalid options\n\n$(usage)" >&2
exit 1
;;
esac

View File

@@ -0,0 +1,72 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# Automation script to create specs to build Kata containers kernel
[ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt
source ../scripts/pkglib.sh
SCRIPT_NAME=$0
SCRIPT_DIR=$(dirname $0)
PKG_NAME="kata-linux-container"
VERSION=$kernel_version
KATA_CONFIG_VERSION=$(cat "${SCRIPT_DIR}/../../kernel/kata_config_version")
KR_SERIES="$(echo $VERSION | cut -d "." -f 1).x"
KR_LTS=$(echo $VERSION | cut -d "." -f 1,2)
ln -sfT "${SCRIPT_DIR}/../../kernel/patches/${KR_LTS}.x" "${SCRIPT_DIR}/patches"
KR_PATCHES=$(eval find "${SCRIPT_DIR}/patches" -type f -name "*.patch")
KR_REL=https://www.kernel.org/releases.json
KR_SHA=https://cdn.kernel.org/pub/linux/kernel/v"${KR_SERIES}"/sha256sums.asc
KR_CONFIGS="kata-kernel-configs"
GENERATED_FILES=(kata-linux-container.dsc kata-linux-container.spec _service debian.control ${KR_CONFIGS}.tar.gz)
STATIC_FILES=(debian.dirs debian.rules debian.compat debian.copyright kata-multiarch.sh)
#STATIC_FILES+=($KR_PATCHES)
# Parse arguments
cli "$@"
[ "$VERBOSE" == "true" ] && set -x
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/linux-container}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
kernel_sha256=$(curl -L -s -f ${KR_SHA} | awk '/linux-'${VERSION}'.tar.xz/ {print $1}')
# Copy the kernel config files and fragments for all architecture
mkdir -p configs
readonly configs_dir="kernel/configs"
find "${SCRIPT_DIR}/../../${configs_dir}" \( -name "*_kata_kvm_${KR_LTS}.x" -o -name fragments \) -exec tar --transform="s,${configs_dir},${KR_CONFIGS}," -czf ${KR_CONFIGS}.tar.gz {} +
replace_list=(
"VERSION=${VERSION}"
"CONFIG_VERSION=${KATA_CONFIG_VERSION}"
"RELEASE=$RELEASE"
"KERNEL_SHA256=$kernel_sha256"
)
verify
echo "Verify succeed."
get_git_info
#TODO delete me: used by changelog_update
hash_tag="nocommit"
changelog_update "${VERSION}-${KATA_CONFIG_VERSION}"
generate_files "$SCRIPT_DIR" "${replace_list[@]}"
build_pkg "${PROJECT_REPO}"