-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SRE-2452 rpms: Script to build RPMs from scratch
Script to build all RPMs, including dependencies on RockyLinux 8 and 9. Introduces a new GHA workflow file for running the script. Signed-off-by: Ryon Jensen <ryon.jensen@intel.com> Doc-only: true
- Loading branch information
1 parent
1a53cc9
commit f0a36da
Showing
2 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: RPM Build Script Test | ||
|
||
on: | ||
pull_request: | ||
|
||
permissions: {} | ||
jobs: | ||
Run_in_docker: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
os: ["rockylinux:8", "rockylinux:9"] | ||
# os: ["rockylinux:8", "rockylinux:9", "opensuse/leap:15.4", "opensuse/leap:15.5"] | ||
platform: ["amd64"] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
Check warning Code scanning / Scorecard Pinned-Dependencies Medium test
score is 1: GitHub-owned GitHubAction not pinned by hash
Click Remediation section below to solve this issue |
||
- name: Run Shell Script in Docker | ||
run: | | ||
distro="${{ matrix.os }}" | ||
distro_clean="${distro//[:\/]/_}" | ||
rpm_dst=~/rpms/$distro_clean | ||
mkdir -p "$rpm_dst" | ||
chmod 777 "$rpm_dst" | ||
docker run --rm -v "$rpm_dst":/root/rpms -v .:/daos $distro /daos/utils/build_rpms_from_scratch.sh /root/rpms | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
#!/bin/bash | ||
set -uex | ||
|
||
############################################################################### | ||
# DAOS RPM Build Script | ||
# | ||
# Description: | ||
# This script sets up an environment to build and install RPM packages for DAOS | ||
# and its dependencies on a Rocky Linux system. It automates the installation | ||
# of required tools, package dependencies, and specific repositories, ensuring | ||
# that each RPM is built in a temporary location and copied to a destination | ||
# directory. | ||
# | ||
# Usage: | ||
# Run the script in a Rocky Linux system | ||
# | ||
# Arguments: | ||
# 1. Destination for built RPMs (default: "$HOME/rpm/") | ||
# | ||
############################################################################### | ||
|
||
dnf_builddep() { | ||
local rpms_dst=$1 | ||
local spec_file="$2" | ||
dnf --nogpgcheck --repofrompath rpms,"$rpms_dst" --refresh builddep -y "$spec_file" | ||
} | ||
|
||
setup_rpm_build_env() { | ||
el_version=${1:-8} # default to '8' | ||
|
||
# Update and install required packages | ||
dnf install -y \ | ||
git \ | ||
rpm-build \ | ||
rpmdevtools \ | ||
dnf-plugins-core \ | ||
epel-release | ||
|
||
# Install build tools and dependencies | ||
dnf groupinstall -y "Development Tools" | ||
dnf install -y mock epel-release | ||
|
||
# enable Power Tools or CodeReady Builder depending on el version | ||
if [[ "$el_version" == "8" ]]; then | ||
dnf config-manager --set-enabled powertools | ||
elif [[ "$el_version" == "9" ]]; then | ||
dnf config-manager --set-enabled crb # CodeReady Builder | ||
else | ||
echo "Unsupported EL Version: $el_version" | ||
exit 1 | ||
fi | ||
|
||
# ignore dpdk because want to use rpms build from daos-stack/dpdk | ||
dnf update -y --exclude=dpdk --exclude=dpdk-devel | ||
} | ||
|
||
# Function to clone a daos-stack repo, build rpms, and setup the rpm repository | ||
build_and_install_rpm() { | ||
local repo_name=$1 | ||
local rpm_build_options=${2:-""} | ||
|
||
# Check if already successful - helps if running script many times while troubleshooting | ||
if [ ! -f "$repo_name"/success ]; then | ||
if [ -d "$repo_name" ]; then rm -rf "$repo_name"; fi | ||
echo "Building $repo_name ..." | ||
git clone https://github.com/daos-stack/"$repo_name".git | ||
cd "$repo_name" | ||
dnf_builddep "$rpms_dst" "$repo_name".spec | ||
make rpms RPM_BUILD_OPTIONS="$rpm_build_options" | ||
cp -r _topdir/RPMS/* "$rpms_dst"/ | ||
createrepo "$rpms_dst" | ||
touch success | ||
cd .. | ||
else | ||
echo "'$repo_name' dependency already built. Skipping step." | ||
fi | ||
} | ||
|
||
get_el_version() { | ||
VERSION_ID=$(grep "^VERSION_ID" /etc/os-release | cut -d'=' -f2 | tr -d '"' | cut -d'.' -f1) | ||
echo "$VERSION_ID" | ||
} | ||
|
||
# ---- # | ||
# MAIN # | ||
# ---- # | ||
rpms_dst=${1:-"$HOME/rpms/"} | ||
build_dst="/tmp/rpmbuild/" # temp location to do the building | ||
|
||
echo "Building RPMs for EL $(get_el_version)." | ||
echo "RPMS will be located in $rpms_dst (built in $build_dst)" | ||
|
||
# make sure rpm and build folders are created | ||
mkdir -p "$rpms_dst" "$build_dst" | ||
|
||
# ------------------------------ | ||
# Build Dependency and DAOS RPMS | ||
# ------------------------------ | ||
setup_rpm_build_env "$(get_el_version)" | ||
|
||
cd $build_dst | ||
|
||
# Initialize the rpm repo | ||
createrepo "$rpms_dst" | ||
|
||
# Call the function with the repository name as an argument | ||
build_and_install_rpm "isa-l_crypto" | ||
build_and_install_rpm "dpdk" # dependency of spdk. | ||
build_and_install_rpm "spdk" | ||
build_and_install_rpm "argobots" | ||
build_and_install_rpm "mercury" | ||
build_and_install_rpm "pmdk" "--nocheck" | ||
|
||
# DAOS and Raft (Submodule) | ||
git clone --recursive https://github.com/daos-stack/daos.git | ||
|
||
# RAFT | ||
if [ ! -f daos/src/rdb/raft/success ]; then | ||
cd daos/src/rdb/raft | ||
dnf_builddep "$rpms_dst" raft.spec | ||
make -f Makefile-rpm.mk | ||
cp -r _topdir/RPMS/* "$rpms_dst"/ | ||
createrepo "$rpms_dst" | ||
touch success | ||
cd - | ||
fi | ||
|
||
# DAOS | ||
if [ ! -f daos/success ]; then | ||
cd daos | ||
dnf_builddep "$rpms_dst" ./utils/rpms/daos.spec | ||
make -C utils/rpms rpms | ||
cp -r utils/rpms/_topdir/RPMS/* "$rpms_dst"/ | ||
createrepo "$rpms_dst" | ||
touch success | ||
cd - | ||
fi | ||
|
||
# -------- | ||
# Clean up | ||
# -------- | ||
rm -rf $build_dst |