Search code examples
rpmrpmbuildrpm-spec

Build RPM package to install files in target system


I'm totally new to rpm package and confused about functionalities of different sections in rpm spec.

What I want to do using rpm package is just to install examples.py into /usr/lib/folder on target system(where I run rpm). The spec template I want to use is showed below. I have two questions here :

1.If I already have examples.py with same file hierarchy in BuildRoot directory before I build the rpm package, do I still need the INSTALL section?

2.I want to create an empty directory if it doesn't exist in target system using rpm package. Is it enough to use %dir directory in %files section? Do I need to do something in %install section or included a directory in BuildRoot directory?

I guess I don't quite understand what %files and %install do, so I have those questions.

Name: test
Version: 1.0.0
Release: 1
Copyright: Copyright info
Group: Applications/System
BuildRoot: %{_some_directory}

%description
Brief description of software package.

%install

%files
/usr/lib/folder/example.py

Solution

    1. This has been answered here: https://stackoverflow.com/a/38408706/3489429

    2. Yes. %dir directory in %files section is needed. But you also have to do:

      %install mkdir -p %{buildroot}directory