Complete guide to writing RPM SPEC files for Azure Linux packages with real-world examples
RPM SPEC files define how packages are built, installed, and distributed in Azure Linux. This guide covers the essential components and best practices for creating SPEC files.
Summary: Access control list utilitiesName: aclVersion: 2.3.1Release: 2%{?dist}License: GPLv2+Vendor: Microsoft CorporationDistribution: Azure LinuxGroup: System Environment/BaseURL: https://savannah.nongnu.org/projects/acl/Source0: https://download.savannah.nongnu.org/releases/%{name}/%{name}-%{version}.tar.gzBuildRequires: attr-develRequires: libacl = %{version}-%{release}%descriptionThis package contains the getfacl and setfacl utilities needed formanipulating access control lists.
Summary: An URL retrieval utility and libraryName: curlVersion: 8.11.1Release: 5%{?dist}License: curlVendor: Microsoft CorporationDistribution: Azure LinuxGroup: System Environment/NetworkingLibrariesURL: https://curl.haxx.seSource0: https://curl.haxx.se/download/%{name}-%{version}.tar.gzPatch0: CVE-2025-0665.patchPatch1: CVE-2025-0167.patchPatch2: CVE-2025-0725.patchBuildRequires: cmakeBuildRequires: krb5-develBuildRequires: openssl-develRequires: curl-libs = %{version}-%{release}Requires: krb5Requires: openssl%descriptionThe cURL package contains an utility and a library used fortransferring files with URL syntax to any of the followingprotocols: FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET,DICT, LDAP, LDAPS and FILE.
%global nginx_user nginxSummary: High-performance HTTP server and reverse proxyName: nginxVersion: 1.28.1Release: 1%{?dist}License: BSD-2-ClauseVendor: Microsoft CorporationDistribution: Azure LinuxGroup: Applications/SystemURL: https://nginx.org/Source0: https://nginx.org/download/%{name}-%{version}.tar.gzSource1: nginx.serviceBuildRequires: openssl-develBuildRequires: pcre2-develBuildRequires: zlib-develRequires: %{name}-filesystem = %{version}-%{release}Requires: %{name}-mimetypes%descriptionNGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server.
Many packages split functionality into multiple RPMs using subpackages.
Library Subpackage
Devel Subpackage
Filesystem Subpackage
%package libsSummary: Libraries for curlGroup: System Environment/LibrariesProvides: libcurl = %{version}-%{release}%description libsThis package contains minimal set of shared curl libraries.# Later in the file...%files libs%{_libdir}/libcurl.so.*
%package develSummary: Libraries and header files for curlRequires: %{name} = %{version}-%{release}Provides: libcurl-devel = %{version}-%{release}%description develStatic libraries and header files for the support library for curl# Later in the file...%files devel%defattr(-,root,root)%{_libdir}/*.so%{_libdir}/pkgconfig/*%{_includedir}/*%{_mandir}/man3/*
%package filesystemSummary: The basic directory layout for the Nginx serverBuildArch: noarchRequires(pre): shadow-utils%description filesystemThe nginx-filesystem package contains the basic directory layoutfor the Nginx server including the correct permissions for thedirectories.%pre filesystemgetent group %{nginx_user} > /dev/null || groupadd -r %{nginx_user}getent passwd %{nginx_user} > /dev/null || \ useradd -r -d %{_localstatedir}/lib/nginx -g %{nginx_user} \ -s /sbin/nologin -c "Nginx web server" %{nginx_user}exit 0%files filesystem%dir %{_sysconfdir}/%{name}