User Tools

Site Tools


rpm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rpm [2012/04/12 18:54]
k2patel [RPM Spec File Information]
rpm [2020/08/10 02:35] (current)
Line 1: Line 1:
 ====== RPM ====== ====== RPM ======
 +
 +* [[ Python packages to rpm ]]
  
 Package management system few tips / trick to build / modify / work with packages. \\ Package management system few tips / trick to build / modify / work with packages. \\
 Many hints information taken from original site [[http://​rpm.org/​ | RPM]] Many hints information taken from original site [[http://​rpm.org/​ | RPM]]
  
 +==== RPM Common Command ====
 +
 +^ Syntax ^Description^
 +| rpm -ivh {rpm-file} | Install the package |
 +| rpm -Uvh {rpm-file} | Upgrade package |
 +| rpm -ev {package} | Erase/​remove/​ an installed package |
 +| rpm -ev --nodeps {package} | Erase/​remove/​ an installed package without checking for dependencies |
 +| rpm -qa | Display list all installed packages |
 +| rpm -qi {package} | Display installed information along with package version and short description |
 +| rpm -qf {/​path/​to/​file} | Find out what package a file belongs to i.e. find what package owns the file |
 +| rpm -qc {pacakge-name} | Display list of configuration file(s) for a package |
 +| rpm -qcf {/​path/​to/​file} | Display list of configuration files for a command |
 +| rpm -qa --last | Display list of all recently installed RPMs |
 +| rpm -qpR {.rpm-file} | Find out what dependencies a rpm file has |
 +| rpm -qR {package} | ::: |
 +| rpm -qR bash | ::: |
 ==== How to Print .spec file from RPM ==== ==== How to Print .spec file from RPM ====
  
Line 125: Line 143:
 </​code>​ </​code>​
  
 +==== Something i come across ====
 +If you wanna override marco from OS you can define value at ''​top''​ of the spec file.
 +<code bash>
 +%define _mandir /usr/man
 +</​code>​
 ==== Sample RPM ==== ==== Sample RPM ====
 <code bash | sample.spec>​ <code bash | sample.spec>​
Line 216: Line 239:
 [[http://​rpm.org/​wiki/​Docs#​PackagerDocumentation | RPM Official]] [[http://​rpm.org/​wiki/​Docs#​PackagerDocumentation | RPM Official]]
  
 +==== Scriptlets ====
 +
 +Normally, rpm has scriptlets inside the spec file that are 
 +ran at install time.  These are:
 +<code bash>
 + %pre              - Run before rpm files are installed.
 + %post ​            - Run after rpm files are installed.
 + %preun ​           - Run before rpm files are erased.
 + %postun ​          - Run after rpm files are erased.
 + ​ %triggerin ​       - Install trigger.
 + %triggerun ​       - uninstall trigger
 + %triggerpostun ​   - postuninstall trigger.
 +</​code>​
 +The scripts are normally bash scripts, but you can change the interpreter
 +with the -p option.
 +
 +Also, as they are bash scripts you can call external scripts from these.
 ==== General RPM Command ==== ==== General RPM Command ====
  
Line 223: Line 263:
 </​code>​ </​code>​
  
 +
 +==== Error on Building ====
 +=== module: command not found ===
 +Try running following command and then execute rpmbuild will resolve the issue.
 +<code bash>
 +source /​etc/​profile.d/​modules.sh
 +</​code>​
 ==== MOCK ==== ==== MOCK ====
  
Line 267: Line 314:
 </​code>​ </​code>​
  
 +== Building SRPM ==
 +<code bash>
 +mock -r epel-6-x86_64 --spec icinga-web.spec --sources=../​SOURCES/​ --resultdir=../​RPMS/​ --buildsrpm
 +</​code>​
 ==== Copying Files ==== ==== Copying Files ====
 <note important>​Dont scratch over --copyin check spelling one more time</​note>​ <note important>​Dont scratch over --copyin check spelling one more time</​note>​
Line 292: Line 343:
 In general case result will be stored in '/​var/​lib/​mock/​epel-5-x86_64/​result/'​ In general case result will be stored in '/​var/​lib/​mock/​epel-5-x86_64/​result/'​
  
-==== RPM Spec File Information ​====+==== SPEC file Overview ​====
  
 This is mostly from following URL [[http://​fedoraproject.org/​wiki/​How_to_create_an_RPM_package | Fedora Project]] This is mostly from following URL [[http://​fedoraproject.org/​wiki/​How_to_create_an_RPM_package | Fedora Project]]
  
 <code text> <code text>
-SPEC file overview 
  
 Other useful guides: Other useful guides:
Line 421: Line 471:
 Do not create a "​relocatable"​ package; they don't add value in Fedora and make things more complicated. Do not create a "​relocatable"​ package; they don't add value in Fedora and make things more complicated.
 </​code>​ </​code>​
 +
 +==== SPEC file sections explained ====
  
 <code text> <code text>
Line 507: Line 559:
 here you configure and compile/​build the files to be installed. here you configure and compile/​build the files to be installed.
  
-Many programs follow the GNU configure approach (or some variation). By default, they will install to a prefix of "/​usr/​local",​ which is reasonable for unpackaged files. However, since you are packaging it, change the prefix to "/​usr"​. Libraries should be installed to either /usr/lib or /usr/lib64 depending on the architecture.+Many programs follow the GNU configure approach (or some variation). 
 +By default, they will install to a prefix of "/​usr/​local",​ which is reasonable for unpackaged files. 
 +However, since you are packaging it, change the prefix to "/​usr"​. 
 +Libraries should be installed to either /usr/lib or /usr/lib64 depending on the architecture.
  
-Since GNU configure is so common, the macro "​%configure"​ can be used to automatically invoke the correct options (e.g. change the prefix to /usr). Some variation of this often works:+Since GNU configure is so common, the macro "​%configure"​ can be used to automatically 
 +invoke the correct options (e.g. change the prefix to /usr). Some variation of this often works:
  
  ​%configure  ​%configure
Line 516: Line 572:
  
 make %{?​_smp_mflags} CFLAGS="​%{optflags}"​ BINDIR=%{_bindir} make %{?​_smp_mflags} CFLAGS="​%{optflags}"​ BINDIR=%{_bindir}
-More more information,​ see "GNU autoconf, automake, and libtool"​ and "Open Source Development Tools: An Introduction to Make, Configure, Automake, Autoconf"​ by Stefan Hundhammer.+More more information,​ see "GNU autoconf, automake, and libtool"​ 
 + and  
 +"Open Source Development Tools: An Introduction to Make, Configure, Automake, Autoconf"​ by Stefan Hundhammer.
  
 Some programs use cmake. See Packaging/​cmake. Some programs use cmake. See Packaging/​cmake.
Line 762: Line 820:
 Macros Macros
 Macros are text in the format %{string}. Typical macros: Macros are text in the format %{string}. Typical macros:
 +</​code>​
  
-Macro  Typical Expansion  Meaning + 
-%{_bindir} /​usr/​bin  Binary directory: where executables are usually stored. +Macro Typical Expansion ​Meaning ​^ 
-%{_builddir} ~/​rpmbuild/​BUILD Build directory: files are compiled within +%{_bindir} ​/​usr/​bin ​Binary directory: where executables are usually stored. ​ 
- a subdirectory of the build directory. See %buildsubdir. +%{_builddir} ​~/​rpmbuild/​BUILD ​Build directory: files are compiled within a subdirectory of the build directory. See %buildsubdir. ​ 
-%{buildroot} ~/​rpmbuild/​BUILDROOT Build root: where files are "​installed"​ during the %install stage, +%{buildroot} ​~/​rpmbuild/​BUILDROOT ​Build root: where files are "​installed"​ during the %install stage, which copies files from a subdirectory of %{_builddir} to a subdirectory of %{buildroot}. (Historically,​ %{buildroot} was in "/​var/​tmp/"​.) ​ 
- which copies files from a subdirectory of %{_builddir} ​ +%{buildsubdir} ​%{_builddir}/​%{name} ​Build subdirectory:​ a subdirectory within %{_builddir} where files are compiled during the %build stage. It is set after %setup. ​ 
- to a subdirectory of %{buildroot}. +%{_datadir} ​/​usr/​share ​Share directory. ​ 
- (Historically,​ %{buildroot} was in "/​var/​tmp/"​.) +%{_defaultdocdir} ​/​usr/​share/​doc ​Default documentation directory. ​ 
-%{buildsubdir} %{_builddir}/​%{name} Build subdirectory:​ a subdirectory within %{_builddir} where +%{dist} ​.fcNUMBER ​Distribution+version short name (e.g. "​.fc9"​) ​ 
- files are compiled during the %build stage. It is set after %setup. +%{fedora} ​NUMBER ​Number of fedora release (e.g. "​9"​) ​ 
-%{_datadir} /​usr/​share  Share directory. +%{_includedir} ​/​usr/​include ​|  |  
-%{_defaultdocdir} /​usr/​share/​doc  Default documentation directory. +%{_infodir} ​/​usr/​share/​info ​|  |  
-%{dist} .fcNUMBER  Distribution+version short name (e.g. "​.fc9"​) +%{_initrddir} ​/​etc/​rc.d/​init.d ​|  |  
-%{fedora} NUMBER  Number of fedora release (e.g. "​9"​) +%{_libdir} ​/​usr/​lib ​|  |  
-%{_includedir} /​usr/​include +%{_libexecdir} ​/​usr/​libexec ​|  |  
-%{_infodir} /​usr/​share/​info +%{_localstatedir} ​/var |  |  
-%{_initrddir} /​etc/​rc.d/​init.d +%{_mandir} ​/​usr/​share/​man ​|  |  
-%{_libdir} /​usr/​lib +%{name} ​|  | Name of package, set by Name: tag  
-%{_libexecdir} /​usr/​libexec +%{_sbindir} ​/​usr/​sbin ​|  |  
-%{_localstatedir} /​var +%{_sharedstatedir} ​/​var/​lib ​|  |  
-%{_mandir} /​usr/​share/​man +%{_sysconfdir} ​/etc |  |  
-%{name}  Name of package, set by Name: tag +%{version} ​|  | Version of package, set by Version: tag |  
-%{_sbindir} /​usr/​sbin + 
-%{_sharedstatedir} /​var/​lib + 
-%{_sysconfdir} /​etc + 
-%{version}  Version of package, set by Version: tag + 
-Learn more about macros by looking in /etc/rpm/* and /​usr/​lib/​rpm,​ +<code text> 
-especially /​usr/​lib/​rpm/​macros. Also use rpm --showrc to  +Learn more about macros by looking in /etc/rpm/* and /​usr/​lib/​rpm,​ especially /​usr/​lib/​rpm/​macros. 
-show values that RPM will use for macros (altered by rpmrc and macro configuration files).+Also use rpm --showrc to show values that RPM will use for macros (altered by rpmrc and macro configuration files).
  
 You can set your own macro values using %global, You can set your own macro values using %global,
Line 803: Line 862:
 Also see Packaging/​RPMMacros and RPM Guide chapter 9. Also see Packaging/​RPMMacros and RPM Guide chapter 9.
 </​code>​ </​code>​
 +
 +==== Custom Built RPM ====
 +
 +[[http://​rpm.k2patel.in|my repository]]
rpm.1334256895.txt.gz · Last modified: 2020/08/10 02:29 (external edit)