Title: pkgbuild build engine Case: PSARC/2010/138 Submitter: Laszlo (Laca) Peter Owner: John Fischer Timeout: 04/28/2010 1.0 Introduction 1.1 Project/Component Working Name: pkgbuild build engine 1.2 Purpose This project delivers the pkgbuild build engine into OpenSolaris. Minor release binding is requested. 2.0 Summary Description pkgbuild is a build engine developed by the Desktop Release Engineering team. It has been used for building the Desktop components of Solaris/ OpenSolaris since 2004. It is also used for building the OpenSolaris /contrib package repository. 2.1 Detailed Description The original purpose of pkgbuild was to facilitate delivering identical code using very similar build procedures on an RPM-based Linux system (JDS) and on Solaris. For this reason, the input of pkgbuild is a spec file[1] similar to RPM's. pkgbuild also has the same CLI and the same output format as rpmbuild, making it familiar to developers who have a background in Linux/RPM packaging. A complete pkgbuild build of a component consists of the following steps (corresponding spec file sections in parentheses): o set up source tree (%prep section) - unpack sources - apply source changes/patches o configure and compile the sources (%build) o install the binaries to a temporary proto area (%install) o generate package prototypes / manifests and create / publish packages All of the above steps are identical to rpmbuild's behaviour, the difference is the end result, which is a source RPM and one or more binary RPMs in the case of rpmbuild, and a source package and one or more binary packages (SVr4 and/or IPS) in the case of pkgbuild. The spec file includes all metainformation required for the above steps, including the location of the sources (a URL), patch names, build-time and runtime dependencies, IPS tags, attributes, actions. pkgbuild builds a single component at a time. It looks for sources (source bundles, individual files, patches and copyright files) in %_topdir/SOURCES. (%_topdir is macro that defines the location of the root of the build area). Additional spec files that may be used included using %include or %use statements must be located in %_topdir/SPECS. The build is performed in a subdirectory under the %_topdir/BUILD directory. Dynamically created SVr4 prototype, pkginfo, depend files, package scripts (e.g. CAS or postinstall) and IPS manifest files are created under %_topdir/PKGMAPS. SVr4 packages are created in %_topdir/PKGS and SVr4 "source packages" under %_topdir/SPKGS. Source packages include all files required for reproducing the build (specs, sources bundles, patches, etc). pkgbuild can automatically rebuild source packages using pkgbuild --rebuild /path/to/source_package IPS packages are published in the repository specified by the PKGBUILD_IPS_SERVER environment variable, or the local repository, if running (as determined using smf commands). Source IPS packages are published in $PKGBUILD_SRC_IPS_SERVER or PKGBUILD_IPS_SERVER or the local IPS repository. At this time, pkgbuild is not able to automatically rebuild IPS source packages, however, it is possible to install the source package (will get installed under /usr/share/src) and then rebuild the package using pkgbuild --rebuild /usr/share/src/ A higher level build script, pkgtool is provided for various convenience functions: o download sources o locate previously downloaded sources and copy them to where pkgbuild expects them o build/install a number of spec files in the order determined by the dependency information in the given spec files o collect log files o send emails about build failures o compile build reports The spec files used by pkgbuild and RPM are not fully compatible because pkgbuild needs to accommodate for the differences. These differences are documented on the pkgbuild web site[2]. Full spec file documentation is not provided, because there is already a wealth of information available for rpm spec files. spectool is a command line utility intended for parsing spec files and querying information from that for the purpose of scripting or embedding the pkgbuild utilities in larger systems. spectool's functions include: o evaluating macros in the context of a spec file o print the IPS or SVr4 package names defined by a spec file o print build-time or runtime dependencies o print the list of sources used for the build o translate an SVr4 package name or file name to an IPS package name pkgbuild comes with a set of predefined macros. These are macros commonly available in RPM implementations (different distributions define different sets of macros). Additional macros can be defined in the spec files and include files, the command line (--define option) and the ~/.pkgbuildmacros file. This corresponds to RPM's ~/.rpmmacros file and the syntax of the files is the same. The most common use of this file is to define an alternative build area from the default ~/packages directory. The syntax for this is: %_topdir /path/to/build/area pkgtool's configuration file is ~/.pkgtoolrc. In addition, a .pkgtoolrc file in the current directory is also read. The order is ./pkgtoolrc, ~/.pkgtoolrc. A self-documenting template for this file can be generated using pkgtool --dumprc. 3.0 Delivery The proposed IPS package name is "command/build/pkgbuild". Should it be delivered to Solaris 10, the proposed SVr4 package name is SUNWpkgbuild. Both names Committed. 4.0 Interface classification +-----------------------------------------------------------------------+ | Interfaces Exported | +------------------------------+-----------------+----------------------+ | Interface Name | Classification | Comment | +------------------------------+-----------------+----------------------+ | /usr/bin/pkgbuild | Volatile | | | /usr/bin/pkgtool | Volatile | | | /usr/bin/spectool | Volatile | | | /usr/lib/pkgbuild-1.3.102 | Project Private | | | ~/.pkgbuildmacros | Uncommitted | user-defined macros | | ~/.pkgtoolrc | Uncommitted | configuration file | | ~/packages | Uncommitted | personal build area | | PKGBUILD_IPS_SERVER | Uncommitted | environment variable | | PKGBUILD_SRC_IPS_SERVER | Uncommitted | environment variable | +------------------------------+-----------------+----------------------+ +-----------------------------------------------------------------------+ | Interfaces Imported | +------------------------------+------------------+---------------------+ | Interface Name | Classification | Comment | +------------------------------+------------------+---------------------+ | perl 5.8.4 | Evolving | PSARC 1999/192 | | /usr/bin/pkg | Uncommitted | PSARC 2008/190 | +------------------------------+------------------+---------------------+ 5.0 References [1] http://www.rpm.org/max-rpm/ch-rpm-inside.html http://jucr.opensolaris.org/help/spec_file [2] http://pkgbuild.sourceforge.net/