Developer Quick Reference
OpenPKG Quick Reference (DEVELOPMENT)
=====================================
Unpacking And Patching Sources
==============================
Synopsis
--------
%setup[<x>] [options]
-q # quiet unpacking operation
-n <dir> # set name of directory
-c # create directory (and change to it) before unpacking
-D # do not delete directory before unpacking sources
-T # do not perform default archive unpacking of %{SOURCE<x>}
-b <n> # also unpack %{SOURCE<n>} before changing to directory
(usually combined with -T, -D)
-a <n> # also unpack %{SOURCE<n>} after changing to directory
(usually combined with -T, -D, -c)
%patch[<x>] [options] [<x> …]
-P # do not perform default apply of %{PATCH<x>}
-p <#> # strip <#> leading slashes and directories from patch filenames
-b <ext> # set the backup file extension to <ext> instead of ".orig"
-E # remove empty output files
-R # apply patch as it would be reversed
<x> # also apply %{PATCH<x>}
Visualization
-------------
Input:
%setup[<x>] # default for <x> is 0
Output:
rm -rf <name>-<version> # changed by -n <dir>, omitted by -D
mkdir <name>-<version> # changed by -n <dir>, added by -c (else omitted)
cd <name>-<version> # changed by -n <dir>, added by -c (else omitted)
gunzip <%{SOURCE<x>} | tar xvf – # omitted by -T, "xvf" replaced with "xf" by -q
gunzip <%{SOURCE<n>} | tar xvf – # added by -b <n>, "xvf" replaced with "xf" by -q
cd <name>-<version> # changed by -n <dir>
gunzip <%{SOURCE<n>} | tar xvf – # added by -a <n>, "xvf" replaced with "xf" by -q
Platform Identification
=======================
FreeBSD Linux Solaris
platform class %{l_platform -c} ix86-4.4bsd ix86-lsb1.2 sparc-svr4
platform product %{l_platform -p} ix86-freebsd4.8 ix86-redhat9 sparc64-solaris9
platform technology %{l_platform -t} i686-freebsd4.8 i585-linux2.4 sun4u-sunos5.9
Sections And Commands
=====================
--rebuild => -Uvh, -bb, --clean, --rmsource (undocumented), --rmspec (undocumented)
%description
%prep
%build
%install
%check (for rpmlint things)
%files
%clean
%pre
%post
%preun
%postun
%trigger
%triggerin
%triggerun
%triggerpostun
%verifyscript (for custom -V checks)
%package (not allowed in OpenPKG)
%changelog (not allowed in OpenPKG)
action only this action up to this action
------------------------ -------------------- -----------------
execute %prep -bp --short-circuit -bp
execute %build -bc --short-circuit -bc
execute %install -bi --short-circuit -bi
execute %check N.A. N.A.
execute %files -bl N.A.
roll binary RPM package -bb --short-circuit N.A.
execute %clean N.A. -bb
roll source RPM package -bs -ba
Script Execution
----------------
section install erase upgrade reinstall
------- ------- ------- ------- ---------
%pre 1 – 2 2
%post 1 – 2 2
%preun – 0 1 –
%postun – 0 1 –
("reinstall" is the case where one uses the --force option to rpm (-i or
-U) to install the same version of the package that already is in the
system. "-" means that the scriptlet will not be run in this phase)
The order in which scripts are executed on a single package install:
new-%pre =1 for new version of package being installed
… (all new files are installed and override old versions)
new-%post =1 for new version of package being installed
The order in which scripts are executed on a single package upgrade:
new-%pre =2 for new version of package being installed
… (all new files are installed and override old versions)
new-%post =2 for new version of package being installed
old-%preun =1 for old version of package being removed
… (all old files are removed which are not part of the new package)
old-%postun =1 for old version of package being removed
The order in which scripts are executed on a single package erase:
old-%preun =0 for old version of package being removed
… (all old files are removed which are not part of the new package)
old-%postun =0 for old version of package being removed
Package Variants
----------------
o Naming Convention
– primary/intended package is named "foo"
– secondary/alternative/compatibility/etc packages are named "fooN"
where "N" is the compressed version string not longer than 2 or 3 digits.
– examples: perl/perl56, gcc/gcc2/gcc33, mysql/mysql4, tomcat/tomcat4
o Alternative Packages
– for using automatically handled package alternatives
– packages conflict by default, because are true alternatives
– intention is that packages are fully equal and compatible, any can be used, any is chosen
– multiple existing packages is final solution and will remain in near future
– multiple packages are of different products (only)
Original Package:
| Name: foo
| Provides: FOO
Alternative Packages:
| Name: fooN
| Provides: FOO
| %install
| ln -s $RPM_BUILD_ROOT%{l_prefix}/bin/fooN $RPM_BUILD_ROOT%{l_prefix}/bin/foo
Examples: MTA, JDK, JRE, MOTIF, KSH, X11
o Faked Packages
– for using manually enforced package alternatives
– packages do not conflict by default, but on enforcement
– intention is that packages are not fully compatible, only one particular should be used, others can be enfored
– multiple existing packages is temporary solution and will certainly change in near future
– multiple packages are of different versions of same product (only)
Original Package:
| Name: foo
Faked Packages:
| Name: fooN
| %options with_foo no
| %if "%{with_foo}" == "yes"
| Provides: foo = %{version}-%{release}
| %endif
| %install
| %if "%{with_foo}" == "yes"
| ln -s $RPM_BUILD_ROOT%{l_prefix}/bin/fooN $RPM_BUILD_ROOT%{l_prefix}/bin/foo
| %endif
Examples: perl, gcc, mysql, gd, tomcat