https://rpm-packaging-guide.github.io/#preparing-software-for-packaging
https://rpm-guide.readthedocs.io/en/latest/rpm-guide.html
sudo yum install gcc rpm-build rpm-devel rpmlint make python bash coreutils diffutils patch rpmdevtools
cd /home/centos
mkdir rpmtest
cd rpmtest/
vi hello-world.spec
Name: hello-world Version: 1 Release: 1 Summary: Most simple RPM package License: FIXME %description This is my first RPM package, which does nothing. %prep # we have no source, so nothing here %build cat > hello-world.sh <<EOF #!/usr/bin/bash echo Hello world EOF %install mkdir -p %{buildroot}/usr/bin/ install -m 755 hello-world.sh %{buildroot}/usr/bin/hello-world.sh %files /usr/bin/hello-world.sh %changelog # let's skip this for now
rpmdev-setuptree
rpmbuild -ba hello-world.spec
cd /home/centos/rpmbuild/
find .
#install
sudo rpm -i -f ./RPMS/x86_64/hello-world-1-1.x86_64.rpm
hello-world.sh
which hello-world.sh
cat /usr/bin/hello-world.sh
#find package
rpm -qa | grep hello
#delete
sudo rpm -e hello-world-1-1.x86_64
#
cd /home/centos/rpmbuild/
sudo rpm -qpi ./RPMS/x86_64/hello-world-1-1.x86_64.rpm
Name : hello-world Version : 1 Release : 1 Architecture: x86_64 Install Date: (not installed) Group : Unspecified Size : 33 License : FIXME Signature : (none) Source RPM : hello-world-1-1.src.rpm Build Date : Mon 03 Jun 2019 09:19:39 PM CEST Build Host : localhost Relocations : (not relocatable) Summary : Most simple RPM package Description : This is my first RPM package, which does nothing.
This is to list the content of a rpm file without installing it:
rpm -q -filesbypkg -p filename.rpm
or also simply:
sudo rpm -ql hello-world-1-1.x86_64
To extract:
rpm2cpio ./RPMS/x86_64/hello-world-1-1.x86_64.rpm > /tmp/hello.cpio
and then
cpio -i --make-directories < /tmp/hello.cpio this will create under the current folder the file usr/bin/hello-world.sh See this nice presentation
No comments:
Post a Comment