6.4.4. Python 程序示例的 spec 文件示例
查看以下为使用 Python 编程语言编写的示例程序的 spec 文件示例文件(pello)。
在 spec 文件中内联创建包装程序脚本的示例表明 spec 文件本身是可以写成脚本的。此打包程序脚本使用 此文档 来执行 Python 字节编译代码。
例 6.4. pello 程序的 spec 文件示例
Name: pello
Version: 0.1.1
Release: 1%{?dist}
Summary: Hello World example implemented in Python
License: GPLv3+
URL: https://www.example.com/%{name}
Source0: https://www.example.com/%{name}/releases/%{name}-%{version}.tar.gz
BuildRequires: python
Requires: python
Requires: bash
BuildArch: noarch
%description
The long-tail description for our Hello World Example implemented in Python.
%prep
%setup -q
%build
python -m compileall %{name}.py
%install
mkdir -p %{buildroot}/%{_bindir}
mkdir -p %{buildroot}/usr/lib/%{name}
cat > %{buildroot}/%{_bindir}/%{name} <<EOF
#!/bin/bash
/usr/bin/python /usr/lib/%{name}/%{name}.pyc
EOF
chmod 0755 %{buildroot}/%{_bindir}/%{name}
install -m 0644 %{name}.py* %{buildroot}/usr/lib/%{name}/
%files
%license LICENSE
%dir /usr/lib/%{name}/
%{_bindir}/%{name}
/usr/lib/%{name}/%{name}.py*
%changelog
* Tue May 31 2016 Adam Miller <maxamillion@fedoraproject.org> - 0.1.1-1
- First pello package
Requires指令指定软件包的运行时依赖项,其中包括两个软件包:-
在运行时执行字节编译的代码所需的
python软件包。 -
执行小入口点脚本所需的
bash软件包。
-
在运行时执行字节编译的代码所需的
-
BuildRequires指令指定软件包的 build-time 依赖项,它只包括python软件包。pello程序需要python来执行字节编译构建过程。 -
%build部分指定如何构建软件,创建脚本的字节编译版本。请注意,在实际打包中,它通常会根据所使用的发行版自动完成。 -
%install部分对应于这样的事实,即您必须将字节文件安装到系统上的库目录中,以便可以访问它。