/var/tmp/rpm-tmp.ajKra4 的退出状态错误 (%prep)
我遇到了一个奇怪的 RPM 问题,我是新手,所以请耐心等待...我创建了规范文件,当我运行进行构建时,出现错误:
/var/tmp/rpm-tmp.ajKra4:第 36 行:cd:hero-01:没有这样的文件或目录 错误: /var/tmp/rpm-tmp.ajKra4 (%prep) 的退出状态错误
然后我检查该临时文件,它正在尝试 CD 到不存在的目录。是否应该在规范文件中创建此文件?如果是的话在哪里?
这是我的规格文件:
Summary: Install Hero
Name: hero
Version: 01
Release: 1
Group: Billing reporting
Source: %{name}-%{version}.tar.gz
License: SLA
%description
Hero billing reports system
%prep
rm -rf %{_topdir}/BUILD/*
%setup
%install
mkdir -p /opt/%{name}
cp -r * /opt/%{name}
%post
find /opt/%{name} -type d -exec chmod 755 {} \;
find /opt/%{name} -type f -exec chmod 644 {} \;
chmod -R 755 /opt/%{name}/bin
%files
/opt/%{name}
%defattr(-,root,root,0755)
%clean
rm -rf $RPM_BUILD_ROOT
%postun
rm -rf /opt/%{name}
也许我遗漏了一些东西?不会是第一个哈哈,谢谢
这也是 tmp 文件输出的内容:
#!/bin/sh
RPM_SOURCE_DIR="/root/rpmbuild/SOURCES"
RPM_BUILD_DIR="/root/rpmbuild/BUILD"
RPM_OPT_FLAGS="-O2 -g"
RPM_ARCH="x86_64"
RPM_OS="linux"
export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
RPM_DOC_DIR="/usr/share/doc"
export RPM_DOC_DIR
RPM_PACKAGE_NAME="hero"
RPM_PACKAGE_VERSION="01"
RPM_PACKAGE_RELEASE="1"
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
LANG=C
export LANG
unset CDPATH DISPLAY ||:
RPM_BUILD_ROOT="/root/rpmbuild/BUILDROOT/hero-01-1.x86_64"
export RPM_BUILD_ROOT
PKG_CONFIG_PATH="/usr/lib64/pkgconfig:/usr/share/pkgconfig"
export PKG_CONFIG_PATH
set -x
umask 022
cd "/root/rpmbuild/BUILD"
rm -rf /root/rpmbuild/BUILD/*
cd '/root/rpmbuild/BUILD'
rm -rf 'hero-01'
/usr/bin/gzip -dc '/root/rpmbuild/SOURCES/hero-01.tar.gz' | /bin/tar -xvvf -
STATUS=$?
if [ $STATUS -ne 0 ]; then
exit $STATUS
fi
cd 'hero-01'
/bin/chmod -Rf a+rX,u+w,g-w,o-w .
exit 0
I am having a weird RPM issue, I am new to it so bear with me... I have the spec file created and when I run to do the build I get an error:
/var/tmp/rpm-tmp.ajKra4: line 36: cd: hero-01: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.ajKra4 (%prep)
Then I check that temp file and it is trying to CD to a directory that does not exist.. Should it be creating this in the spec file? if so where?
Here is my spec file:
Summary: Install Hero
Name: hero
Version: 01
Release: 1
Group: Billing reporting
Source: %{name}-%{version}.tar.gz
License: SLA
%description
Hero billing reports system
%prep
rm -rf %{_topdir}/BUILD/*
%setup
%install
mkdir -p /opt/%{name}
cp -r * /opt/%{name}
%post
find /opt/%{name} -type d -exec chmod 755 {} \;
find /opt/%{name} -type f -exec chmod 644 {} \;
chmod -R 755 /opt/%{name}/bin
%files
/opt/%{name}
%defattr(-,root,root,0755)
%clean
rm -rf $RPM_BUILD_ROOT
%postun
rm -rf /opt/%{name}
Perhaps I am missing something? Would not be the first lol, thanks
Here is also what that tmp file is outputting:
#!/bin/sh
RPM_SOURCE_DIR="/root/rpmbuild/SOURCES"
RPM_BUILD_DIR="/root/rpmbuild/BUILD"
RPM_OPT_FLAGS="-O2 -g"
RPM_ARCH="x86_64"
RPM_OS="linux"
export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
RPM_DOC_DIR="/usr/share/doc"
export RPM_DOC_DIR
RPM_PACKAGE_NAME="hero"
RPM_PACKAGE_VERSION="01"
RPM_PACKAGE_RELEASE="1"
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
LANG=C
export LANG
unset CDPATH DISPLAY ||:
RPM_BUILD_ROOT="/root/rpmbuild/BUILDROOT/hero-01-1.x86_64"
export RPM_BUILD_ROOT
PKG_CONFIG_PATH="/usr/lib64/pkgconfig:/usr/share/pkgconfig"
export PKG_CONFIG_PATH
set -x
umask 022
cd "/root/rpmbuild/BUILD"
rm -rf /root/rpmbuild/BUILD/*
cd '/root/rpmbuild/BUILD'
rm -rf 'hero-01'
/usr/bin/gzip -dc '/root/rpmbuild/SOURCES/hero-01.tar.gz' | /bin/tar -xvvf -
STATUS=$?
if [ $STATUS -ne 0 ]; then
exit $STATUS
fi
cd 'hero-01'
/bin/chmod -Rf a+rX,u+w,g-w,o-w .
exit 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 http://www.rpm.org/max-rpm/s1-rpm- inside-macros.html,特别是“-n — 设置构建目录名称”部分。
%setup 宏期望解压 tar.gz 后,将有一个 Hero-01 目录可用,但您的 Hero-01.tar.gz 可能会创建一些其他目录名称,可能是名称中不包含版本的目录。
因此,例如,如果解压后 /root/rpmbuild/BUILD 中有一个“hero”目录而不是“hero-01”目录,则更新规范文件以使用“%setup -n Hero”而不仅仅是“ %设置'。
Check out http://www.rpm.org/max-rpm/s1-rpm-inside-macros.html, specifically the "-n — Set Name of Build Directory" section.
The %setup macro is expecting that after untaring the tar.gz, there will be a hero-01 directory available, but your hero-01.tar.gz probably creates some other directory name, probably one without the version included in the name.
So, for example, if there's a 'hero' directory instead of a 'hero-01' directory in /root/rpmbuild/BUILD after the untarring, then update the spec file to use '%setup -n hero' instead of just '%setup'.
另外值得注意的是,某些 tarball 不会将自己创建为安装路径的父目录。即,我的 tarball 有树:
因为这是它想要安装这些软件包的位置
要实现此功能,您只需将
setup -n
更改为setup -c
即可在解压之前创建并移动到该目录(您需要 ctrl+f对于“创建目录(并更改为它)”)TL;DR:
setup -n
->setup -c
可能有帮助Also noteworthy is that some tarballs will not create themselves as a parent directory to the install paths. I.e., my tarball has the tree:
Because this is where it wants to install these packages
To make this work, you can just change
setup -n
tosetup -c
to create and move to that directory before untarring (You'll want to ctrl+f for "create directory (and change to it)")TL;DR:
setup -n
->setup -c
might help在 rpmbuild 文件夹中,转到
SOURCES
并按如下方式重命名源文件夹:然后创建 tarball:
它应该可以工作。
发生的情况是,解压存档后,rpmbuild 需要一个名为 mypackage-1.0 的文件夹,而不是 mypackage 或 mypackage-something else。
尊重命名约定。检查指南
In your rpmbuild folder, go to
SOURCES
and rename your source folder this way:then create the tarball:
And it should work.
What happens is that after untarring the archive, rpmbuild expects a folder named mypackage-1.0 and not mypackage or mypackage-something else.
Respect naming conventions. Check Guidelines