Reduce libmagic-data package size
[platform/upstream/file.git] / packaging / file.spec
1 %global         _miscdir    %{_datadir}/misc
2
3 Name:           file
4 BuildRequires:  findutils
5 BuildRequires:  libtool
6 BuildRequires:  zlib-devel
7 Url:            http://www.darwinsys.com/file/
8 Version:        5.31
9 Release:        0
10 Summary:        A Tool to Determine File Types
11 License:        BSD-2.0
12 Group:          System/Utilities
13
14 ### SOURCES BEGIN ###
15 Source2:        baselibs.conf
16 Source1001:     file.manifest
17 ### SOURCES END ###
18 Source:         ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz
19
20 %description
21 With the file command, you can obtain information on the file type of a
22 specified file. File type recognition is controlled by the file
23 /etc/magic, which contains the classification criteria. This command is
24 used by apsfilter to permit automatic printing of different file types.
25
26 %package -n libmagic-data-full
27 Summary:        The magic files for libmagic to use
28 Group:          System/Libraries
29 Provides:               libmagic-data
30
31 %description -n libmagic-data-full
32 This package contains the basic magic files that libmagic reads and uses
33 to estimate a file's type.
34
35 %package -n libmagic-data-mini
36 Summary:        The magic files for libmagic to use
37 Group:          System/Libraries
38 Provides:               libmagic-data
39
40 %description -n libmagic-data-mini
41 This package contains the basic magic files that libmagic reads and uses
42 to estimate a file's type.
43
44 %package -n libmagic
45 Summary:        Library with file's functionality
46 Group:          System/Libraries
47 Requires:       libmagic-data = %{version}
48 Recommends:             libmagic-data-full
49 Provides:       libfile
50 Obsoletes:      libfile =< 5.04
51
52 %description -n libmagic
53 This library reads magic files and detects file types. Used by file command
54
55 %package -n file-devel
56 Summary:        Include Files and Libraries mandatory for Development
57 Group:          System/Libraries
58 Provides:       file:/usr/include/magic.h
59 Requires:       glibc-devel
60 Requires:       libmagic = %{version}
61
62 %description -n file-devel
63 This package contains all necessary include files and libraries needed
64 to develop applications that require the magic "file" interface.
65
66 %prep
67 %setup -q -n file-%{version}
68 ### PREP BEGIN ###
69 cp %{SOURCE1001} .
70 ### PREP END ###
71
72 %build
73 ### BUILD BEGIN ###
74 export LANG=POSIX
75 export LC_ALL=POSIX
76 rm -f Magdir/*,v Magdir/*~
77 rm -f ltcf-c.sh ltconfig ltmain.sh
78 autoreconf -fiv
79 CFLAGS="$RPM_OPT_FLAGS -DHOWMANY=69632"
80 %configure --disable-silent-rules --datadir=%{_miscdir} --disable-static --with-pic --enable-fsect-man5
81 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
82 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
83
84 %{__make} %{?_smp_mflags} pkgdatadir='$(datadir)'
85 %if 0%{?build_python_bindings:1}
86 pushd python
87 python setup.py build
88 popd
89 %endif
90 ### BUILD END ###
91
92 %install
93 export LANG=POSIX
94 export LC_ALL=POSIX
95 mkdir  %{buildroot}%{_sysconfdir}
96 make DESTDIR=%{buildroot} install pkgdatadir='$(datadir)'
97 rm -vf %{buildroot}%{_sysconfdir}/magic
98 echo '# Localstuff: file(1) magic(5) for locally observed files' > %{buildroot}%{_sysconfdir}/magic
99 echo '#     global magic file is %{_miscdir}/magic(.mgc)'   >> %{buildroot}%{_sysconfdir}/magic
100 %{nil install -s dcore %{buildroot}%{_bindir}}
101 # Check out that the binary does not bail out:
102 ln -sf %{buildroot}%{_miscdir}/magic_full.mgc %{buildroot}%{_miscdir}/magic.mgc
103 LD_LIBRARY_PATH=%{buildroot}%{_libdir}
104 export LD_LIBRARY_PATH
105 %{buildroot}%{_bindir}/file --version
106 find %{buildroot}%{_bindir}/file %{_bindir}/ /%{_lib}/ %{_libdir}/ | \
107     xargs %{buildroot}%{_bindir}/file -m %{buildroot}%{_miscdir}/magic.mgc
108 unset LD_LIBRARY_PATH
109 %{__rm} -f %{buildroot}%{_libdir}/*.la
110 %{__rm} -f %{buildroot}%{_miscdir}/magic.mgc
111
112 %remove_docs
113
114 %post -n libmagic -p /sbin/ldconfig
115
116 %post -n libmagic-data-full
117 ln -sf %{_miscdir}/magic_full.mgc %{_miscdir}/magic.mgc
118
119 %post -n libmagic-data-mini
120 ln -sf %{_miscdir}/magic_mini.mgc %{_miscdir}/magic.mgc
121
122 %postun -n libmagic -p /sbin/ldconfig
123
124 %files -n libmagic
125 %manifest %{name}.manifest
126 %defattr (644,root,root,755)
127 %license COPYING
128 %config(noreplace) %{_sysconfdir}/magic
129 %{_libdir}/lib*.so.*
130
131 %files -n libmagic-data-full
132 %manifest %{name}.manifest
133 %defattr (644,root,root,755)
134 %license COPYING
135 %{_miscdir}/magic_full.mgc
136
137 %files -n libmagic-data-mini
138 %manifest %{name}.manifest
139 %defattr (644,root,root,755)
140 %license COPYING
141 %{_miscdir}/magic_mini.mgc
142
143 %files
144 %manifest %{name}.manifest
145 %defattr (644,root,root,755)
146 %{nil %{_bindir}/dcore}
147 %attr(755,root,root) %{_bindir}/file
148 %license COPYING
149
150 %files -n file-devel
151 %manifest %{name}.manifest
152 %defattr (644,root,root,755)
153 %{_libdir}/lib*.so
154 %{_includedir}/magic.h
155 %license COPYING