/var/tmp/rpm-tmp.ajKra4 的退出状态错误 (%prep)

发布于 2025-01-05 11:37:59 字数 2059 浏览 1 评论 0原文

我遇到了一个奇怪的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦里兽 2025-01-12 11:37:59

查看 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'.

荒人说梦 2025-01-12 11:37:59

另外值得注意的是,某些 tarball 不会将自己创建为安装路径的父目录。即,我的 tarball 有树:

usr
├── bin
│   ├── check_for_incorrect_quotes
│   └── check_for_incorrect_quotes.py
└── lib
    └── python2.6
        └── site-packages
            ├── incorrectquotes
            │   ├── check_for_incorrect_quotes.py
            │   ├── check_for_incorrect_quotes.pyc
            │   ├── __init__.py
            │   ├── __init__.pyc
            │   └── test
            │       ├── __init__.py
            │       └── __init__.pyc
            └── IncorrectQuotes-0.2.0-py2.6.egg-info
                ├── dependency_links.txt
                ├── entry_points.txt
                ├── PKG-INFO
                ├── requires.txt
                ├── SOURCES.txt
                └── top_level.txt

因为这是它想要安装这些软件包的位置

要实现此功能,您只需将 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:

usr
├── bin
│   ├── check_for_incorrect_quotes
│   └── check_for_incorrect_quotes.py
└── lib
    └── python2.6
        └── site-packages
            ├── incorrectquotes
            │   ├── check_for_incorrect_quotes.py
            │   ├── check_for_incorrect_quotes.pyc
            │   ├── __init__.py
            │   ├── __init__.pyc
            │   └── test
            │       ├── __init__.py
            │       └── __init__.pyc
            └── IncorrectQuotes-0.2.0-py2.6.egg-info
                ├── dependency_links.txt
                ├── entry_points.txt
                ├── PKG-INFO
                ├── requires.txt
                ├── SOURCES.txt
                └── top_level.txt

Because this is where it wants to install these packages

To make this work, you can just change setup -n to setup -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

挥剑断情 2025-01-12 11:37:59

在 rpmbuild 文件夹中,转到 SOURCES 并按如下方式重命名源文件夹:

mypackage-1.0

然后创建 tarball:

mypackage-1.0.tar.gz

它应该可以工作。

发生的情况是,解压存档后,rpmbuild 需要一个名为 mypackage-1.0 的文件夹,而不是 mypackage 或 mypackage-something else。

尊重命名约定。检查指南

In your rpmbuild folder, go to SOURCES and rename your source folder this way:

mypackage-1.0

then create the tarball:

mypackage-1.0.tar.gz

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文