将 %cmake*(*.spec 文件)转换为 cmake3?

将 %cmake*(*.spec 文件)转换为 cmake3?

我想将现有的 *.spec 文件从 fedora 风格%cmake*命令转换为%cmake3基于备用的命令(例如Amazon Linux 2)。

我应该用什么替换现有的%cmake_build

最小可重现示例:

 % cat Dockerfile
FROM public.ecr.aws/lambda/dotnet:7
WORKDIR /tmp
RUN curl -O https://kojipkgs.fedoraproject.org//packages/dcmtk/3.6.7/3.fc39/src/dcmtk-3.6.7-3.fc39.src.rpm
RUN yum -y update && yum -y install rpm-build make gcc-c++ cmake3 libjpeg-devel \
 libpng-devel libtiff-devel libxml2-devel openssl-devel zlib-devel doxygen \
 git-core
RUN rpm -i dcmtk-3.6.7-3.fc39.src.rpm
WORKDIR /root/rpmbuild/SPECS/
RUN sed -e '/0017-Increase-sleep-for-tests.patch/ s/^#*/#/' -i dcmtk.spec
RUN sed -e 's/BuildRequires: cmake/BuildRequires: cmake3/g' -i dcmtk.spec
RUN sed -e 's/%cmake /%cmake3 /g' -i dcmtk.spec
RUN rpmbuild -ba dcmtk.spec

给出:

% docker build .
[...]
-- Build files have been written to: /root/rpmbuild/BUILD/dcmtk-3.6.7
+ %cmake_build
/var/tmp/rpm-tmp.p5JL4r: line 70: fg: no job control
error: Bad exit status from /var/tmp/rpm-tmp.p5JL4r (%build)

我在以下位置没有看到任何cmake3_build命令:

# grep build /usr/lib/rpm/macros.d/macros.cmake3

答案1

现在,我使用了以下方法,似乎效果很好:

RUN sed -e 's/%cmake_build/make %{?_smp_mflags}/g' -i dcmtk.spec
RUN sed -e 's/%cmake_install/make install DESTDIR=$RPM_BUILD_ROOT/g' -i dcmtk.spec
RUN sed -e 's/%ctest/make test/g' -i dcmtk.spec

希望这有帮助

以供参考:

相关内容