【发布时间】:2021-12-05 14:58:30
【问题描述】:
我有一个具有以下结构的 GitLab 存储库:
clearshare (repo name)
|---clearshare (yes this is a repeat name)
| |---bin
| | |---clearsia
| |---app.py
| |---base.py
| |---cli.py
| |---more_files
|---clearshared.service
|---clearshare.spec
|---logging.conf
|---requirements.txt
|---setup.py
我正在尝试并未能为此设置一个规范文件来构建一个我到目前为止可以使用的 rpm:
Name: clearshare
Version: 0.0.1
Release: 1%{?dist}
License: Proprietary
Summary: my clearshare program
BuildRoot: %{_builddir}/%{name}
BuildArch: x86_64
Source1: clearshare
Source2: logging.conf
Source3: requirements.txt
Source4: setup.py
Source5: %{name}d.service
Requires: rh-python38
%prep
[ -d %{buildroot} ] && rm -rf %{buildroot}
%install
%define _VENV /var/clearos/envs/%{name}/lib/python3.8/site-packages
mkdir -p -m 755 %{buildroot}%{_VENV}/%{name}
cp -r %{SOURCE1} %{buildroot}%{_VENV}/%{name}
install %{SOURCE2} %{buildroot}%{_VENV}/%{name}/logging.conf
install %{SOURCE3} %{buildroot}%{_VENV}/%{name}/requirements.txt
install %{SOURCE4} %{buildroot}%{_VENV}/%{name}/setup.py
install -D %{SOURCE5} %{buildroot}/usr/lib/systemd/system/%{name}d.service
# Exit install without trying to compile the python code
exit 0
%files
%defattr(-,root,root,-)
%{_VENV}/%{name}/%{name}
%{_VENV}/%{name}/logging.conf
%{_VENV}/%{name}/requirements.txt
%{_VENV}/%{name}/setup.py
%{_unitdir}/%{name}d.service
还有更多内容,但我认为暂时不重要。我可以在没有指定任何源的情况下在本地构建 rpm,但是 src.rpm 失败并带有一组要打包的空文件。如果我指定 Source1-5,我会得到一个 src.rpm,其中包含文件 Source2-5 和文件夹 Source1,但文件夹 Source1 是空的。如何让 src.rpm 递归地打包 clearshare 子文件夹下的所有文件和文件夹而不单独命名它们?如果有帮助,clearshare/ 下的所有内容都是 pyhon,除了 bin 文件夹是二进制文件。
有一些限制,因为我最终使用的构建系统在构建阶段无法获取文件,因此使用带有链接和 sha265sum 的 sources.download 文件。创建sources.download时,我不知道sha256sum,因为一旦我知道它并将其放入文件中,它就会改变,所以我需要避免这种情况。
如何在不指定所有较低级别文件的情况下将子文件夹内容拉入 src.rpm?我不介意我是否只需要单独指定 clearshare/bin/clearsia 文件。
【问题讨论】:
-
sources.download和 SHA 不是您提供的代码的一部分,因此很难理解它们是如何使用的,因此请尝试在这一点上提供帮助。 -
sources.download 将包含类似以下内容:
9d5adf74e8b439cff0ee26fe4619dcf30588665a13d4208b85a7dc6d62989782 clearshare.tar.gz https://gitlab.com/clearos/clearfoundation/clearshare/-/archive/9c9925aa3d6723dcc264abae81055b6e9f4059a5/clearshare-9c9925aa3d6723dcc264abae81055b6e9f4059a5.tar.gz但使用它会使我陷入先有鸡还是先有蛋的境地。只有当我创建另一个包来构建这个包时,它才能真正使用。我可能不得不走那条路。