Wednesday 15 February 2023

Packaging Source Code inside the RPM Packages


Prepare build environment


yum install rpm-build

mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

tree rpmbuild

rpmbuild

├── BUILD

├── RPMS

├── SOURCES

├── SPECS

└── SRPMS


5 directories, 0 files


 echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros


Pull down the source code


cd rpmbuild/SOURCES/

curl -LO https://github.com/open-iscsi/rtslib-fb/archive/refs/tags/v2.1.74.tar.gz

tar -xzvf v2.1.74.tar.gz


yum install python-rtslib

mv rtslib-fb-2.1.74/ python-rtslib-2.1.fb74/

rm -rf v2.1.74.tar.gz

tar -zcvf python-rtslib-2.1.fb74.tar.gz python-rtslib-2.1.fb74/


#edit setup.py

setup (

    name = 'python-rtslib',

    version = '2.1.fb74',


yum install python-setuptools

python setup.py bdist_rpm --packager="Jojan Paul <jpmolekunnel@gmail.com>" --spec-only

cp dist/python-rtslib.spec ../../SPECS/

cd ../../SPECS/


#edit file

vim python-rtslib.spec

%description

python-rtslib


Build RPM


cd ~/rpmbuild/

rpmbuild -ba SPECS/python-rtslib.spec

cd RPMS/noarch

ls

python-rtslib-2.1.fb74-1.noarch.rpm


#test

yum install python-rtslib-2.1.fb74-1.noarch.rpm


No comments:

Post a Comment