Sisyphus repository
Last update: 8 february 2023 | SRPMs: 18184 | Visits: 26684350
en ru br
ALT Linux repos
5.0: 4.26-alt2
4.1: 4.20-alt5
4.0: 4.20-alt5
3.0: 4.13-alt1

Other repositories

Group :: File tools
RPM: file

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

# SPDX-License-Identifier: GPL-2.0-only
%define _unpackaged_files_terminate_build 1
%define _stripped_files_terminate_build 1
%set_verify_elf_method strict

Name: file
Version: 5.44
Release: alt1

Summary: File type guesser
License: BSD-2-Clause
Group: File tools
# Sources archive:

Source: %name-%version.tar

BuildRequires: bzlib-devel
BuildRequires: libcap-devel
BuildRequires: liblzma-devel
BuildRequires: libseccomp-devel
BuildRequires: libzstd-devel
BuildRequires: zlib-devel
BuildRequires: lzip
BuildRequires: ncompress
BuildRequires: strace

The file command is "a file type guesser", that is, a command-line tool that
tells you in words what kind of data a file contains. Unlike most GUI systems,
command-line UNIX systems - with this program leading the charge - don't rely
on filename extentions to tell you the type of a file, but look at the file's
actual contents. This is, of course, more reliable, but requires a bit of I/O.

%package -n libmagic
Summary: Shared library for handling magic files
Group: System/Libraries

%description -n libmagic
This package contains shared library for handling magic files.

%package -n libmagic-devel
Summary: Development files to build applications that handle magic files
Group: Development/C
Requires: libmagic = %EVR

%description -n libmagic-devel
This package contains development files to build applications that handle
magic files.


sed -i '/rm -fr magic/d' magic/

%configure \
--enable-fsect-man5 \
--disable-rpath \

mkdir -p %buildroot%_sysconfdir
cat <<EOF > %buildroot%_sysconfdir/magic
# Magic local data for file(1) command.
# Insert here your local magic data. Format is described in magic(5).

cat magic/magic/* > %buildroot%_datadir/file/magic

xz -k ChangeLog

set -o pipefail
strace_file() {
local ret=0
strace -nfo strace.log -- src/file "$ at " > stdout.log || ret=$?
! grep -w -e ENOSYS strace.log >&2 || ret=$?
# Check seccomp was enabled.
grep -q 'prctl(PR_SET_NO_NEW_PRIVS, 1,.* = 0' strace.log
grep -q 'seccomp(SECCOMP_SET_MODE_FILTER,.* = 0' strace.log
# Check capabilities are dropping.
grep -q 'capset(.*{effective=0, permitted=0, inheritable=0}.* = 0' strace.log
# Print output to stderr for debugging.
cat stdout.log >&2
# Finally, print to stdout for grep.
cat stdout.log
return $ret
strace_file -m /dev/null  ChangeLog.xz | grep ': data'
strace_file -m magic/magic/  ChangeLog.xz | grep ': XZ compressed data'
strace_file -m magic/magic.mgc  ChangeLog.xz | grep ': XZ compressed data'
strace_file -m magic/magic.mgc -z ChangeLog.xz | grep ': ASCII text (XZ compressed data'
# Zstd is built-in.
tar cf ChangeLog.tar.zst ChangeLog.xz --zstd
strace_file -m magic/magic.mgc -z ChangeLog.tar.zst | grep ': POSIX tar archive (GNU) (Zstandard compressed data'
# lzip uses external helper.
lzip -k ChangeLog
strace_file -m magic/magic.mgc    ChangeLog.lz | grep ': lzip compressed data'
strace_file -m magic/magic.mgc -z ChangeLog.lz | grep ': ASCII text (lzip compressed data'
%ifnarch armh
# compress does not work on armh:
# Z uses external helper (gzip).
compress ChangeLog
strace_file -m magic/magic.mgc    ChangeLog.Z  | grep ': compress.d data'
strace_file -m magic/magic.mgc -z ChangeLog.Z  | grep ': ASCII text (compress.d data'

make check

%doc COPYING ChangeLog.xz
%config(noreplace) %_sysconfdir/magic

%files -n libmagic

%files -n libmagic-devel


Full changelog you can see here

design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin