Skip to content

Commit 7f47f16

Browse files
committed
updated O2-FLP pda-kadapter-dkms RPM build procedure
1 parent 1d5353a commit 7f47f16

File tree

5 files changed

+169
-118
lines changed

5 files changed

+169
-118
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
1) Update the PACKAGE_VERSION in `dkms.conf`
2-
2) Run make rpm_dkms
3-
3) RPM present in: `/home/$(whoami)/rpmbuild/RPMS/noarch/pda-kadapter-dkms-$PACKAGE_VERSION-0.noarch.rpm`
1+
1) Update the version numbers in make-pda-kadapter-dkms-rpm.sh
2+
2) Run make-pda-kadapter-dkms-rpm.sh
3+
3) RPM present in: `/tmp/rpm/RPMS/noarch/${PKG_NAME}-${PKG_VERSION}-${GIT_TAG}-0.noarch.rpm`
4+
e.g. /tmp/rpm/RPMS/noarch/pda-kadapter-dkms-2.1.3.0.11.0-0.noarch.rpm

patches/linux_uio/Makefile_dkms

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
#!/bin/sh
2+
3+
# script to build pda-kadapter-dkms RPM from upstream repo
4+
# as used in O2 FLP farm
5+
6+
7+
8+
# This is pda GIT tag from https://github.com/cbm-fles/pda
9+
GIT_TAG=11.8.7
10+
11+
# This is the base name and version for this dkms package
12+
PKG_NAME=pda-kadapter-dkms
13+
PKG_VERSION=2.1.3
14+
15+
# local build directory
16+
TMPDIR=/tmp/rpm
17+
18+
# current directory
19+
CURDIR=`pwd`
20+
21+
# use local versions of kernel module source files, if found
22+
# (eg to test a local version not available in upstream repo)
23+
USE_LOCAL_SOURCES=0
24+
25+
# Prerequisites:
26+
# yum install -y git rpm-build
27+
28+
# check needed commands found
29+
ISERROR=0
30+
for a in git rpmbuild; do
31+
which $a > /dev/null 2>&1
32+
if [ "$?" -ne "0" ]; then
33+
echo "Missing: $a"
34+
ISERROR=1
35+
fi
36+
done
37+
if [ "$ISERROR" -ne "0" ]; then
38+
exit 0
39+
fi
40+
41+
# create a fresh build directory tree
42+
echo "Generating RPM in ${TMPDIR}"
43+
rm -rf ${TMPDIR}
44+
WDIR=${TMPDIR}/tmp
45+
mkdir -p ${TMPDIR}/SOURCES ${TMPDIR}/SPECS ${TMPDIR}/BUILD ${TMPDIR}/RPMS ${TMPDIR}/SRPMS ${WDIR}
46+
47+
# get source code from upstream
48+
echo "Generating source tarball ${TMPDIR}/SOURCES/${PKG_DIR}.src.tar.gz"
49+
cd ${WDIR}
50+
git clone https://github.com/cbm-fles/pda.git -c advice.detachedHead=false
51+
cd pda
52+
git fetch
53+
#git checkout -b fix_sysfs_attr origin/fix_sysfs_attr
54+
git checkout tags/${GIT_TAG}
55+
cd patches/linux_uio
56+
57+
# update source code with local files, if present
58+
if [ "$USE_LOCAL_SOURCES" == "1" ]; then
59+
for ff in uio_pci_dma.c uio_pci_dma.h; do
60+
if [ -f ${CURDIR}/${ff} ]; then
61+
echo "*** Using local file: ${ff}"
62+
cp -p ${CURDIR}/${ff} .
63+
fi
64+
done
65+
fi
66+
67+
# create source tarball
68+
KMOD_VERSION=`cat uio_pci_dma.h | grep UIO_PCI_DMA_VERSION | cut -d\" -f2`
69+
echo "Detected uio_pci_dma kernel module version ${KMOD_VERSION}"
70+
VERSION="${PKG_VERSION}.${KMOD_VERSION}"
71+
PKG_DIR=${PKG_NAME}-${VERSION}
72+
mkdir -p ${WDIR}/${PKG_DIR}
73+
cp -p Makefile.dkms dkms.conf uio_pci_dma.c uio_pci_dma.h *-pda.rules *-pda.conf ${WDIR}/${PKG_DIR}
74+
cp ${WDIR}/pda/LICENSE ${WDIR}/${PKG_DIR}
75+
cd ${WDIR}
76+
tar -cf ${PKG_DIR}.src.tar ${PKG_DIR}
77+
gzip ${PKG_DIR}.src.tar
78+
mv ${PKG_DIR}.src.tar.gz ${TMPDIR}/SOURCES
79+
80+
# create specfile
81+
SPECFILE=${PKG_NAME}.spec
82+
echo "Generating ${TMPDIR}/SPECS/${SPECFILE}"
83+
rm -f ${TMPDIR}/SPECS/${SPECFILE}
84+
85+
# NB: https://en.opensuse.org/openSUSE:Package_group_guidelines
86+
# Development/Sources is intended for binary and noarch packages containing sources. It is the right place for kernel sources and kernel module sources.
87+
# System/Kernel contains kernel binaries and kernel-related tools like module-init-tools. The packages with kernel sources and kernel modules sources are in the group Development/Sources.
88+
# For RHEL9, using : System Environment/Kernel
89+
# rpm -qa --qf "%{GROUP}\n" | sort | uniq
90+
91+
echo "%define version ${VERSION}" >> ${TMPDIR}/SPECS/${SPECFILE}
92+
echo "%define module ${PKG_NAME}" >> ${TMPDIR}/SPECS/${SPECFILE}
93+
94+
echo '
95+
Summary: PDA kernel adapter DKMS package
96+
Name: %{module}
97+
Version: %{version}
98+
Release: 0
99+
License: BSD
100+
URL: https://github.com/cbm-fles/pda/
101+
Packager: Sylvain Chapeland <[email protected]>
102+
Group: System Environment/Kernel
103+
BuildArch: noarch
104+
Requires: dkms >= 1.00, kernel-devel, kernel-headers
105+
Requires: bash
106+
Source0: %{module}-%{version}.src.tar.gz
107+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root/
108+
109+
%description
110+
This package contains the PDA kernel adapter wrapped for the DKMS framework.
111+
112+
%prep
113+
%setup
114+
115+
%install
116+
mkdir -p $RPM_BUILD_ROOT/usr/src/%{module}-%{version}/
117+
mkdir -p $RPM_BUILD_ROOT/usr/lib/udev/rules.d/
118+
mkdir -p $RPM_BUILD_ROOT/usr/lib/modules-load.d/
119+
mv $RPM_BUILD_DIR/%{module}-%{version}/*-pda.rules $RPM_BUILD_ROOT/usr/lib/udev/rules.d/
120+
mv $RPM_BUILD_DIR/%{module}-%{version}/*-pda.conf $RPM_BUILD_ROOT/usr/lib/modules-load.d/
121+
mv $RPM_BUILD_DIR/%{module}-%{version}/Makefile.dkms $RPM_BUILD_ROOT/usr/src/%{module}-%{version}/Makefile
122+
mv $RPM_BUILD_DIR/%{module}-%{version}/* $RPM_BUILD_ROOT/usr/src/%{module}-%{version}/
123+
124+
125+
%clean
126+
rm -rf $RPM_BUILD_DIR/%{module}-%{version}
127+
rm -rf $RPM_BUILD_ROOT
128+
129+
130+
%files
131+
%defattr(644,root,root,755)
132+
/usr/src/%{module}-%{version}/
133+
/usr/lib/udev/rules.d/*.rules
134+
/usr/lib/modules-load.d/*.conf
135+
136+
137+
%pre
138+
# ensure group pda exists
139+
groupadd -f pda
140+
141+
%post
142+
dkms add -m %{module} -v %{version}
143+
144+
if [ `uname -r | grep -c "BOOT"` -eq 0 ]; then
145+
dkms build -m %{module} -v %{version}
146+
dkms install -m %{module} -v %{version}
147+
elif [ `uname -r | grep -c "BOOT"` -gt 0 ]; then
148+
echo -e ""
149+
echo -e "Module build for the currently running kernel was skipped since you"
150+
echo -e "are running a BOOT variant of the kernel."
151+
else
152+
echo -e ""
153+
echo -e "Module build for the currently running kernel was skipped since the"
154+
echo -e "kernel headers for this kernel do not seem to be installed."
155+
fi
156+
exit 0
157+
158+
%preun
159+
echo -e
160+
echo -e "Uninstall of PDA kernel adapter module (version %{version}) beginning:"
161+
dkms remove -m %{module} -v %{version} --all
162+
exit 0
163+
' >> ${TMPDIR}/SPECS/${SPECFILE}
164+
165+
rpmbuild --define "_topdir ${TMPDIR}" -ba ${TMPDIR}/SPECS/${SPECFILE}

patches/linux_uio/pda_kadapter.spec

Lines changed: 0 additions & 36 deletions
This file was deleted.

patches/linux_uio/pda_kadapter_dkms.spec

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)