Packaging applications with RPM¶
To build and deploy applications for AutoSD, package the application with RPM Package Manager (RPM) and embed the packaged application in the operating system (OS) image. The Automotive SIG provides sample OS image manifests that you can customize for specific use cases and sample applications that you can package and deploy in your OS images.
There are two types of packages:
- Binary packages (RPM packages): A binary package contains compiled software.
- Source RPM packages (SRPM packages): A source package contains the source code of the application, the spec file that specifies how to compile the source code, and eventual patches to produce the binary packages.
In this example workflow, you will learn how to prepare the sample application source code that you want to package with RPM, create a spec file, build a binary RPM, and create a local RPM repository. Then configure the OS image build process to include your RPM at build time. To learn more about RPM packages, see the RHEL RPM guide.
Creating the RPM packaging workspace¶
To create an RPM package, you must first create a separate directory for your RPM packaging workspace. An RPM package consists of an archive of source code and a spec file. The spec file contains project metadata and different sections that you use to define how to compile project source code.
Prerequisites
- A host machine that runs on CentOS Stream, Fedora, or RHEL
Procedure
-
Install the tools required to build RPM packages, as well as dependencies required by the sample application:
-
From your
home
directory, run therpmdev-setuptree
utility to create a file structure for the RPM packaging workspace: -
Verify that
rpmdev-setuptree
created the required directories:
The required directories each serve a unique purpose:
BUILD
: The location of various%buildroot
directories. These are useful for investigating a failed build if the log output is inconclusive.RPMS
: The location of your binary RPM packages. This directory contains subdirectories for different architectures.SOURCES
: The location of your source code. Package your source code in atar
archive and copy it to theSOURCES
directory. At build time, therpmbuild
build tool extracts your software from this directory.SPECS
: The location of your spec files.SRPMS
: The location of your SRPM packages.
Packaging your application source code with RPM¶
Use this workflow to package your own application source code into an RPM package. After you package your software, add it to a local RPM repository. RPM Package Manager queries the RPM packages in this repository, resolves their dependencies, and installs them in your operating system (OS) image.
-
Create a
tar
archive of your application source code:In this example, your application source code is in a directory named
my-app
. -
Move the
.tar
archive of your software to therpmbuild/SOURCES
directory: -
Create a
spec
file for a new RPM package calledmy-app
:This command creates a spec file for your
my-app
application in~/rpmbuild/SPECS/my-app.spec
. -
Modify the
~/rpmbuild/SPECS/my-app.spec
file with a text editor. For more information about spec files and how to customize them, see the RPM packaging Guide on GitHub. -
Build the binary RPM package:
-
Create a directory for your RPM package repository, move your
.rpm
file to this directory, and initialize the directory as an RPM package repository:
Your RPM package repository is now ready, and it contains your software packaged as a .rpm
file. When you build the AutoSD image, include the RPM
package repository in the build manifest to enable the OS image to incorporate your software. For more information about building the AutoSD image,
see Building an AutoSD image.
Next steps