Bad exit status from /var/tmp/rpm-tmp.ajKra4 (%prep)
Asked Answered
R

3

10

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
Rollandrollaway answered 14/2, 2012 at 20:0 Comment(0)
O
8

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

Omen answered 15/2, 2012 at 13:45 Comment(3)
Awesome, thank you pwan.. this fixed it by adding a prefix (directory for the files). Greatly appreciate itRollandrollaway
sorry I cannot totally understand what Can I do to fix it?Gavrilla
Take your hero-01.tar.gz file and decompress it in some temp directory with a command like 'tar -zxvf hero-01.tar.gz'. It'll make a new directory that includes all the files. Use that directory name as the argument to the '-n' flag for the %setup macro.Omen
G
3

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

Grunion answered 18/10, 2018 at 21:41 Comment(0)
T
2

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

Trinidad answered 13/2, 2014 at 16:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.