Thursday, January 14, 2016

rpm tutorial

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

This is my first RPM package, which does nothing.

# we have no source, so nothing here

cat > <<EOF
echo Hello world

mkdir -p %{buildroot}/usr/bin/
install -m 755 %{buildroot}/usr/bin/


# let's skip this for now

rpmbuild -ba hello-world.spec
cd /home/centos/rpmbuild/
find .
sudo rpm -i -f ./RPMS/x86_64/hello-world-1-1.x86_64.rpm
cat /usr/bin/
#find package
rpm -qa | grep hello
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/ See this nice presentation

No comments: