【问题标题】:Using rpmbuild when source tar directory doesn't correspond to name-version当源 tar 目录与 name-version 不对应时使用 rpmbuild
【发布时间】:2019-02-16 06:09:35
【问题描述】:

我正在尝试从 source-1.4.3-linux.tgz 构建一个 rpm(已下载,因此我不控制名称)并将文件解压缩到目录 source-1.4.3-linux 中。在我的 source.spec 文件中,我有

Name: source
Version: 1.4.3 

所以我得到一个错误可能是很合乎逻辑的:

cd: source-1.4.3: No such file or directory.  

我尝试将 -linux 添加到版本中,但 rpmbuild 只想要一个数字。我该怎么做才能告诉 rpmbuild 源文件解压缩到 source-1.4.3-linux 中?

【问题讨论】:

  • 你能展示更多你的规范文件的内容吗?可能您需要更改 %prep 部分。 rpmbuild 输出应该告诉您错误发生在哪个部分
  • 谢谢。这让我走上了正轨。我在 %prep 中找到了我必须做的事情。将在下面发布答案。

标签: rpmbuild rpm-spec


【解决方案1】:

只需使用setup macro

setup -n %{name}-%{version}.linux

【讨论】:

【解决方案2】:

这是一个simple.spec 文件,可以帮助您理解问题。源 tarball 包含以下内容:

$ tar tzf simple-0.tar.gz 
simple-0/
simple-0/simple.txt

规格文件:

Summary: Simple SPEC
Name: simple
Version: 0
Release: 1
License: NONE
Group: NONE
URL: NONE
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root


%description
" This is Simple "

%prep
%setup -q

%build

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/tmp/
install -m 0644 simple.txt %{buildroot}/tmp/simple.txt

%clean
rm -rf $RPM_BUILD_ROOT

%post
echo "In the Post section of Simple"

%files
%defattr(-,root,root,-)
%doc
/tmp/simple.txt


%changelog
* Wed Sep 12 2018  <iamauser@localdomain> - 
- Initial build.

【讨论】:

  • 根据问题,文件名/内容是 $ tar tzf simple-0-linux-blah.tar.gz simple-0-linux-blah/simple-0/simple.txt 这个非常规的命名是我要问的问题。
【解决方案3】:

好的,我得到了这个工作。也许是一个黑客,但它正在工作。根据问题,我的 tarball 命名非常规。

$ tar tzf source-1.4.3-linux-amd64.tar.gz 
source-1.4.3-linux-amd64/
source-1.4.3-linux-amd64/simple.txt

在 specfile %prep 部分中,我没有使用 %setup 或 %autosetup,而是手动解压并重命名解压目录。

Name:       source
Version:    1.4.3
Release:    0
Source0:    https://example.com/%{name}-%{version}-linux-amd64.tar.bz2

%prep
rm -fr %{name}-%{version}
tar -xjf %{SOURCE0}
mv %{name}-%{version}-linux-amd64 %{name}-%{version}

【讨论】:

  • 当您可以按照我的回答中指出的那样做正确的事情时,这会使事情变得困难 3 倍。
猜你喜欢
  • 1970-01-01
  • 2014-01-17
  • 1970-01-01
  • 2022-01-08
  • 2019-05-22
  • 1970-01-01
  • 2014-07-20
  • 2019-10-31
  • 2015-08-19
相关资源
最近更新 更多