Template Spec Files: различия между версиями
Материал из ROSA Wiki
PastorDi (обсуждение | вклад) Новая страница: «=Spec файл для сборки программ используя GNU Autotools= <pre> Summary: foo Name: foo Version: 1.0 Release: 1 License: foo Group: foo Url: foo Source0: %{name}-%{version}.tar.bz2 %description foo. %files -f %{name}.lang #------------------------------------------------------------------ %prep %setup -q %build %configure2_5x %make %install %makeinstall_std %find_lang %{name} </pre> =Spec файл для сборки...» |
Survolog (обсуждение | вклад) м %make -> %make_build %makeinstall_std -> %make_install |
||
(не показаны 2 промежуточные версии 1 участника) | |||
Строка 1: | Строка 1: | ||
=Spec | = Spec file for a program built using GNU Autotools = | ||
<pre> | <pre> | ||
Summary: foo | Summary: foo | ||
Name: foo | Name: foo | ||
Version: 1.0 | Version: 1.0 | ||
Release: 1 | Release: 1 | ||
Строка 9: | Строка 8: | ||
Group: foo | Group: foo | ||
Url: foo | Url: foo | ||
Source0: %{name}-%{version}.tar. | Source0: %{name}-%{version}.tar.gz | ||
%description | %description | ||
Строка 19: | Строка 18: | ||
%prep | %prep | ||
% | %autosetup -p1 | ||
%build | %build | ||
% | %configure | ||
% | %make_build | ||
%install | %install | ||
% | %make_install | ||
%find_lang %{name} | %find_lang %{name} | ||
</pre> | </pre> | ||
=Spec | = Spec file for a program built using CMake = | ||
<pre> | <pre> | ||
Summary: foo | Summary: foo | ||
Строка 41: | Строка 39: | ||
Group: foo | Group: foo | ||
Url: foo | Url: foo | ||
Source0: %{name}-%{version}.tar. | Source0: %{name}-%{version}.tar.gz | ||
BuildRequires: cmake | BuildRequires: cmake | ||
Строка 52: | Строка 50: | ||
%prep | %prep | ||
% | %autosetup -p1 | ||
%build | %build | ||
%cmake | %cmake | ||
% | %make_build | ||
%install | %install | ||
% | %make_install -C build | ||
%find_lang %{name} | %find_lang %{name} | ||
</pre> | </pre> | ||
=Spec | = Spec file for a program written in Qt4 and built using cmake = | ||
<pre> | <pre> | ||
Summary: foo | Summary: foo | ||
Строка 74: | Строка 71: | ||
Group: foo | Group: foo | ||
Url: foo | Url: foo | ||
Source0: %{name}-%{version}.tar. | Source0: %{name}-%{version}.tar.gz | ||
BuildRequires: cmake | BuildRequires: cmake | ||
BuildRequires: qt4-devel | BuildRequires: qt4-devel | ||
Строка 86: | Строка 83: | ||
%prep | %prep | ||
% | %autosetup -p1 | ||
%build | %build | ||
%cmake_qt4 | %cmake_qt4 | ||
% | %make_build | ||
%install | %install | ||
% | %make_install -C build | ||
%find_lang %{name} | %find_lang %{name} | ||
< | <pre> | ||
= Spec file for a program written in Qt5 and built using cmake = | |||
<pre> | <pre> | ||
Summary: foo | Summary: foo | ||
Строка 108: | Строка 104: | ||
Group: foo | Group: foo | ||
Url: foo | Url: foo | ||
Source0: %{name}-%{version}.tar. | Source0: %{name}-%{version}.tar.gz | ||
BuildRequires: cmake | BuildRequires: cmake | ||
BuildRequires: qt5-devel | BuildRequires: qt5-devel | ||
Строка 120: | Строка 116: | ||
%prep | %prep | ||
% | %autosetup -p1 | ||
%build | %build | ||
%cmake_qt5 | %cmake_qt5 | ||
% | %make_build | ||
%install | %install | ||
% | %make_install -C build | ||
%find_lang %{name} | %find_lang %{name} | ||
< | <pre> | ||
= Spec file for a program built using Meson = | |||
<pre> | |||
Summary: foo | |||
Name: foo | |||
Version: 1.0 | |||
Release: 1 | |||
License: foo | |||
Group: foo | |||
Url: foo | |||
Source0: %{name}-%{version}.tar.gz | |||
BuildRequires: meson | |||
%description | |||
foo. | |||
%files -f %{name}.lang | |||
#------------------------------------------------------------------ | |||
%prep | |||
%autosetup -p1 | |||
%build | |||
%meson | |||
%meson_build | |||
%install | |||
%meson_install | |||
%find_lang %{name} | |||
<pre> | |||
=Spec | = Spec file for a program built using Perl/Makefile.PL = | ||
<pre> | <pre> | ||
%define upstream_name | %define upstream_name foo | ||
%define upstream_version 1.0 | %define upstream_version 1.0 | ||
Строка 144: | Строка 172: | ||
Group: foo | Group: foo | ||
Url: foo | Url: foo | ||
Source0: %{upstream_name}-%{upstream_version}.tar. | Source0: %{upstream_name}-%{upstream_version}.tar.gz | ||
BuildRequires: perl-devel | BuildRequires: perl-devel | ||
BuildRequires: perl(ExtUtils::MakeMaker) | |||
%description | %description | ||
Строка 155: | Строка 184: | ||
%prep | %prep | ||
% | %autosetup -p1 -n %{upstream_name}-%{upstream_version} | ||
%build | %build | ||
perl Makefile.PL INSTALLDIRS=vendor | perl Makefile.PL INSTALLDIRS=vendor | ||
% | %make_build | ||
%check | %check | ||
make test | |||
%install | %install | ||
% | %make_install | ||
< | <pre> | ||
=Spec | = Spec file for a program built using Perl/Build.PL = | ||
<pre> | <pre> | ||
%define upstream_name | %define upstream_name foo | ||
%define upstream_version 1.0 | %define upstream_version 1.0 | ||
Строка 180: | Строка 209: | ||
Group: foo | Group: foo | ||
Url: foo | Url: foo | ||
Source0: %{upstream_name}-%{upstream_version}.tar. | Source0: %{upstream_name}-%{upstream_version}.tar.gz | ||
BuildRequires: perl-devel | BuildRequires: perl-devel | ||
BuildRequires: perl(Module::Build) | BuildRequires: perl(Module::Build) | ||
Строка 192: | Строка 221: | ||
%prep | %prep | ||
% | %autosetup -p1 -n %{upstream_name}-%{upstream_version} | ||
%build | %build | ||
Строка 205: | Строка 234: | ||
</pre> | </pre> | ||
=Spec | = Spec file for a Python module = | ||
== Spec file to build python3 module with setup.py == | |||
python-mymodule.spec: | |||
<pre>%define pypi_name mymodule | |||
Summary: Example module | |||
Name: python-%{pypi_name} | |||
Version: 1.0 | |||
Release: 1 | |||
License: GPL | |||
Group: Development/Python | |||
Url: http://mypage.org/mymodule | |||
Source0: %{pypi_name}-%{version}.tar.gz | |||
#if source available on pypi.org uncoment next line, and remove line Source0: above | |||
#Source0: %pypi_source | |||
BuildRequires: pkgconfig(python3) | |||
%define _description \ | |||
Text about \ | |||
example Python module | |||
%description | |||
%{_description} | |||
#------------------------------------------------------------------ | |||
%package -n python3-%{pypi_name} | |||
Summary: %{summary} | |||
Group: Development/Python | |||
%description -n python3-%{pypi_name} | |||
%{_description} | |||
%files -n python3-%{pypi_name} | |||
# for files in /usr/lib64/python3.8/site-packages | |||
%{python3_sitearch}/* | |||
%{python3_sitearch}/%{pypi_name}-%{version}-py*.egg-info | |||
# for files in /usr/lib/python3.8/site-packages uncomment next lines | |||
#%%{python3_sitelib}/* | |||
#%%{python3_sitelib}/%{pypi_name}-%{version}-py*.egg-info | |||
#------------------------------------------------------------------ | |||
%prep | |||
%autosetup -p1 | |||
%build | |||
%py3_build | |||
%install | |||
%py3_install | |||
# uncomment for fix rpmlint error "set python3 shebang" | |||
#%%py3_shebang_fix | |||
%check | |||
%pytest</pre> | |||
== Spec file to build python3 module with pyproject.toml == | |||
python-mymodule.spec: | |||
<pre> | |||
%define pypi_name mymodule | |||
Summary: Example module | |||
Name: python-%{pypi_name} | |||
Version: 1.0 | |||
Release: 1 | |||
License: GPL | |||
Group: Development/Python | |||
Url: http://mypage.org/mymodule | |||
#if source available on pypi.org | |||
Source0: %pypi_source | |||
# if source not available on pypi.org uncomment line below and comment Source0 upper | |||
#Source0: %{pypi_name}-%{version}.tar.gz | |||
BuildRequires: pkgconfig(python3) | |||
BuildRequires: pyproject-rpm-macros | |||
# for %%check if needed | |||
BuildRequires: python3egg(pytest) | |||
%define _description \ | |||
Text about \ | |||
example Python module | |||
%description | |||
%{_description} | |||
#------------------------------------------------------------------ | |||
%package -n python3-%{pypi_name} | |||
Summary: %{summary} | |||
Group: Development/Python | |||
%description -n python3-%{pypi_name} | |||
%{_description} | |||
%files -n python3-%{pypi_name} -f %{pyproject_files} | |||
%license LICENSE | |||
%doc README* | |||
#------------------------------------------------------------------ | |||
%prep | |||
%autosetup -p1 -n %{pypi_name}-%{version} | |||
# for autoinstall BuildRequires | |||
%generate_buildrequires | |||
%pyproject_buildrequires -r | |||
%build | |||
%pyproject_wheel | |||
%install | |||
%pyproject_install | |||
%pyproject_save_files %{pypi_name} | |||
# uncomment for fix rpmlint error "set python3 shebang" | |||
#%%py3_shebang_fix | |||
%check | |||
%pytest | |||
<pre> | |||
== Spec file to build python2 module (ROSA <= 2016.1) == | |||
<pre> | <pre> | ||
%define module mymodule | %define module mymodule | ||
Summary: | Summary: Example module | ||
Name: | Name: python-%{module} | ||
Version: | Version: 1.0 | ||
Release: | Release: 1 | ||
License: Apache License | License: Apache License | ||
Group: Development/Python | Group: Development/Python | ||
Url: http://mypage.org/mymodule | Url: http://mypage.org/mymodule | ||
Source0: | Source0: %{module}-%{version}.tar.gz | ||
BuildRequires: pkgconfig( | BuildRequires: pkgconfig(python2) | ||
%description | %description | ||
Example Python module. | Example Python module. | ||
%files | %files | ||
%doc *.txt | %doc *.txt | ||
%{python2_sitearch}/* | |||
#------------------------------------------------------------------ | #------------------------------------------------------------------ | ||
Строка 229: | Строка 379: | ||
%prep | %prep | ||
%setup -q | %setup -q | ||
%apply_patches | |||
%build | |||
%py2_build | |||
%install | %install | ||
%py2_install | |||
# | </pre> | ||
== Spec file to build python2 module (ROSA >= 2021.1) == | |||
python-mymodule.spec: | |||
<pre> | |||
%define pypi_name mymodule | |||
Summary: Example module | |||
Name: python-%{pypi_name} | |||
Version: 1.0 | |||
Release: 1 | |||
License: Apache License | |||
Group: Development/Python | |||
Url: http://mypage.org/mymodule | |||
Source0: %{pypi_name}-%{version}.tar.gz | |||
#if source available on pypi.org uncoment next line, and remove line Source0: above | |||
#Source0: %pypi_source | |||
BuildRequires: pkgconfig(python2) | |||
%define _description \ | |||
Text about \ | |||
example Python module | |||
%description | |||
%{_description} | |||
#------------------------------------------------------------------ | |||
%package -n python2-%{pypi_name} | |||
Summary: %{summary} | |||
Group: Development/Python | |||
%description -n python2-%{pypi_name} | |||
%{_description} | |||
%files -n python2-%{pypi_name} | |||
%{python2_sitearch}/* | |||
#------------------------------------------------------------------ | |||
%prep | |||
%autosetup -p1 | |||
%build | |||
%py2_build | |||
%install | |||
%py2_install | |||
</pre> | |||
== Spec file for both python2 and python3 modules, ROSA >= 2021.1 == | |||
python-mymodule.spec: | |||
<pre> | |||
%define pypi_name mymodule | |||
Summary: Example module | |||
Name: python-%{pypi_name} | |||
Version: 1.0 | |||
Release: 1 | |||
License: Apache License | |||
Group: Development/Python | |||
Url: http://mypage.org/mymodule | |||
Source0: %{pypi_name}-%{version}.tar.gz | |||
#if source available on pypi.org uncoment next line, and remove line Source0: above | |||
#Source0: %pypi_source | |||
%define _description \ | |||
Text about \ | |||
example Python module | |||
%description | |||
%{_description} | |||
#------------------------------------------------------------------ | |||
%package -n python2-%{pypi_name} | |||
Summary: Example python2 module | |||
Group: Development/Python | |||
BuildRequires: pkgconfig(python2) | |||
%py2_migration_meta python-%{pypi_name} | |||
%description -n python2-%{pypi_name} | |||
%{_description} | |||
%files -n python2-%{pypi_name} | |||
%{python2_sitearch}/* | |||
#------------------------------------------------------------------ | |||
%package -n python3-%{pypi_name} | |||
Summary: Example python3 module | |||
Group: Development/Python | |||
BuildRequires: pkgconfig(python3) | |||
%description -n python3-%{pypi_name} | |||
%{_description} | |||
%files -n python3-%{pypi_name} | |||
%{python3_sitearch}/* | |||
#------------------------------------------------------------------ | |||
%prep | |||
%autosetup -p1 | |||
%build | |||
%py2_build | |||
%py3_build | |||
%install | |||
%py2_install | |||
%py3_install | |||
</pre> | </pre> | ||
See also: [https://abf.io/import/rpm-openmandriva-setup/blob/rosa2019.1/0513-python2-macro-and-py2_migration_meta.patch %py2_migration_info] | |||
= Spec file for a Library = | |||
<pre> | <pre> | ||
%define major 1 | %define major 1 | ||
Строка 248: | Строка 513: | ||
Summary: foo | Summary: foo | ||
Name: foo | Name: foo | ||
Version: 1.0 | Version: 1.0 | ||
Release: 1 | Release: 1 | ||
Строка 254: | Строка 519: | ||
Group: foo | Group: foo | ||
Url: foo | Url: foo | ||
Source0: %{name}-%{version}.tar. | Source0: %{name}-%{version}.tar.gz | ||
%description | %description | ||
Строка 262: | Строка 527: | ||
%package -n %{libname} | %package -n %{libname} | ||
Summary: | Summary: %{name} shared library | ||
Group: System/Libraries | Group: System/Libraries | ||
%description -n %{libname} | %description -n %{libname} | ||
%{name} shared library. | |||
%files -n %{libname} | %files -n %{libname} | ||
Строка 274: | Строка 539: | ||
%package -n %{devname} | %package -n %{devname} | ||
Summary: | Summary: %{name} development files | ||
Group: Development/Other | Group: Development/Other | ||
Requires: | Requires: %{libname} = %{EVRD} | ||
Provides: | Provides: %{name}-devel = %{EVRD} | ||
%description -n %{devname} | %description -n %{devname} | ||
%{name} development files. | |||
%files -n %{devname} | %files -n %{devname} | ||
Строка 289: | Строка 554: | ||
%package -n %{sdevname} | %package -n %{sdevname} | ||
Summary: | Summary: %{name} development files (static library) | ||
Group: Development/Other | Group: Development/Other | ||
Requires: | Requires: %{devname} = %{EVRD} | ||
Provides: | Provides: %{name}-static-devel = %{EVRD} | ||
%description -n %{sdevname} | %description -n %{sdevname} | ||
%{name} development files (static library). | |||
%files -n %{sdevname} | %files -n %{sdevname} | ||
Строка 303: | Строка 568: | ||
%prep | %prep | ||
% | %autosetup -p1 | ||
%build | %build | ||
% | %configure | ||
% | %make_build | ||
%install | %install | ||
% | %make_install | ||
</pre> | </pre> | ||
See also: [[Libraries policy]] | |||
= Spec file for a Node.js module = | |||
<pre> | <pre> | ||
%define oname foo | %define oname foo | ||
Строка 339: | Строка 605: | ||
%prep | %prep | ||
% | %autosetup -p1 -n package | ||
rm -rf node_modules | rm -rf node_modules | ||
Строка 350: | Строка 616: | ||
</pre> | </pre> | ||
=Spec | = Spec file for a Ruby Gem (ROSA >= 2021.1) = | ||
<pre> | |||
%define gem_name foo | |||
Summary: Foo | |||
Name: rubygem-%{gem_name} | |||
Version: 1.0 | |||
Release: 1 | |||
Group: Development/Ruby | |||
License: GPLv2+ or Ruby | |||
URL: foo | |||
Source0: %{gem_name}-%{version}.gem | |||
BuildRequires: rubygems-devel | |||
BuildArch: noarch | |||
%description | |||
%{summary}. | |||
%files | |||
%dir %{gem_instdir} | |||
%license %{gem_instdir}/LICENSE.txt | |||
%{gem_libdir} | |||
%exclude %{gem_cache} | |||
%{gem_spec} | |||
#------------------------------------------------------------------ | |||
%package doc | |||
Summary: Documentation for %{name} | |||
Group: Books/Computer books | |||
Requires: %{name} = %{EVRD} | |||
%description doc | |||
Documents, RDoc & RI documentation for %{name}. | |||
%files doc | |||
%doc %{gem_docdir} | |||
%doc %{gem_instdir}/CHANGELOG.md | |||
%{gem_instdir}/Gemfile | |||
%doc %{gem_instdir}/README.md | |||
%doc %{gem_instdir}/SECURITY.md | |||
#------------------------------------------------------------------ | |||
%prep | |||
%autosetup -p1 -n %{gem_name}-%{version} | |||
%build | |||
%gem_build | |||
%install | |||
%gem_install | |||
mkdir -p %{buildroot}%{gem_dir} | |||
cp -a .%{gem_dir}/* \ | |||
%{buildroot}%{gem_dir}/ | |||
cp ../%{gem_name}-%{version}.gemspec %{buildroot}%{gem_dir}/specifications | |||
</pre> | |||
= Spec file for a Ruby Gem (ROSA <= 2016.1) = | |||
<pre> | <pre> | ||
%define rbname foo | %define rbname foo | ||
Строка 389: | Строка 713: | ||
%prep | %prep | ||
%setup -q | %setup -q | ||
%apply_patches | |||
%build | %build | ||
Строка 397: | Строка 722: | ||
</pre> | </pre> | ||
= Spec | = Spec file for a Haskell Library = | ||
<pre> | |||
%define _disable_ld_no_undefined 1 | |||
%global debug_package %{nil} | |||
%global pkg_name Foo | |||
% | %global pkgver %{pkg_name}-%{version} | ||
Summary: foo | Summary: foo | ||
Name: ghc-%{ | Name: ghc-%{pkg_name} | ||
Version: 1.0 | Version: 1.0 | ||
Release: 1 | Release: 1 | ||
License: BSD | License: BSD | ||
Group: Development/Haskell | Group: Development/Haskell | ||
Url: https://hackage.haskell.org/package/%{pkg_name} | |||
Source0: https://hackage.haskell.org/package/%{pkgver}/%{pkgver}.tar.gz | |||
BuildRequires: ghc-devel | |||
BuildRequires: ghc-prof | |||
BuildRequires: ghc-rpm-macros | |||
%description | |||
%{summary}. | |||
%files -f %{name}.files | |||
%license LICENSE | |||
#---------------------------------------------------------------------- | |||
%package devel | |||
Summary: %{summary} | |||
Provides: %{name}-static = %{EVRD} | |||
Provides: %{name}-static%{?_isa} = %{EVRD} | |||
%if %{defined ghc_version} | |||
Requires: ghc = %{ghc_version} | |||
%endif | |||
Requires: %{name}%{?_isa} = %{EVRD} | |||
%description devel | |||
This package provides the Haskell %{pkg_name} library development files. | |||
%files devel -f %{name}-devel.files | |||
#---------------------------------------------------------------------- | |||
%if %{with haddock} | |||
%package doc | |||
Summary: Haskell %{pkg_name} library documentation | |||
BuildArch: noarch | |||
%description doc | |||
This package provides the Haskell %{pkg_name} library documentation. | |||
%files doc -f %{name}-doc.files | |||
%license LICENSE | |||
%endif | |||
#---------------------------------------------------------------------- | |||
%if %{with ghc_prof} | |||
%package prof | |||
Summary: Haskell %{pkg_name} profiling library | |||
Requires: %{name}-devel%{?_isa} = %{EVRD} | |||
Supplements: (%{name}-devel and ghc-prof) | |||
%description prof | |||
This package provides the Haskell %{pkg_name} profiling library. | |||
%files prof -f %{name}-prof.files | |||
%endif | |||
#---------------------------------------------------------------------- | |||
%prep | |||
%autosetup -p1 -n %{pkgver} | |||
%build | |||
%ghc_lib_build | |||
%install | |||
%ghc_lib_install | |||
</pre> | |||
= Spec file when building a git snapshot = | |||
<pre> | |||
%define commit 0123456789abcdef101112131415161718191a1b | |||
%define commit_short %(echo %{commit} | head -c6) | |||
Summary: foo | |||
Name: foo | |||
Version: foo | |||
Release: 0.git%{commit_short}.1 | |||
License: foo | |||
Group: foo | |||
Url: foo | Url: foo | ||
Source0: %{ | Source0: %{name}-%{commit}.tar.gz | ||
%description | |||
foo. | |||
%files | |||
... | |||
#------------------------------------------------------------------ | |||
%prep | |||
%autosetup -p1 -n %{name}-%{commit} | |||
%build | |||
... | |||
%install | |||
... | |||
</pre> | |||
Source example for Github, Gogs, Gitea, Forgejo: | |||
Source0: https://github.com/owner/repo/archive/%{commit}.tar.gz?/%{name}-%{commit}.tar.gz | |||
Source example for Gitlab, MosHub: | |||
Source0: https://gitlab.com/owner/repo/-/archive/%{commit}/%{name}-%{commit}.tar.gz | |||
Source example for GitWeb: | |||
Source0: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/%{commit}.tar.gz | |||
Source example for GitVerse: | |||
Source0: https://gitverse.ru/api/repos/owner/repo/archive/%{commit}.tar.gz?/%{name}-%{commit}.tar.gz | |||
To update such a package: | |||
# Change Version to the latest tagged release | |||
# Change commit hash in the spec | |||
# Change the first number of the Release tag to "0" if the Version was incrimented, otherwise incriment that first number | |||
# Change the last number in the Release to 1 | |||
# Run: | |||
<pre> | |||
rm -fv .abf.yml | |||
spectool -g *.spec | |||
abf put | |||
</pre> | |||
If upstream has no tagged versions at all, use "Version: 0", example: [https://web.archive.org/web/20240703053451/https://abf.io/import/just-backup-btrfs/blob/225cac97e9/just-backup-btrfs.spec] | |||
= Spec file for a golang = | |||
<pre> | |||
%define debug_package %{nil} | |||
# use bundled golang modules (from Source1) | |||
%global gomodulesmode GO111MODULE=off | |||
# see Source0 | |||
%global goipath github.com/foo/bar | |||
Summary: foo | |||
Name: foo | |||
Version: 1.0 | |||
Release: 1 | |||
License: MIT | |||
Group: Development/Other | |||
Url: http://github.com/foo/bar | |||
Source0: http://github.com/foo/bar/archive/refs/tags/v%{version}.tar.gz?/%{name}-%{version}.tar.gz | |||
# unpack source and run 'go mod vendor' in source dir, tar.gz 'vendor' dir | |||
Source1: vendor.tar.gz | |||
BuildRequires: golang | |||
%gometa | |||
%description | %description | ||
Строка 418: | Строка 892: | ||
%files | %files | ||
%{ | %{_bindir}/%{name} | ||
#---------------------------------------------------------------------------- | #---------------------------------------------------------------------------- | ||
%prep | %prep | ||
% | %goprep | ||
# prepare vendored modules | |||
tar -xf %{SOURCE2} | |||
cp -r ./vendor/* _build/src/ | |||
%build | %build | ||
% | %gobuild -o %{gobuilddir}/bin/%{name} %{goipath}/cmd/%{name} | ||
%install | %install | ||
% | install -d %{buildroot}%{_bindir} | ||
% | install -Dm0755 %{gobuilddir}/bin/%{name} %{buildroot}%{_bindir} | ||
</pre> | |||
See also: [https://abf.io/import/rclone] | |||
[[Категория: | [[Категория:Управление пакетами]] |
Текущая версия от 15:40, 9 апреля 2025
Spec file for a program built using GNU Autotools
Summary: foo Name: foo Version: 1.0 Release: 1 License: foo Group: foo Url: foo Source0: %{name}-%{version}.tar.gz %description foo. %files -f %{name}.lang #------------------------------------------------------------------ %prep %autosetup -p1 %build %configure %make_build %install %make_install %find_lang %{name}
Spec file for a program built using CMake
Summary: foo Name: foo Version: 1.0 Release: 1 License: foo Group: foo Url: foo Source0: %{name}-%{version}.tar.gz BuildRequires: cmake %description foo. %files -f %{name}.lang #------------------------------------------------------------------ %prep %autosetup -p1 %build %cmake %make_build %install %make_install -C build %find_lang %{name}
Spec file for a program written in Qt4 and built using cmake
Summary: foo Name: foo Version: 1.0 Release: 1 License: foo Group: foo Url: foo Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: qt4-devel %description foo. %files -f %{name}.lang #------------------------------------------------------------------ %prep %autosetup -p1 %build %cmake_qt4 %make_build %install %make_install -C build %find_lang %{name} <pre> = Spec file for a program written in Qt5 and built using cmake = <pre> Summary: foo Name: foo Version: 1.0 Release: 1 License: foo Group: foo Url: foo Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: qt5-devel %description foo. %files -f %{name}.lang #------------------------------------------------------------------ %prep %autosetup -p1 %build %cmake_qt5 %make_build %install %make_install -C build %find_lang %{name} <pre> = Spec file for a program built using Meson = <pre> Summary: foo Name: foo Version: 1.0 Release: 1 License: foo Group: foo Url: foo Source0: %{name}-%{version}.tar.gz BuildRequires: meson %description foo. %files -f %{name}.lang #------------------------------------------------------------------ %prep %autosetup -p1 %build %meson %meson_build %install %meson_install %find_lang %{name} <pre> = Spec file for a program built using Perl/Makefile.PL = <pre> %define upstream_name foo %define upstream_version 1.0 Summary: foo Name: perl-%{upstream_name} Version: %perl_convert_version %{upstream_version} Release: 1 License: foo Group: foo Url: foo Source0: %{upstream_name}-%{upstream_version}.tar.gz BuildRequires: perl-devel BuildRequires: perl(ExtUtils::MakeMaker) %description foo. %files #------------------------------------------------------------------ %prep %autosetup -p1 -n %{upstream_name}-%{upstream_version} %build perl Makefile.PL INSTALLDIRS=vendor %make_build %check make test %install %make_install <pre> = Spec file for a program built using Perl/Build.PL = <pre> %define upstream_name foo %define upstream_version 1.0 Summary: foo Name: perl-%{upstream_name} Version: %perl_convert_version %{upstream_version} Release: 1 License: foo Group: foo Url: foo Source0: %{upstream_name}-%{upstream_version}.tar.gz BuildRequires: perl-devel BuildRequires: perl(Module::Build) %description foo. %files #------------------------------------------------------------------ %prep %autosetup -p1 -n %{upstream_name}-%{upstream_version} %build perl Build.PL installdirs=vendor ./Build CFLAGS="%{optflags}" %check ./Build test %install ./Build install destdir=%{buildroot}
Spec file for a Python module
Spec file to build python3 module with setup.py
python-mymodule.spec:
%define pypi_name mymodule Summary: Example module Name: python-%{pypi_name} Version: 1.0 Release: 1 License: GPL Group: Development/Python Url: http://mypage.org/mymodule Source0: %{pypi_name}-%{version}.tar.gz #if source available on pypi.org uncoment next line, and remove line Source0: above #Source0: %pypi_source BuildRequires: pkgconfig(python3) %define _description \ Text about \ example Python module %description %{_description} #------------------------------------------------------------------ %package -n python3-%{pypi_name} Summary: %{summary} Group: Development/Python %description -n python3-%{pypi_name} %{_description} %files -n python3-%{pypi_name} # for files in /usr/lib64/python3.8/site-packages %{python3_sitearch}/* %{python3_sitearch}/%{pypi_name}-%{version}-py*.egg-info # for files in /usr/lib/python3.8/site-packages uncomment next lines #%%{python3_sitelib}/* #%%{python3_sitelib}/%{pypi_name}-%{version}-py*.egg-info #------------------------------------------------------------------ %prep %autosetup -p1 %build %py3_build %install %py3_install # uncomment for fix rpmlint error "set python3 shebang" #%%py3_shebang_fix %check %pytest
Spec file to build python3 module with pyproject.toml
python-mymodule.spec:
%define pypi_name mymodule Summary: Example module Name: python-%{pypi_name} Version: 1.0 Release: 1 License: GPL Group: Development/Python Url: http://mypage.org/mymodule #if source available on pypi.org Source0: %pypi_source # if source not available on pypi.org uncomment line below and comment Source0 upper #Source0: %{pypi_name}-%{version}.tar.gz BuildRequires: pkgconfig(python3) BuildRequires: pyproject-rpm-macros # for %%check if needed BuildRequires: python3egg(pytest) %define _description \ Text about \ example Python module %description %{_description} #------------------------------------------------------------------ %package -n python3-%{pypi_name} Summary: %{summary} Group: Development/Python %description -n python3-%{pypi_name} %{_description} %files -n python3-%{pypi_name} -f %{pyproject_files} %license LICENSE %doc README* #------------------------------------------------------------------ %prep %autosetup -p1 -n %{pypi_name}-%{version} # for autoinstall BuildRequires %generate_buildrequires %pyproject_buildrequires -r %build %pyproject_wheel %install %pyproject_install %pyproject_save_files %{pypi_name} # uncomment for fix rpmlint error "set python3 shebang" #%%py3_shebang_fix %check %pytest <pre> == Spec file to build python2 module (ROSA <= 2016.1) == <pre> %define module mymodule Summary: Example module Name: python-%{module} Version: 1.0 Release: 1 License: Apache License Group: Development/Python Url: http://mypage.org/mymodule Source0: %{module}-%{version}.tar.gz BuildRequires: pkgconfig(python2) %description Example Python module. %files %doc *.txt %{python2_sitearch}/* #------------------------------------------------------------------ %prep %setup -q %apply_patches %build %py2_build %install %py2_install
Spec file to build python2 module (ROSA >= 2021.1)
python-mymodule.spec:
%define pypi_name mymodule Summary: Example module Name: python-%{pypi_name} Version: 1.0 Release: 1 License: Apache License Group: Development/Python Url: http://mypage.org/mymodule Source0: %{pypi_name}-%{version}.tar.gz #if source available on pypi.org uncoment next line, and remove line Source0: above #Source0: %pypi_source BuildRequires: pkgconfig(python2) %define _description \ Text about \ example Python module %description %{_description} #------------------------------------------------------------------ %package -n python2-%{pypi_name} Summary: %{summary} Group: Development/Python %description -n python2-%{pypi_name} %{_description} %files -n python2-%{pypi_name} %{python2_sitearch}/* #------------------------------------------------------------------ %prep %autosetup -p1 %build %py2_build %install %py2_install
Spec file for both python2 and python3 modules, ROSA >= 2021.1
python-mymodule.spec:
%define pypi_name mymodule Summary: Example module Name: python-%{pypi_name} Version: 1.0 Release: 1 License: Apache License Group: Development/Python Url: http://mypage.org/mymodule Source0: %{pypi_name}-%{version}.tar.gz #if source available on pypi.org uncoment next line, and remove line Source0: above #Source0: %pypi_source %define _description \ Text about \ example Python module %description %{_description} #------------------------------------------------------------------ %package -n python2-%{pypi_name} Summary: Example python2 module Group: Development/Python BuildRequires: pkgconfig(python2) %py2_migration_meta python-%{pypi_name} %description -n python2-%{pypi_name} %{_description} %files -n python2-%{pypi_name} %{python2_sitearch}/* #------------------------------------------------------------------ %package -n python3-%{pypi_name} Summary: Example python3 module Group: Development/Python BuildRequires: pkgconfig(python3) %description -n python3-%{pypi_name} %{_description} %files -n python3-%{pypi_name} %{python3_sitearch}/* #------------------------------------------------------------------ %prep %autosetup -p1 %build %py2_build %py3_build %install %py2_install %py3_install
See also: %py2_migration_info
Spec file for a Library
%define major 1 %define libname %mklibname %{name} %{major} %define devname %mklibname %{name} -d # Usually we don't need to build static library # But let's add it to spec template anyway %define sdevname %mklibname %{name} -d -s Summary: foo Name: foo Version: 1.0 Release: 1 License: foo Group: foo Url: foo Source0: %{name}-%{version}.tar.gz %description foo. #------------------------------------------------------------------ %package -n %{libname} Summary: %{name} shared library Group: System/Libraries %description -n %{libname} %{name} shared library. %files -n %{libname} %{_libdir}/lib%{name}.so.%{major}* #------------------------------------------------------------------ %package -n %{devname} Summary: %{name} development files Group: Development/Other Requires: %{libname} = %{EVRD} Provides: %{name}-devel = %{EVRD} %description -n %{devname} %{name} development files. %files -n %{devname} %{_includedir}/*.h %{_libdir}/*.so #------------------------------------------------------------------ %package -n %{sdevname} Summary: %{name} development files (static library) Group: Development/Other Requires: %{devname} = %{EVRD} Provides: %{name}-static-devel = %{EVRD} %description -n %{sdevname} %{name} development files (static library). %files -n %{sdevname} %{_libdir}/*.a #------------------------------------------------------------------ %prep %autosetup -p1 %build %configure %make_build %install %make_install
See also: Libraries policy
Spec file for a Node.js module
%define oname foo Summary: foo Name: nodejs-%{oname} Version: 1.0 Release: 1 License: foo Group: Development/Other Url: foo Source0: %{oname}-%{version}.tgz BuildRequires: nodejs-packaging BuildArch: noarch %description %{summary}. %files %doc LICENSE %{nodejs_sitelib}/%{oname} #------------------------------------------------------------------ %prep %autosetup -p1 -n package rm -rf node_modules %build %install mkdir -p %{buildroot}/%{nodejs_sitelib}/%{oname} cp -r package.json index.js %{buildroot}/%{nodejs_sitelib}/%{oname} %nodejs_symlink_deps
Spec file for a Ruby Gem (ROSA >= 2021.1)
%define gem_name foo Summary: Foo Name: rubygem-%{gem_name} Version: 1.0 Release: 1 Group: Development/Ruby License: GPLv2+ or Ruby URL: foo Source0: %{gem_name}-%{version}.gem BuildRequires: rubygems-devel BuildArch: noarch %description %{summary}. %files %dir %{gem_instdir} %license %{gem_instdir}/LICENSE.txt %{gem_libdir} %exclude %{gem_cache} %{gem_spec} #------------------------------------------------------------------ %package doc Summary: Documentation for %{name} Group: Books/Computer books Requires: %{name} = %{EVRD} %description doc Documents, RDoc & RI documentation for %{name}. %files doc %doc %{gem_docdir} %doc %{gem_instdir}/CHANGELOG.md %{gem_instdir}/Gemfile %doc %{gem_instdir}/README.md %doc %{gem_instdir}/SECURITY.md #------------------------------------------------------------------ %prep %autosetup -p1 -n %{gem_name}-%{version} %build %gem_build %install %gem_install mkdir -p %{buildroot}%{gem_dir} cp -a .%{gem_dir}/* \ %{buildroot}%{gem_dir}/ cp ../%{gem_name}-%{version}.gemspec %{buildroot}%{gem_dir}/specifications
Spec file for a Ruby Gem (ROSA <= 2016.1)
%define rbname foo Summary: Foo Name: rubygem-%{rbname} Version: 1.0 Release: 1 Group: Development/Ruby License: GPLv2+ or Ruby URL: foo Source0: %{rbname}-%{version}.gem BuildRequires: rubygems BuildArch: noarch %description %{summary}. %files %{ruby_gemdir}/gems/%{rbname}-%{version} %{ruby_gemdir}/specifications/%{rbname}-%{version}.gemspec #------------------------------------------------------------------ %package doc Summary: Documentation for %{name} Group: Books/Computer books Requires: %{name} = %{EVRD} %description doc Documents, RDoc & RI documentation for %{name}. %files doc %{ruby_gemdir}/doc/%{rbname}-%{version} #------------------------------------------------------------------ %prep %setup -q %apply_patches %build %gem_build %install %gem_install
Spec file for a Haskell Library
%define _disable_ld_no_undefined 1 %global debug_package %{nil} %global pkg_name Foo %global pkgver %{pkg_name}-%{version} Summary: foo Name: ghc-%{pkg_name} Version: 1.0 Release: 1 License: BSD Group: Development/Haskell Url: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkgver}/%{pkgver}.tar.gz BuildRequires: ghc-devel BuildRequires: ghc-prof BuildRequires: ghc-rpm-macros %description %{summary}. %files -f %{name}.files %license LICENSE #---------------------------------------------------------------------- %package devel Summary: %{summary} Provides: %{name}-static = %{EVRD} Provides: %{name}-static%{?_isa} = %{EVRD} %if %{defined ghc_version} Requires: ghc = %{ghc_version} %endif Requires: %{name}%{?_isa} = %{EVRD} %description devel This package provides the Haskell %{pkg_name} library development files. %files devel -f %{name}-devel.files #---------------------------------------------------------------------- %if %{with haddock} %package doc Summary: Haskell %{pkg_name} library documentation BuildArch: noarch %description doc This package provides the Haskell %{pkg_name} library documentation. %files doc -f %{name}-doc.files %license LICENSE %endif #---------------------------------------------------------------------- %if %{with ghc_prof} %package prof Summary: Haskell %{pkg_name} profiling library Requires: %{name}-devel%{?_isa} = %{EVRD} Supplements: (%{name}-devel and ghc-prof) %description prof This package provides the Haskell %{pkg_name} profiling library. %files prof -f %{name}-prof.files %endif #---------------------------------------------------------------------- %prep %autosetup -p1 -n %{pkgver} %build %ghc_lib_build %install %ghc_lib_install
Spec file when building a git snapshot
%define commit 0123456789abcdef101112131415161718191a1b %define commit_short %(echo %{commit} | head -c6) Summary: foo Name: foo Version: foo Release: 0.git%{commit_short}.1 License: foo Group: foo Url: foo Source0: %{name}-%{commit}.tar.gz %description foo. %files ... #------------------------------------------------------------------ %prep %autosetup -p1 -n %{name}-%{commit} %build ... %install ...
Source example for Github, Gogs, Gitea, Forgejo:
Source0: https://github.com/owner/repo/archive/%{commit}.tar.gz?/%{name}-%{commit}.tar.gz
Source example for Gitlab, MosHub:
Source0: https://gitlab.com/owner/repo/-/archive/%{commit}/%{name}-%{commit}.tar.gz
Source example for GitWeb:
Source0: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/%{commit}.tar.gz
Source example for GitVerse:
Source0: https://gitverse.ru/api/repos/owner/repo/archive/%{commit}.tar.gz?/%{name}-%{commit}.tar.gz
To update such a package:
- Change Version to the latest tagged release
- Change commit hash in the spec
- Change the first number of the Release tag to "0" if the Version was incrimented, otherwise incriment that first number
- Change the last number in the Release to 1
- Run:
rm -fv .abf.yml spectool -g *.spec abf put
If upstream has no tagged versions at all, use "Version: 0", example: [1]
Spec file for a golang
%define debug_package %{nil} # use bundled golang modules (from Source1) %global gomodulesmode GO111MODULE=off # see Source0 %global goipath github.com/foo/bar Summary: foo Name: foo Version: 1.0 Release: 1 License: MIT Group: Development/Other Url: http://github.com/foo/bar Source0: http://github.com/foo/bar/archive/refs/tags/v%{version}.tar.gz?/%{name}-%{version}.tar.gz # unpack source and run 'go mod vendor' in source dir, tar.gz 'vendor' dir Source1: vendor.tar.gz BuildRequires: golang %gometa %description %{summary}. %files %{_bindir}/%{name} #---------------------------------------------------------------------------- %prep %goprep # prepare vendored modules tar -xf %{SOURCE2} cp -r ./vendor/* _build/src/ %build %gobuild -o %{gobuilddir}/bin/%{name} %{goipath}/cmd/%{name} %install install -d %{buildroot}%{_bindir} install -Dm0755 %{gobuilddir}/bin/%{name} %{buildroot}%{_bindir}
See also: [2]