### Basic Alternatives Implementation in RPM Spec Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Alternatives A simple example showing the necessary Requires, %install, %post, %postun, and %files sections for a basic alternatives setup. ```rpm-spec Requires(post): %{_bindir}/update-alternatives Requires(postun): %{_bindir}/update-alternatives ... %install ... touch %{buildroot}%{_bindir}/antlr %post update-alternatives --install %{_bindir}/antlr \ %{name} %{_bindir}/antlr-java 10 %postun if [ $1 -eq 0 ] ; then update-alternatives --remove %{name} %{_bindir}/antlr-java fi ... %files ... %ghost %{_bindir}/antlr %{_bindir}/antlr-java ``` -------------------------------- ### Install Go binaries Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang_old Manually create the bindir and install compiled binaries into the buildroot. ```bash install -m 0755 -vd %{buildroot}%{_bindir} install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ ``` -------------------------------- ### Configure %prep for Vendored Dependencies Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust Example of a %prep scriptlet setup when using a vendor tarball for Rust dependencies. ```spec %prep %autosetup -%{crate}-%{version} -p1 -a1 %cargo_prep -v vendor ``` -------------------------------- ### Example tmpfiles.d configuration Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Tmpfiles.d A concrete example of creating a /run/mysqld directory with specific permissions and ownership. ```text d /run/mysqld 0755 mysql mysql - ``` -------------------------------- ### Define the [Install] section Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Systemd The [Install] section specifies the target for enabling the service. ```ini [Install] WantedBy=... ``` -------------------------------- ### Install debuginfo post-processing Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/MinGW Call this macro in the %install section after binary files have been installed to the virtual root. ```rpm-spec %install [...] %{?mingw_debug_install_post} ``` -------------------------------- ### Example RPM Spec File for Meson Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Meson A complete example of an RPM spec file utilizing Meson macros for configuration, building, installation, and testing. ```spec %global _vpath_srcdir sdk/%{name}/projects/meson Name: angelscript Version: 2.31.1 Release: 1%{?dist} Summary: Flexible cross-platform scripting library License: zlib URL: https://www.angelcode.com/angelscript/ Source: %{url}sdk/files/%{name}_%{version}.zip BuildRequires: meson BuildRequires: gcc %package devel Summary: Development libraries and header files for %{name} Requires: %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} %description devel %{summary}. %prep %autosetup -c %conf %meson %build %meson_build %install %meson_install %check %meson_test %files %{_libdir}/lib%{name}.so.* %files devel %{_libdir}/lib%{name}.so %{_includedir}/%{name}.h ``` -------------------------------- ### Build and install binary packages Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Haskell Use these macros in the build and install sections for binary packages. ```RPM %build %ghc_bin_build %install %ghc_bin_install ``` -------------------------------- ### Install LibreOffice extension in RPM spec Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/LibreOfficeExtensions Example of defining the extension name and installing the unpacked extension files into the required LibreOffice directory. ```rpm %global extname writer2latex Name: libreoffice-%{extname} Requires: libreoffice-core %install install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/libreoffice/share/extensions/%{extname} unzip -q target/lib/%{extname}.oxt -d $RPM_BUILD_ROOT%{_libdir}/libreoffice/share/extensions/%{extname} ``` -------------------------------- ### Register assemblies with gacutil Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Mono Example of installing and registering a library into the GAC within a spec file. ```spec %install mkdir -p %{buildroot}/%{_monogacdir} gacutil -i bin/mono-1.0/release/MySql.Data.dll -f -package mysql-connector-net -root %{buildroot}/usr/lib %files %{_monogacdir}/MySql.Data %{_monodir}/mysql-connector-net/ ``` -------------------------------- ### Build and install library packages Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Haskell Use these macros in the build and install sections for library and binary-library packages. ```RPM %build %ghc_lib_build %install %ghc_lib_install ``` -------------------------------- ### Addon Package Naming Examples Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Naming Examples of the %{parent}-%{child} naming format for addon packages. ```text gnome-applet-netmon (netmon applet for gnome, relies on gnome) php-adodb (adodb functionality for php, relies on php) python3-twisted (the twisted module for python3, relies on python3) xmms-cdread (direct cd read functionality for xmms, relies on xmms) ``` -------------------------------- ### Prepare library packages Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Haskell Use the setup macro to correctly unpack the source for library packages. ```RPM %prep %setup -q -n %{pkg_name}-%{version} ``` -------------------------------- ### Specialized Addon Naming Examples Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Naming Examples of naming schemes for httpd, pam, and SDL addon packages. ```text mod_perl (Perl components for Apache httpd, relies on httpd) pam_krb5 (krb5 components for pam, relies on pam) SDL_gfx (Additional graphics components for SDL, relies on SDL) SDL_ttf (TrueType font rendering support for SDL, relies on SDL) ``` -------------------------------- ### Sample Addon .metainfo.xml File Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/AppData Example structure for an application add-on metadata file. ```xml gedit-bookmarks gedit.desktop Bookmarks Easy document navigation with bookmarks https://wiki.gnome.org/Apps/Gedit/ShippedPlugins https://bugzilla.gnome.org/enter_bug.cgi?product=gedit&component=Plugins CC0-1.0 GPL-2.0+ ``` -------------------------------- ### Install R package Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/R Use %R_install and %R_save_files in the %install section; the %build section must remain empty. ```RPM %build %install %R_install %R_save_files ``` -------------------------------- ### Sample Application .metainfo.xml File Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/AppData Example structure for a desktop application metadata file. ```xml comical.desktop CC0-1.0 GPL-2.0+ and GFDL-1.3 Comical A Comic Archive Reader Un Comic Archive Lecteur

