Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

rpm: Lack of magic files #22930

Closed
t3hk0d3 opened this issue Sep 29, 2013 · 29 comments
Closed

rpm: Lack of magic files #22930

t3hk0d3 opened this issue Sep 29, 2013 · 29 comments

Comments

@t3hk0d3
Copy link

t3hk0d3 commented Sep 29, 2013

error: magic_load(ms, /usr/local/Cellar/rpm/5.4.11/share/file/magic) failed: could not find any valid magic files!
Assertion failed: (mg != NULL), function rpmfcClassify, file rpmfc.c, line 1276.

Install log: https://gist.github.com/t3hk0d3/6756947

RPM version is lastest available in brew ATM.

@t3hk0d3
Copy link
Author

t3hk0d3 commented Sep 29, 2013

Required file named "rpm.magic" and located in source archive root.

@jacknagel
Copy link
Contributor

What command do I need to run to see this error message?

@jacknagel
Copy link
Contributor

I can't even compile rpm because it seems to want to build universal binaries but its library dependencies are not universal on my system.

Looking at configure, it seems that some incantation of "--with-path-magic" would fix this, but I don't know exactly what.

@t3hk0d3
Copy link
Author

t3hk0d3 commented Sep 30, 2013

@jacknagel
rpmbuild, but you have to make dummy rpm spec file before. It's a bit complicated, at least for me.

@adamv
Copy link
Contributor

adamv commented Sep 30, 2013

@t3hk0d3 Please provide a complete repro case; if additional files are needed, please gist them, etc.

@t3hk0d3
Copy link
Author

t3hk0d3 commented Sep 30, 2013

@adamv Its quite difficult task, because you have to literally recreate all workspace required for RPM package creation.

I'll try my best to create mock for bug reproduction, but it will require some time.

@adamv
Copy link
Contributor

adamv commented Oct 1, 2013

If you can't give us a minimal set of repro instructions, how will we know what change fixes the problem?

@t3hk0d3
Copy link
Author

t3hk0d3 commented Oct 1, 2013

@adamv
Minimal test case is existance of /usr/local/Cellar/rpm/5.4.11/share/file/magic file.

@afb
Copy link
Contributor

afb commented Oct 2, 2013

It defaults to the bundled/internal version of file, had missed to configure the magic path properly. There's some examples in devtool.conf in CVS, but I will provide a proper (oneline) patch. Reproducer is to add an actual file to the sample package, I seem to forget this when testing.

@t3hk0d3
Copy link
Author

t3hk0d3 commented Oct 3, 2013

@afb
You should not confuse that file with libmagic's file. They even have different format.

Here is contents of my /usr/local/Cellar/rpm/5.4.11/share/file/magic
https://gist.github.com/t3hk0d3/6810274

When i tried to put libmagic's file, i've got load of format errors.

@afb
Copy link
Contributor

afb commented Oct 3, 2013

The important part is that the magic file matches the libmagic in use... That is, if using the internal "file" then the installed version and if using external "file" then the version from the file formula...

@t3hk0d3
Copy link
Author

t3hk0d3 commented Oct 3, 2013

@afb
Okay, i get it. There is different format for bundled magic file.

@afb
Copy link
Contributor

afb commented Oct 4, 2013

Test spec https://gist.github.com/afb/6821217

@t3hk0d3
Copy link
Author

t3hk0d3 commented Oct 16, 2013

bump

@jacknagel
Copy link
Contributor

Pulled the fix.

@t3hk0d3
Copy link
Author

t3hk0d3 commented Oct 19, 2013

@jacknagel
Thank you.

@thedotedge
Copy link

I can still reproduce the problem with latest rpm:

~ ❯❯❯ brew upgrade rpm          
Error: rpm-5.4.11 already installed
~ ❯❯❯ brew upgrade libmagic                                         
Error: libmagic-5.15 already installed
Processing files: orchestration-1.0.0-1.noarch
/bin/bash: --rpm-requires: invalid option
Usage:  /bin/bash [GNU long option] [option] ...
    /bin/bash [GNU long option] [option] script-file ...
GNU long options:
    --debug
    --debugger
    --dump-po-strings
    --dump-strings
    --help
    --init-file
    --login
    --noediting
    --noprofile
    --norc
    --posix
    --protected
    --rcfile
    --restricted
    --verbose
    --version
    --wordexp
Shell options:
    -irsD or -c command or -O shopt_option      (invocation only)
    -abefhkmnptuvxBCHP or -o option
error: magic_load(ms, /usr/local/Cellar/rpm/5.4.11/share/misc/magic) failed: no magic files loaded
Assertion failed: (mg != NULL), function rpmfcClassify, file rpmfc.c, line 1276.
[1]    11739 abort      rpmbuild -bb --buildroot

@bcolyn
Copy link

bcolyn commented Oct 24, 2013

Latest version seems to want the file as
/usr/local/Cellar/rpm/5.4.11/share/misc/magic instead of
/usr/local/Cellar/rpm/5.4.11/share/file/magic

