Difference between revisions of "Fedora-rpm"

From Bashlinux
Jump to: navigation, search
Line 1: Line 1:
  +
__NOTITLE__
 
__NOTOC__
 
__NOTOC__
 
= Fedora RPM Build =
 
= Fedora RPM Build =
 
== Structure ==
 
== Structure ==
To build an rpm must be created and/or placed different files under `/usr/src/redhat` as follow:
+
To build an rpm must be created and/or placed different files under <tt>/usr/src/redhat</tt> as follow:
# Spec file with details of name, dependencies, instructions, etc and script of how to build the rpm under `SPEC` folder
+
# Spec file with details of name, dependencies, instructions, etc and script of how to build the rpm under <tt>SPEC</tt> folder
# Compressed file with the sources under `SOURCES` folder
+
# Compressed file with the sources under <tt>SOURCES</tt> folder
   
 
== Build ==
 
== Build ==
Line 11: Line 12:
   
 
The created files will be placed as follow:
 
The created files will be placed as follow:
# New RPM created under `RPMS/''system_architecture''` folder
+
# New RPM created under <tt>RPMS/''system_architecture''</tt> folder
# RPM with sources and spec file packed under `SRPMS` folder
+
# RPM with sources and spec file packed under <tt>SRPMS</tt> folder
# Unpacked sources under `BUILD` folder
+
# Unpacked sources under <tt>BUILD</tt> folder
   
 
== Scripts ==
 
== Scripts ==
Line 22: Line 23:
 
# Post uninstall: postun
 
# Post uninstall: postun
   
The `rpm` command has 3 main types of execution to be considered:
+
The <tt>rpm</tt> command has 3 main types of execution to be considered:
 
# install
 
# install
 
rpm -i newrpm.rpm
 
rpm -i newrpm.rpm
Line 31: Line 32:
 
# remove
 
# remove
 
rpm -e newrpm.rpm
 
rpm -e newrpm.rpm
and different values are passed to each script based on which type of execution is performed by the `rpm` command.
+
: and different values are passed to each script based on which type of execution is performed by the <tt>rpm</tt> command.
  +
  +
{{Warningbox | Warning |
 
* Be careful with the usage of each script section, please note the execution order which is crucial at upgrade time.
  +
* When importing specs from other distros use remove `%` in from of `make`}}
   
{{Warningbox | Warning |* Be careful with the usage of each script section, please note the execution order which is crucial at upgrade time.<br>* When importing specs from other distros use remove `%` in from of `make`}}
 
   
 
==== New installation ====
 
==== New installation ====

Revision as of 01:44, 6 June 2015

__NOTITLE__

Fedora RPM Build

Structure

To build an rpm must be created and/or placed different files under /usr/src/redhat as follow:

  1. Spec file with details of name, dependencies, instructions, etc and script of how to build the rpm under SPEC folder
  2. Compressed file with the sources under SOURCES folder

Build

To build the new rpm, run the command:

# rpmbuild -ba SPEC/newrpm.spec

The created files will be placed as follow:

  1. New RPM created under RPMS/system_architecture folder
  2. RPM with sources and spec file packed under SRPMS folder
  3. Unpacked sources under BUILD folder

Scripts

There are 4 types of scripts:

  1. Pre install: pre
  2. Post install: post
  3. Pre uninstall: preun
  4. Post uninstall: postun

The rpm command has 3 main types of execution to be considered:

  1. install
rpm -i newrpm.rpm
  1. upgrade
rpm -u newrpm.rpm
  1. remove
rpm -e newrpm.rpm
and different values are passed to each script based on which type of execution is performed by the rpm command.
Error creating thumbnail: File missing
Warning
  • Be careful with the usage of each script section, please note the execution order which is crucial at upgrade time.
  • When importing specs from other distros use remove `%` in from of `make`


New installation

The execution order and values passed are:

  •  %pre NEW_PACKAGE ($1 = 1)
  •  %install
  •  %post NEW_PACKAGE ($1 = 1)

Upgrade

The execution order and values passed are:

  •  %pre
NEW_PACKAGE `($1 = 2)`
  •  %install
  •  %post
NEW_PACKAGE `($1 = 2)`
  •  %preun
OLD_PACKAGE `($1 = 1)`
  •  %files
NEW_PACKAGE, Delete all files no longer listed
  •  %postun
OLD_PACKAGE `($1 = 1)`

Remove

The execution order and values passed are:

  •  %preun
OLD_PACKAGE `($1 = 0)`
  •  %files
OLD_PACKAGE, Delete all files listed
  •  %postun
OLD_PACKAGE `($1 = 0)`