Skip to content
Open
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
39 changes: 39 additions & 0 deletions ciq/SOURCES/bundle_bindgen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

# Bundle the bindgen-cli source code to be included in the kernel build.
# https://crates.io/crates/bindgen-cli
#
# The bindgen tool, required to build Rust code in the Linux kernel, is
# currently only packaged in Fedora/ELN. In order to build CLK kernels
# on Rocky Linux we need to build bindgen as part of the kernel build.

SOURCES=$1

BINDGEN_CLI=bindgen-cli
BINDGEN_CLI_VERSION="0.71.1"
BINDGEN_CLI_CRATE=bindgen-cli.crate
CRATESIO_API_ENDPOINT=https://crates.io/api/v1/crates/bindgen-cli/${BINDGEN_CLI_VERSION}/download

curl -sL $CRATESIO_API_ENDPOINT -o $SOURCES/$BINDGEN_CLI_CRATE
tar -xf $SOURCES/$BINDGEN_CLI_CRATE -C $SOURCES
mv $SOURCES/$BINDGEN_CLI-$BINDGEN_CLI_VERSION $SOURCES/$BINDGEN_CLI

# vendor bindgen-cli
cd $SOURCES/$BINDGEN_CLI
mkdir .cargo
cat > .cargo/config.toml <<EOF
[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"
EOF

cargo vendor --locked --quiet

cd ..
tar czf $BINDGEN_CLI.tar.gz $BINDGEN_CLI

# clean up
rm -f $SOURCES/$BINDGEN_CLI_CRATE
rm -rf $SOURCES/$BINDGEN_CLI
24 changes: 14 additions & 10 deletions ciq/SOURCES/generate_tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
DISTGIT_ROOT="$(dirname "$SCRIPT_DIR")"
SOURCE_DIR="$DISTGIT_ROOT/SOURCES"
SPEC_FILE="$DISTGIT_ROOT/SPECS/kernel.spec"
SPEC_FILE="$DISTGIT_ROOT/SPECS/kernel-clk6.12.spec"

# Extract version information from spec file
TARFILE_RELEASE=$(grep '^%define tarfile_release' "$SPEC_FILE" | awk '{print $3}')
SPEC_VERSION=$(grep '^%define specversion' "$SPEC_FILE" | awk '{print $3}')

if [ -z "$TARFILE_RELEASE" ]; then
echo "Error: Could not extract tarfile_release from $SPEC_FILE"
KERNEL_MAJOR_MINOR=$(grep '^%define kernel_major_minor' "$SPEC_FILE" | awk '{print $3}')
KERNEL_PATCH=$(grep '^%define kernel_patch' "$SPEC_FILE" | awk '{print $3}')
BUILDID=$(grep '^%define buildid' "$SPEC_FILE" | awk '{print $3}')
PKGRELEASE=$(grep '^%define pkgrelease' "$SPEC_FILE" | awk '{print $3}')
EL_VERSION=$(grep '^%define el_version' "$SPEC_FILE" | awk '{print $3}')

if [ -z "$KERNEL_MAJOR_MINOR" ] || [ -z "$KERNEL_PATCH" ] || [ -z "$PKGRELEASE" ] || [ -z "$EL_VERSION" ]; then
echo "Error: Could not extract kernel version from $SPEC_FILE"
exit 1
fi

if [ -z "$SPEC_VERSION" ]; then
echo "Error: Could not extract specversion from $SPEC_FILE"
exit 1
fi
# Resolve macros in pkgrelease
PKGRELEASE=$(echo "$PKGRELEASE" | sed "s/%{?buildid}/${BUILDID}/")

SPEC_VERSION="${KERNEL_MAJOR_MINOR}.${KERNEL_PATCH}"
TARFILE_RELEASE="${SPEC_VERSION}-${PKGRELEASE}.el${EL_VERSION}"

# Get current git tag and extract version
CURRENT_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
Expand Down
89 changes: 87 additions & 2 deletions ciq/SOURCES/merge.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,88 @@
#!/usr/bin/env python3
print("merge.py stub: no merge performed")
#!/usr/bin/python3
# SPDX-License-Identifier: GPL-2.0
# Author: Clark Williams <williams@redhat.com>
# Copyright (C) 2022 Red Hat, Inc.
#
# merge.py - a direct replacement for merge.pl in the redhat/configs directory
#
# invocation: python merge.py overrides baseconfig [arch]
#
# This script merges two kernel configuration files, an override file and a
# base config file and writes the results to stdout.
#
# The script reads the overrides into a dictionary, then reads the baseconfig
# file, looking for overrides and replacing any found, then printing the result
# to stdout. Finally any remaining (new) configs in the override are appended to the
# end of the output

import sys
import re
import os.path

def usage(msg):
'''print a usage message and exit'''
sys.stderr.write(msg + "\n")
sys.stderr.write("usage: merge.py overrides baseconfig [arch]\n")
sys.exit(1)

isset = re.compile(r'^(CONFIG_\w+)=')
notset = re.compile(r'^#\s+(CONFIG_\w+)\s+is not set')

# search an input line for a config (set or notset) pattern
# if we get a match return the config that is being changed
def find_config(line):
'''find a configuration line in the input and return the config name'''
m = isset.match(line)
if (m is not None):
return m.group(1)

m = notset.match(line)
if (m is not None):
return m.group(1)

return None

#########################################################

if len(sys.argv) < 3:
usage("must have two input files")

override_file = sys.argv[1]
baseconfig_file = sys.argv[2]

if not os.path.exists(override_file):
usage(f"overrides config file {override_file:s} does not exist!")

if not os.path.exists(baseconfig_file):
usage(f"base configs file {baseconfig_file:s} does not exist")

if len(sys.argv) == 4:
print(f"# {sys.argv[3]:s}")

# read each line of the override file and store any configuration values
# in the overrides dictionary, keyed by the configuration name.
overrides = {}
with open(override_file, "rt", encoding="utf-8") as f:
for line in [l.strip() for l in f.readlines()]:
c = find_config(line)
if c and c not in overrides:
overrides[c] = line

# now read and print the base config, checking each line
# that defines a config value and printing the override if
# it exists
with open(baseconfig_file, "rt", encoding="utf-8") as f:
for line in [ l.strip() for l in f.readlines() ]:
c = find_config(line)
if c and c in overrides:
print(overrides[c])
del overrides[c]
else:
print(line)

# print out the remaining configs (new values)
# from the overrides file
for v in overrides.values():
print (v)

sys.exit(0)
Loading
Loading