Comical is an easy to use and cross-platform CBR and CBZ reader which prefetches and caches pages for speed.

Comical est une CBR et CBZ lecteur facile à utiliser et multi-plateforme qui prélectures et caches pages pour la vitesse.

Resized images are crisp, and you can view pages one or two at a time. Comical is open-source, so feel free to contribute new features!

Images redimensionnées sont nettes, et vous pouvez voir une ou deux pages à la fois. Comical est open-source, alors n'hésitez pas à apporter de nouvelles fonctionnalités!

http://comical.sourceforge.net/images/comical-0.5-linux.jpg http://comical.sourceforge.net/images/comical-0.6-win32.jpg http://comical.sourceforge.net/ richard_at_hughsie.com
``` -------------------------------- ### Install Fedora Specific File Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Ruby Install a specific source file into the appropriate binary directory during the install stage. ```RPM Spec install -m 0755 %{SOURCE1} %{buildroot}%{_bindir}/deltacloudd ``` -------------------------------- ### Locale Package Naming Examples Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Naming Examples of locale package naming using underscores. ```text ttfonts-zh_TW (adds zh_TW locale fonts in ttfonts family) ttfonts-zh_CN (adds zh_CN locale fonts in ttfonts family) ``` -------------------------------- ### Install Go source packages Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang_old Use this macro to install primary and compatibility import paths for Go libraries. ```rpm-spec %gopkginstall ``` -------------------------------- ### OCaml Dune Spec File Example Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/OCaml A complete RPM spec file template for an OCaml library built with Dune, demonstrating the use of standard build, install, and check macros. ```spec %ifnarch %{ocaml_native_compiler} %global debug_package %{nil} %endif Name: ocaml-foolib Version: 1.2.3 Release: %autorelease Summary: OCaml library for fooing bars License: LGPL-2.1-or-later URL: https://www.example.com/foolib Source: https://www.example.com/foolib-%{version}.tar.gz BuildRequires: ocaml BuildRequires: ocaml-dune %description OCaml library for fooing bars. This library can also foo bazes. %package devel Summary: Development files for %{name} Requires: %{name}%{?_isa} = %{version}-%{release} %description devel The %{name}-devel package contains libraries and signature files for developing applications that use %{name}. %prep %autosetup -n foolib-%{version} %build # Build all installable targets %dune_build # Build a specific set of targets %dune_build -p bazzer,boffer # Build non-default targets %dune_build @install @doc %install # Install all installable targets %dune_install # Install a specific set of targets %dune_install bazzer boffer %check # Check all installable targets %dune_check # Check a specific set of targets %dune_check -p bazzer,boffer %files -f .ofiles %doc README %license LICENSE %files devel -f .ofiles-devel %changelog %autochangelog ``` -------------------------------- ### Emacs Component Naming Examples Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Naming Examples of the emacs-$NAME naming format for Emacs components. ```text emacs-auctex (auctex component for GNU Emacs) emacs-deferred (deferred component for GNU Emacs) emacs-flycheck (flycheck component for GNU Emacs) ``` -------------------------------- ### Erlang Module Naming Example Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Naming Example of the erlang-$NAME naming format for Erlang modules. ```text erlang-esdl (Erlang module named esdl) ``` -------------------------------- ### Integrated MinGW Package Specfile Example Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/MinGW A comprehensive example demonstrating the integration of MinGW build requirements, package definitions, and build/install commands within a standard specfile. ```rpm-spec %if 0%{?fedora} %bcond_without mingw %else %bcond_with mingw %endif Name: example Version: 1.0.0 Release: 1%{?dist} Summary: Example library License: LGPL-2.1-or-later URL: https://fedoraproject.org Source: https://fedoraproject.org/example-%{version}.tar.bz2 BuildRequires: gcc BuildRequires: binutils BuildRequires: gettext BuildRequires: zlib %if %{with mingw} BuildRequires: mingw32-filesystem BuildRequires: mingw32-gcc BuildRequires: mingw32-binutils BuildRequires: mingw32-gettext BuildRequires: mingw32-win-iconv BuildRequires: mingw32-zlib BuildRequires: mingw64-filesystem BuildRequires: mingw64-gcc BuildRequires: mingw64-binutils BuildRequires: mingw64-gettext BuildRequires: mingw64-win-iconv BuildRequires: mingw64-zlib %endif %description Example library. %package devel Summary: Example library development package ... %description devel Example library development headers and library. %if %{with mingw} # If a package maintainer wishes to bundle static libraries then they # can be placed in -static subpackages. Otherwise, the -static subpackages # can be dropped # Win32 %package -n mingw32-example Summary: MinGW compiled example library for the Win32 target BuildArch: noarch %description -n mingw32-example MinGW compiled example library for the Win32 target. %package -n mingw32-example-static Summary: Static version of the MinGW Win32 compiled example library Requires: mingw32-example = %{version}-%{release} %description -n mingw32-example-static Static version of the MinGW Win32 compiled example library. # Win64 %package -n mingw64-example Summary: MinGW compiled example library for the Win64 target %description -n mingw64-example MinGW compiled example library for the Win64 target. BuildArch: noarch %package -n mingw64-example-static Summary: Static version of the MinGW Win64 compiled example library Requires: mingw64-example = %{version}-%{release} %description -n mingw64-example-static Static version of the MinGW Win64 compiled example library. %{?mingw_debug_package} %endif %prep %autosetup -p1 -n example-%{version} %build %define _configure ../../configure mkdir -p build/native cd build/native %configure ... %make_build cd ../.. %if %{with mingw} %mingw_configure --enable-static --enable-shared --enable-foo %mingw_make_build %endif %install cd build/native %make_install %find_lang example cd ../.. %if %{with mingw} %mingw_make_install %mingw_find_lang example %endif %files %{_libdir}/libexample.so.* %files devel %{_libdir}/libexample.so %{_libdir}/pkgconfig/example.pc %{_includedir}/example/ # Static subpackages are optional (as mentioned earlier) %if %{with mingw} # Win32 %files -n mingw32-example -f mingw32-example.lang %{mingw32_bindir}/libexample-0.dll %{mingw32_includedir}/example/ %{mingw32_libdir}/libexample.dll.a %{mingw32_libdir}/pkgconfig/example.pc %files -n mingw32-example-static %{mingw32_libdir}/libexample.a # Win64 %files -n mingw64-example -f mingw64-example.lang %{mingw64_bindir}/libexample-0.dll %{mingw64_includedir}/example/ %{mingw64_libdir}/libexample.dll.a %{mingw64_libdir}/pkgconfig/example.pc %files -n mingw64-example-static %{mingw64_libdir}/libexample-0.a %endif %changelog * Sun Apr 15 2012 Erik van Pienbroek - 1.0.0-1 - Initial release ``` -------------------------------- ### Define Go build and installation macros in RPM spec Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang_templates Use these macros to automate dependency generation, installation, and testing for Go packages. ```rpm-spec %generate_buildrequires # “go_generate_buildrequires” computes the build dependencies of the packaged # Go code. Right now, it only knows how to compute version-less dependencies. # If that is not good enough for you you need to filter and rework its output. %go_generate_buildrequires %install # Perform installation steps for all known kinds of Go subpackages # You can replace if with “godevelinstall” to process Go devel subpackages only %gopkginstall %check # “gocheck” runs all the unit tests found in the project. This is useful to catch # API breakage early. Unfortunately, the following kinds of unit tests are # incompatible with a secure build environment: # – tests that call a remote server or API over the Internet, # – tests that attempt to reconfigure the system, # – tests that rely on a specific app running on the system, like a database # or syslog server. # You can disable those tests with the following exclusion flags, that can be # repeated: # – “-d ” exclude the files contained in # not recursive (subdirectories are not excluded) # – “-t ” exclude the files contained in # recursive (subdirectories are excluded) # – “-r ” exclude files matching , # If a test is broken for some other reason, you can disable it # the same way. However, you should also report the problem upstream. # Remember to trace in a comment why each check was disabled, with links to # eventual upstream problem reports. %gocheck # Generate file sections for all known kinds of Go subpackages # You can replace if with “godevelfiles” to process Go devel subpackages only %gopkgfiles ``` -------------------------------- ### Example spec file Release definition Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/DistTag A complete example showing how the Release field is defined in a spec file. ```spec Name: logjam Version: 1.4 Release: 2%{?dist} ``` -------------------------------- ### Example Tree-sitter spec file Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Tree-sitter A complete example of a spec file for a Tree-sitter parser package. ```spec Name: tree-sitter-typescript Version: 0.21.2 Release: %autorelease License: MIT URL: https://github.com/tree-sitter/%{name} Source: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz BuildSystem: tree_sitter %{tree_sitter -l %{quote:TypeScript and TSX}} %changelog %autochangelog ``` -------------------------------- ### Install Vendored Licenses Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang Macro to install license files from the main project and all vendored modules. ```rpm-spec # Install into the main package's license directory %go_vendor_license_install -c %{S:2} ``` -------------------------------- ### Example output of golist dependency gathering Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang_old The resulting BuildRequires lines generated by the golist utility. ```text BuildRequires: golang(github.com/stretchr/testify/assert) BuildRequires: golang(github.com/stretchr/testify/require) BuildRequires: golang(golang.org/x/crypto/ssh/terminal) ``` -------------------------------- ### Define subpackage provides Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python_201x Example of using %py_provides within a subpackage definition. ```rpm %package -n python3-%{srcname} Summary: %{summary} %py_provides python3-%{srcname} ``` -------------------------------- ### Install Go devel subpackages Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang_old Use this macro to install Go development files without compatibility paths. ```rpm-spec %godevelinstall ``` -------------------------------- ### Define upstream dependencies in setup.py Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python_201x Example of the install_requires list found in a Python package's setup.py file. ```python install_requires = [     'jinja2',     'tornado>=4',     'pyzmq>=17',     'ipython_genutils',     'traitlets>=4.2.1',     'jupyter_core>=4.4.0',     'jupyter_client>=5.2.0',     'nbformat',     'nbconvert',     'ipykernel',     'Send2Trash',     'terminado>=0.8.1',     'prometheus_client' ], ``` -------------------------------- ### RPM Spec File Installation and Files Macros Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang_templates Standard macros for installing Go binaries and declaring package files in an RPM spec file. ```rpm-spec %install # You can replace “gopkginstall” with “godevelinstall” and “goaltinstall” # calls for finer control. # “godevelinstall” and “goaltinstall” accept the usual selection arguments: # – “-a” process everything # – “-z ” process a specific declaration block # If no flag is specified they only process the zero/nosuffix block. %gopkginstall install -m 0755 -vd %{buildroot}%{_bindir} install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ %check %gocheck %files %license %doc %{_bindir}/* # You can replace “gopkgfiles” with “godevelfiles” and “goaltfiles” # calls for finer control. # “godevelfiles” and “goaltfiles” accept the usual selection arguments: # – “-a” process everything # – “-z ” process a specific declaration block # If no flag is specified they only process the zero/nosuffix block. %gopkgfiles %changelog ``` -------------------------------- ### Define D header directory Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/D The standard path for installing D header files. ```text /usr/include/d/ ``` -------------------------------- ### Define Emacs file locations Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Emacs Use these macros to specify installation directories for elisp files and startup scripts. ```rpm %{_emacs_sitelispdir}/foo ``` ```rpm %{_emacs_sitestartdir} ``` -------------------------------- ### Configure D-Bus service activation Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Systemd Example of a D-Bus service file that redirects activation to a systemd service. ```ini [D-BUS Service] Name=org.freedesktop.ConsoleKit Exec=console-kit-daemon --no-daemon User=root SystemdService=console-kit-daemon.service ``` -------------------------------- ### Using Python Dependency Macros Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python_201x Examples of using %{py3_dist} for BuildRequires and Requires, and %{py_dist_name} for name transformation. ```rpm BuildRequires: %{py3_dist PyMySQL} >= 0.7.5 # => BuildRequires: python3dist(pymysql) >= 0.7.5 Requires: %{py3_dist virtualenv pyPEG2} # => Requires: python3dist(virtualenv) python3dist(pypeg2) %{py_dist_name 0-._.-._.-._.-._.-._.-._.-0} # => 0-0 ``` -------------------------------- ### Handle Golang package renames Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang_old Example of using %goaltipaths to manage package renames in an RPM spec file. ```rpm-spec # https://github.com/sirupsen/logrus %global goipath github.com/sirupsen/logrus Version: 1.4.0 %gometa %global goaltipaths github.com/Sirupsen/logrus %global common_description %{expand: Logrus is a structured logger for Go (golang), completely API compatible with the standard library logger.} %global golicenses LICENSE %global godocs *.md Name: %{goname} Release: 1%{?dist} Summary: Structured logger for Go License: MIT URL: %{gourl} Source: %{gosource} BuildRequires: golang(golang.org/x/crypto/ssh/terminal) BuildRequires: golang(github.com/stretchr/testify/assert) %description %{common_description} %gopkg %prep %goprep %install %gopkginstall %check %gocheck %gopkgfiles %changelog * Wed Oct 31 2018 Robert-André Mauchin - 1.4.0-1 - First package for Fedora ``` -------------------------------- ### Initialize MinGW spec file Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/MinGW Include this macro at the start of spec files to enable automatic dependency generation. ```rpm-spec %{?mingw_package_header} ``` -------------------------------- ### Example fc-scan output Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/FontsPolicy Sample output showing the metadata structure for a font file before applying fixes. ```text Accanthis ADF Std Regular AccanthisADFStd-Regular 100 80 0 131400 /usr/share/fonts/adf-accanthis-fonts/AccanthisADFStd-Regular.otf ``` -------------------------------- ### Expanded %pycached macro example Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python This shows the approximate expansion of the %pycached macro for a given source file. ```spec %files %{python3_sitelib}/foo.py %{python3_sitelib}/__pycache__/foo.cpython-3X{,.opt-?}.pyc ``` -------------------------------- ### Manual extra subpackage definition Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python This example shows the manual implementation of an extras subpackage, which is required if the convenience macros do not support specific needs. ```spec %package -n python3-setuptools_scm+toml Summary: Metapackage for python3-setuptools_scm: toml extra Requires: python3-setuptools_scm = %{?epoch:%{epoch}:}%{version}-%{release} %description -n python3-setuptools_scm+toml This is a metapackage bringing in toml extra requires for python3-setuptools_scm. It contains no code, just makes sure the dependencies are installed. %files -n python3-setuptools_scm+toml %ghost %{python3_sitelib}/*.dist-info ``` -------------------------------- ### List Python modules in %files section Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python_201x Use these macros to specify the installation paths for pure Python modules and compiled extension modules within the %files section of a spec file. ```rpm %files # A pure python3 module %{python3_sitelib}/foomodule/ # A compiled python3 extension module %{python3_sitearch}/barmodule/ ``` -------------------------------- ### Example Python Library Spec File Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python A template spec file for a Python library named Pello, demonstrating standard macros and subpackage configuration. ```spec Name: python-pello Version: 1.0.4 Release: 1%{?dist} Summary: Example Python library License: MIT-0 URL: https://github.com/fedora-python/Pello Source: %{url}/archive/v%{version}/Pello-%{version}.tar.gz BuildArch: noarch BuildRequires: python3-devel %global _description %{expand: A python module which provides a convenient example. This description provides some details.} %description %_description %package -n python3-pello Summary: %{summary} Recommends: python3-pello+color %description -n python3-pello %_description %pyproject_extras_subpkg -n python3-pello color %prep %autosetup -p1 -n Pello-%{version} %generate_buildrequires %pyproject_buildrequires -t %build %pyproject_wheel %install %pyproject_install # Here, "pello" is the name of the importable module. %pyproject_save_files -l pello %check %tox # Note that there is no %%files section for # the unversioned python module, python-pello. # For python3-pello, %%{pyproject_files} handles code files and %%license, # but executables and documentation must be listed in the spec file: %files -n python3-pello -f %{pyproject_files} %doc README.md %{_bindir}/pello_greeting %changelog ``` -------------------------------- ### Example Spec File Configuration Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang_advanced A sample spec file demonstrating how to use %gometa and conditional logic to handle subpackages and avoid cyclic dependencies. ```spec # Generated by go2rpm %bcond_without check %bcond_without bootstrap # https://github.com/GoogleCloudPlatform/google-cloud-go %global goipath cloud.google.com/go %global forgeurl https://github.com/GoogleCloudPlatform/google-cloud-go Version: 0.37.4 %gometa %if %{without bootstrap} %global goipaths0 cloud.google.com/go %global goipathsex0 cloud.google.com/go/compute %endif %global goipaths1 cloud.google.com/go/compute %global common_description %{expand: Go packages for Google Cloud Platform services.} %global golicenses LICENSE %global godocs AUTHORS CODE_OF_CONDUCT.md CONTRIBUTING.md CONTRIBUTORS RELEASING.md old-news.md CHANGES.md README.md Name: %{goname} Release: 1%{?dist} Summary: Google Cloud client libraries for Go # Upstream license specification: Apache-2.0 License: Apache-2.0 URL: %{gourl} Source: %{gosource} %if %{without bootstrap} BuildRequires: golang(github.com/golang/mock/gomock) BuildRequires: golang(github.com/golang/protobuf/proto) BuildRequires: golang(github.com/golang/protobuf/ptypes) BuildRequires: golang(github.com/golang/protobuf/ptypes/any) BuildRequires: golang(github.com/golang/protobuf/ptypes/duration) BuildRequires: golang(github.com/golang/protobuf/ptypes/empty) BuildRequires: golang(github.com/golang/protobuf/ptypes/struct) BuildRequires: golang(github.com/golang/protobuf/ptypes/timestamp) BuildRequires: golang(github.com/golang/protobuf/ptypes/wrappers) BuildRequires: golang(github.com/google/btree) ``` -------------------------------- ### Configure %prep for PEAR/PECL archives Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/PHP Use this setup command when the source archive contains a package.xml file at the root level to prevent file write errors. ```rpm %setup -q -c ``` -------------------------------- ### RPM Spec File Configuration for tmpfiles.d Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Tmpfiles.d Example of installing a tmpfiles.d configuration file and managing runtime directories or files in an RPM spec file. ```rpm-spec # For the _tmpfilesdir macro. BuildRequires: systemd-rpm-macros # tmpfiles.d configuration for the /run directory Source1: %{name}-tmpfiles.conf [...] %install mkdir -p %{buildroot}%{_tmpfilesdir} install -m 0644 %{SOURCE1} %{buildroot}%{_tmpfilesdir}/%{name}.conf # This may not be needed if the upstream's install script creates the directories # Make sure permissions are correct install -d -m 0755 %{buildroot}/run/%{name}/ # A bit contrived as most packages will either create a subdirectory or a single file. Not both # Make sure permissions are correct touch %{buildroot}/run/%{name}.pid chmod 0644 %{buildroot}/run/%{name}.pid [...] %files # Use %attr() if needed to change ownership of these two items %dir /run/%{name}/ %verify(not size mtime md5) /run/%{name}.pid %{_tmpfilesdir}/%{name}.conf ``` -------------------------------- ### Include jQuery via HTML script tag Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/JavaScript Example of referencing a JavaScript library installed in the standard %{_jsdir} location within a web application. ```html ; ``` -------------------------------- ### Package a cron job in an RPM spec file Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/CronFiles Example of how to install and mark a cron job file as a configuration file within an RPM spec. ```rpm-spec Name: ... Source1: %{name}.cron Requires: crontabs ... %install ... mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/cron.monthly %{__install} -p -D -m 0750 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/cron.monthly/%{name} %files %config(noreplace) %{_sysconfdir}/cron.monthly/%{name} ``` -------------------------------- ### Abbreviated Ruby Application Spec File Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Ruby An example spec file structure for a Ruby-based REST API, demonstrating manual file installation and service configuration. ```RPM Spec %global app_root %{_datadir}/%{name} Summary: Deltacloud REST API Name: deltacloud-core Version: 0.3.0 Release: 3%{?dist} Group: Development/Languages License: Apache-2.0 AND MIT URL: https://incubator.apache.org/deltacloud Source: https://rubygems.org/gems/%{name}-%{version}.gem Requires: rubygem-haml #... Requires(post): chkconfig #... BuildRequires: rubygem-haml #... BuildArch: noarch %description The Deltacloud API is built as a service-based REST API. You do not directly link a Deltacloud library into your program to use it. Instead, a client speaks the Deltacloud API over HTTP to a server which implements the REST interface. %package doc Summary: Documentation for %{name} Group: Documentation Requires:%{name} = %{version}-%{release} %description doc Documentation for %{name} %prep %setup -q -n %{name}-%{version} %build %install mkdir -p %{buildroot}%{app_root} mkdir -p %{buildroot}%{_initddir} mkdir -p %{buildroot}%{_bindir} cp -r * %{buildroot}%{app_root} mv %{buildroot}%{app_root}/support/fedora/%{name} %{buildroot}%{_initddir} find %{buildroot}%{app_root}/lib -type f | xargs chmod -x chmod 0755 %{buildroot}%{_initddir}/%{name} chmod 0755 %{buildroot}%{app_root}/bin/deltacloudd rm -rf %{buildroot}%{app_root}/support rdoc --op %{buildroot}%{_defaultdocdir}/%{name} %post # This adds the proper /etc/rc*.d links for the script /sbin/chkconfig --add %{name} %files %{_initddir}/%{name} %{_bindir}/deltacloudd %dir %{app_root}/ %{app_root}/bin #... %files doc %{_defaultdocdir}/%{name} %{app_root}/tests %{app_root}/%{name}.gemspec %{app_root}/Rakefile %changelog #... ``` -------------------------------- ### Remove -s flag from Python shebang Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python Use this to ensure extensions installed in user locations are visible and loaded. ```spec # Remove -s from Python shebang - ensure that extensions installed with pip # to user locations are seen and properly loaded %undefine _py3_shebang_s ``` -------------------------------- ### Disable GConf schema installation during build Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/ScriptletsGConf Use the GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL environment variable to prevent schema installation during the make install phase. ```rpm-spec %install export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL=1 make install DESTDIR=$RPM_BUILD_ROOT ... ``` -------------------------------- ### Prepare R package sources Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/R Use the -c option with %autosetup to ensure sources are extracted into a subdirectory. ```RPM %prep %autosetup -c ``` -------------------------------- ### Inspect RPM provides Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/AutoProvidesAndRequiresFiltering Use rpm -qp to list the provides extracted by RPM for a built package. ```bash libprivate.so()(64bit) foo = 1.0-1.fc19 foo(x86-64) = 1.0-1.fc19 ``` -------------------------------- ### Install Ansible collection Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Ansible_collections Extracts metadata from galaxy.yml to install the collection and generate the file list. ```rpm-spec %install %ansible_collection_install ``` -------------------------------- ### Configure go-vendor-tools.toml Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang Minimal configuration file specifying the license detector backend. ```toml [licensing] detector = "askalono" ``` -------------------------------- ### List of Provided Go Packages Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang_advanced A list of provided Go import paths and their corresponding versions for the cloud.google.com/go module. ```text golang(cloud.google.com/go/logging/logadmin) = 0.36.0-1.fc31 golang(cloud.google.com/go/longrunning) = 0.36.0-1.fc31 golang(cloud.google.com/go/longrunning/autogen) = 0.36.0-1.fc31 golang(cloud.google.com/go/monitoring/apiv3) = 0.36.0-1.fc31 golang(cloud.google.com/go/oslogin/apiv1) = 0.36.0-1.fc31 golang(cloud.google.com/go/oslogin/apiv1beta) = 0.36.0-1.fc31 golang(cloud.google.com/go/profiler) = 0.36.0-1.fc31 golang(cloud.google.com/go/profiler/mocks) = 0.36.0-1.fc31 golang(cloud.google.com/go/profiler/proftest) = 0.36.0-1.fc31 golang(cloud.google.com/go/pubsub) = 0.36.0-1.fc31 golang(cloud.google.com/go/pubsub/apiv1) = 0.36.0-1.fc31 golang(cloud.google.com/go/pubsub/internal/distribution) = 0.36.0-1.fc31 golang(cloud.google.com/go/pubsub/loadtest) = 0.36.0-1.fc31 golang(cloud.google.com/go/pubsub/loadtest/pb) = 0.36.0-1.fc31 golang(cloud.google.com/go/pubsub/pstest) = 0.36.0-1.fc31 golang(cloud.google.com/go/redis/apiv1) = 0.36.0-1.fc31 golang(cloud.google.com/go/redis/apiv1beta1) = 0.36.0-1.fc31 golang(cloud.google.com/go/rpcreplay) = 0.36.0-1.fc31 golang(cloud.google.com/go/rpcreplay/proto/intstore) = 0.36.0-1.fc31 golang(cloud.google.com/go/rpcreplay/proto/rpcreplay) = 0.36.0-1.fc31 golang(cloud.google.com/go/scheduler/apiv1beta1) = 0.36.0-1.fc31 golang(cloud.google.com/go/securitycenter/apiv1beta1) = 0.36.0-1.fc31 golang(cloud.google.com/go/spanner) = 0.36.0-1.fc31 golang(cloud.google.com/go/spanner/admin/database/apiv1) = 0.36.0-1.fc31 golang(cloud.google.com/go/spanner/admin/instance/apiv1) = 0.36.0-1.fc31 golang(cloud.google.com/go/spanner/apiv1) = 0.36.0-1.fc31 golang(cloud.google.com/go/spanner/internal/backoff) = 0.36.0-1.fc31 golang(cloud.google.com/go/spanner/internal/testutil) = 0.36.0-1.fc31 golang(cloud.google.com/go/speech/apiv1) = 0.36.0-1.fc31 golang(cloud.google.com/go/speech/apiv1p1beta1) = 0.36.0-1.fc31 golang(cloud.google.com/go/storage) = 0.36.0-1.fc31 golang(cloud.google.com/go/talent/apiv4beta1) = 0.36.0-1.fc31 golang(cloud.google.com/go/texttospeech/apiv1) = 0.36.0-1.fc31 golang(cloud.google.com/go/trace) = 0.36.0-1.fc31 golang(cloud.google.com/go/trace/apiv1) = 0.36.0-1.fc31 golang(cloud.google.com/go/trace/apiv2) = 0.36.0-1.fc31 golang(cloud.google.com/go/translate) = 0.36.0-1.fc31 golang(cloud.google.com/go/translate/internal/translate/v2) = 0.36.0-1.fc31 golang(cloud.google.com/go/videointelligence/apiv1) = 0.36.0-1.fc31 golang(cloud.google.com/go/videointelligence/apiv1beta1) = 0.36.0-1.fc31 golang(cloud.google.com/go/videointelligence/apiv1beta2) = 0.36.0-1.fc31 golang(cloud.google.com/go/vision/apiv1) = 0.36.0-1.fc31 golang(cloud.google.com/go/vision/apiv1p1beta1) = 0.36.0-1.fc31 golang-cloud-google-devel = 0.36.0-1.fc31 golang-cloud-google-devel(x86-64) = 0.36.0-1.fc31 golang-ipath(cloud.google.com/go) = 0.36.0-1.fc31 ``` -------------------------------- ### Manual MinGW Build Directory Configuration Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/MinGW Example of manually creating and configuring separate build directories for shared and static versions using MinGW macros. ```rpm-spec mkdir build_shared pushd build_shared %{mingw32_configure} --enable-shared popd mkdir build_static pushd build_static %{mingw32_configure} --enable-static popd ``` -------------------------------- ### Configure Installation Directories Source: https://docs.fedoraproject.org/en-US/packaging-guidelines/Tcl Use configure switches to redirect installation paths for noarch packages. ```RPM Spec %configure --libdir=%{tcl_sitelib} --datadir=%{tcl_sitelib} ```