当源 tar 目录与名称版本不对应时使用 rpmbuild
Using rpmbuild when source tar directory doesn't correspond to name-version
我正在尝试从 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?
这是一个 simple.spec
文件,可以帮助您了解问题。源压缩包包含以下内容:
$ 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.
好的,我成功了。也许是一个 hack,但它正在工作。根据问题,我的 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,而是手动解压并重命名了 untarred 目录。
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}
只需使用 setup macro.
setup -n %{name}-%{version}.linux
我正在尝试从 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?
这是一个 simple.spec
文件,可以帮助您了解问题。源压缩包包含以下内容:
$ 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.
好的,我成功了。也许是一个 hack,但它正在工作。根据问题,我的 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,而是手动解压并重命名了 untarred 目录。
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}
只需使用 setup macro.
setup -n %{name}-%{version}.linux