File diskdev_cmds.spec of Package diskdev_cmds

#
# spec file for package diskdev_cmds
#
# Copyright (c) 2013-2020 Malcolm J Lewis <malcolmlewis@opensuse.org>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

Name:           diskdev_cmds
Version:        540.1.linux3
Release:        0
License:        APSL-2.0
Summary:        Apple HFS+ filesystems tools
URL:            http://www.opensource.apple.com/
Group:          System/Filesystems
Source0:        http://cavan.codon.org.uk/~mjg59/diskdev_cmds/diskdev_cmds-540.1.linux3.tar.gz
Source1:        http://www.opensource.org/licenses/apsl-2.0.txt
#PATCH-FIX-OPENSUSE diskdev_cmds-remove-deprecated-header.patch malcolmlewis@opensuse.org -- Remove deprecated glibc sysctl.h header.
Patch0:         diskdev_cmds-remove-deprecated-header.patch
BuildRequires:  llvm-clang
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(uuid)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
This package provides tools to create and check HFS+ filesystems under Linux.

%prep
%autosetup -p1
cp %{S:1} .

%build
export CFLAGS="%{optflags}"
export LINUX="1"
make %{?_smp_mflags} -f Makefile

%install
mkdir -p %{buildroot}/%{_sbindir}
cp newfs_hfs.tproj/newfs_hfs %{buildroot}/%{_sbindir}/mkfs.hfsplus
cp fsck_hfs.tproj/fsck_hfs %{buildroot}/%{_sbindir}/fsck.hfsplus

# man pages -- a mildly non-invasive name change is in order
mkdir -p %{buildroot}/%{_mandir}/man8
cat fsck_hfs.tproj/fsck_hfs.8 | sed -e 's/[F|f]sck_hfs/fsck.hfsplus/g' \
    > %{buildroot}/%{_mandir}/man8/fsck.hfsplus.8
cat newfs_hfs.tproj/newfs_hfs.8 | sed -e 's/[N|n]ewfs_hfs/mkfs.hfsplus/g' \
    > %{buildroot}/%{_mandir}/man8/mkfs.hfsplus.8

# and a utility symlink...
cd %{buildroot}/%{_sbindir}
ln -s fsck.hfsplus fsck.hfs
cd %{buildroot}/%{_mandir}/man8
ln -s fsck.hfsplus.8 fsck.hfs.8

%post
if ! grep -e '^hfsplus$' /etc/filesystems >/dev/null 2>&1 ; then
    sed -i 's/*/hfsplus\n*/g' /etc/filesystems
    echo "Added 'hfsplus' to the file /etc/filesystems"
fi

%postun
if [ "$1" == "0" ]; then
    sed -i -e '/^hfsplus$/d' /etc/filesystems
    echo "Deleted 'hfsplus' from the file /etc/filesystems"
fi

%files
%license apsl-2.0.txt
%{_sbindir}/mkfs.hfsplus
%{_sbindir}/fsck.hfsplus
%{_sbindir}/fsck.hfs
%{_mandir}/man8/mkfs.hfsplus.8%{?ext_man}
%{_mandir}/man8/fsck.hfsplus.8%{?ext_man}
%{_mandir}/man8/fsck.hfs.8%{?ext_man}

%changelog
openSUSE Build Service is sponsored by