brew upgrade libmagic
Error: libmagic-5.15 already installed

@nefilim
Copy link

nefilim commented Dec 12, 2014

I'm still running into this issue with a fresh brew installation. I'm not familiar with the details here but this looks like a problem:

==> Downloading http://rpm5.org/files/rpm/rpm-5.4/rpm-5.4.14-0.20131024.src.rpm
rpm-5.4.14.tar.gz
27361 blocks
==> ./configure --prefix=/usr/local/Cellar/rpm/5.4.14 --localstatedir=/usr/local/var --with-path-cfg=/usr/local/etc/rpm --with-path-magic=/usr/local/share/misc/magic --with-extra-path-macros=/usr/local/Cellar/rpm/5.4.14/lib/rpm/macros.*
==> make
[peter@nefilim s]$ ls -l /usr/local/share/misc
lrwxr-xr-x  1 peter  admin  34 Dec 12 14:29 /usr/local/share/misc -> ../Cellar/libmagic/5.20/share/misc
[peter@nefilim s]$ ls -l /usr/local/share/misc/
total 5752
-rw-r--r--  1 peter  admin  2944752 Oct 19 11:45 magic.mgc

Earlier in this issue someone mentioned that it requires the text format magic file? It looks like the one installed by lib magic is in a binary format.

I'm not really sure how this relates to bash on OSX not supporting the --rpm-requires option like it does on RHEL variants?

[peter@nefilim s]$ brew info rpm
rpm: stable 5.4.14
http://www.rpm5.org/
/usr/local/Cellar/rpm/5.4.14 (186 files, 11M) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/rpm.rb
==> Dependencies
Build: rpm2cpio ✔
Required: berkeley-db ✔, libmagic ✔, popt ✔, beecrypt ✔, libtasn1 ✔, neon ✔, gettext ✔, xz ✔, ossp-uuid ✔, pcre ✔
[peter@nefilim s]$ brew info libmagic
libmagic: stable 5.20 (bottled)
http://www.darwinsys.com/file/
/usr/local/Cellar/libmagic/5.20 (15 files, 3.0M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/libmagic.rb

@nefilim
Copy link

nefilim commented Dec 13, 2014

@afb am I missing something or doing something wrong here?

@fiorix
Copy link
Contributor

fiorix commented Apr 18, 2015

Having the same problem here.

@MikeMcQuaid
Copy link
Member

Can someone provide a simple, reproducible test case here and open a new issue with it?

@fiorix
Copy link
Contributor

fiorix commented Apr 19, 2015

It's super easy actually. All you need is a spec file that has a %pre, %preun, %post or %postun section. From what I could understand, rpmbuild saves the contents of those sections in a shell script, and uses bash --rpm-requires to calculate the dependencies. Because our bash doesn't have that option, you get this "invalid option" error but usually it continues and builds the rpm.

@fiorix
Copy link
Contributor

fiorix commented Apr 19, 2015

Got one very simple that triggers the error. Use this spec file:

Summary: Shows bash error on homebrew
Name: fail-me
Version: 1.0
Release: 1
License: Free
Group: Utilities
#Source: %{name}-%{version}.tar.gz
BuildRoot: %{_topdir}/BUILD/%{name}-%{version}-%{release}

%description
Running rpmbuild with this spec causes OS X's bash to emit an error message.

%prep

%install
touch %{buildroot}/foobar

%files
/foobar

#%post
#echo hello world

And run this in any directory:

mkdir -p top/BUILD root
rpmbuild --target amd64-redhat-linux --define "_topdir `pwd`/top" --buildroot `pwd`/root -bb spec

If you uncomment the %post part and run again, you get the error:

/bin/bash: --rpm-requires: invalid option

@afb
Copy link
Contributor

afb commented Apr 19, 2015

The bash --rpm-requires doesn't have anything to do with libmagic.
We already discussed and addressed the issue in #35062 (8fb1062)

@fiorix
Copy link
Contributor

fiorix commented Apr 19, 2015

Yeah I realized that this is not the right issue to post it on.

@afb
Copy link
Contributor

afb commented Apr 19, 2015

@MikeMcQuaid: it used to have a "rpmbuild" test, but it got rebased away sometime (probably around the same time that my formula got renamed from rpm5 to rpm or so)...
It also seems that the "prefix" macro is shot, so all packages you build will install into the rpm Cellar rather than into the HOMEBREW_PREFIX (that you want it it to)?

Test spec was at dc583fc, if anyone cares to revive it.

@nefilim
Copy link

nefilim commented Apr 19, 2015

@MikeMcQuaid i provided a simple reproducible case in the linked issue last year:

#35062

@afb
Copy link
Contributor

afb commented Apr 25, 2015

New version added as #39054, with a test in 6bec1e0

@Homebrew Homebrew locked and limited conversation to collaborators Feb 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants