为什么%autosetup在提取源之前执行修补程序? [英] Why does %autosetup perform patching BEFORE extracting sources?

查看:57
本文介绍了为什么%autosetup在提取源之前执行修补程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的安排很简单-一个原始档,一个补丁:

I have a very straightforward arrangement -- one source tarball, one patch:

Source: http://...../foo-%{version}.tar.gz
Patch: my-patch-for-foo.diff
...
%prep
%autosetup -v -n bar-%{version}

但是,当我尝试在%prep 步骤中使用%autosetup 时, rpmbuild 会尝试先修补 -提取之前:

However, when I attempt to use the %autosetup in the %prep step, rpmbuild attempts to patch first -- before extracting:

/bin/cat ..../SOURCES/my-patch-for-foo.diff | 
/usr/bin/patch  
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.8PV0PY
+ umask 022
+ cd /....
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /....
+ rm -rf bar-0.12.18
+ /bin/tar -xvvf -
+ /usr/bin/gzip -dc ..../SOURCES/foo-0.12.18.tgz

由于某些原因, patch 没有报告错误-但是提取的代码最终未打补丁,并且以后我的构建失败.

For some reason, there is no error reported by patch -- but the extracted code ends up unpatched and my build fails later.

使用普通的%setup 后跟%patch0 可以正常工作,但是%autosetup 怎么了?

Using the ordinary %setup followed by %patch0 works fine, but what's wrong with %autosetup?

如果很重要,我使用的是CentOS-6.8,其中RPM的版本为4.8.0.谢谢!

I'm on CentOS-6.8, if it matters, where RPM is of version 4.8.0. Thank you!

更新,将%autosetup 拆分为%setup %autopatch 都不起作用-%autopatch 不会做任何有用的事情.因为我的补丁都是默认格式,所以我将使用重新实现的%autopatch :

Update, splitting the %autosetup into %setup and %autopatch does not work either -- %autopatch does not do anything useful. Because my patches are all in default format, I'm going to use my reimplementation of %autopatch:

%prep
%setup -n bar-%{version}
%{lua:
    for i, p in ipairs(patches) do
        print("%patch"..i)
    end
}

我真的找到了一个错误,还是我做的事情很怪异?

Have I really found a bug, or am I doing something grotesquely wrong?

推荐答案

我在CentOS 6.7上发现了相同的问题.

I observed the same issue on CentOS 6.7.

如上所述,RPM 4.8可能不支持%autosetup http://rpm.org/user_doc/autosetup.html 也从以下开始确认支持该功能4.11.

As mentioned above, RPM 4.8 supposedly doesn't support %autosetup; http://rpm.org/user_doc/autosetup.html also confirms that it's supported starting from 4.11.

但是,我发现/usr/lib/rpm/macros (从 rpm-4.8.0-55.el6.x86_64 安装)确实包含一个定义%autosetup 宏和 rpm -q --changelog rpm 显示它最近"向后移植:

However, I found that /usr/lib/rpm/macros (installed from rpm-4.8.0-55.el6.x86_64) does actually include a definition of the %autosetup macro, and rpm -q --changelog rpm shows that it was backported "recently":

* Mon Feb 08 2016 Lubos Kardos <lkardos@redhat.com> - 4.8.0-52
- Add %autosetup macros (#1265021)

显然,这种实现似乎被破坏了.

Obviously that implementation seems to be broken, though.

EPEL打包指南说,所有EPEL版本(通过epel-rpm-macros 用于EPEL5和EPEL6)"(强调我的),因此我尝试安装该软件包.安装 epel-rpm-macros-6-16.noarch (说明后用于添加EPEL YUM存储库(如果您尚未完成此操作),/etc/rpm/macros.zzz-epel-autosetup 包含了%apply_patch (由%autopatch 使用,由%autosetup 使用).解决了此问题-提取源后立即应用补丁.

The EPEL packaging guidelines says that "The %autosetup macro is available in all EPEL releases (via epel-rpm-macros for EPEL5 and EPEL6)" (emphasis mine), so I tried installing that package. After installing epel-rpm-macros-6-16.noarch (instructions for adding the EPEL YUM repository if you haven't already done this), /etc/rpm/macros.zzz-epel-autosetup contained a different definition of %apply_patch (which is used by %autopatch, which is used by %autosetup). This fixed the issue - patches are now applied after the sources are extracted.

这篇关于为什么%autosetup在提取源之前执行修补程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