Name:              cdrkit
Version:           1.1.11
Release:           50
Summary:           A collection of CD/DVD utilities
License:           GPLv2
URL:               http://cdrkit.org/
Source0:           http://cdrkit.org/releases/cdrkit-%{version}.tar.gz

Provides:          dirsplit = %{version}-%{release} wodim = %{version}-%{release}
Obsoletes:         dirsplit < %{version}-%{release} wodim < %{version}-%{release}
Obsoletes:	   cdrkit-help < %{version}-%{release}

Patch1:            cdrkit-1.1.8-werror.patch
Patch2:            cdrkit-1.1.9-efi-boot.patch
Patch4:            cdrkit-1.1.9-no_mp3.patch
Patch5:            cdrkit-1.1.9-buffer_overflow.patch
Patch6:            cdrkit-1.1.10-build-fix.patch
Patch7:            cdrkit-1.1.11-manpagefix.patch
Patch8:            cdrkit-1.1.11-rootstat.patch
Patch9:            cdrkit-1.1.11-usalinst.patch
Patch10:           cdrkit-1.1.11-readsegfault.patch
Patch11:           cdrkit-1.1.11-format.patch
Patch12:           cdrkit-1.1.11-handler.patch
Patch13:           cdrkit-1.1.11-dvdman.patch
Patch14:           cdrkit-1.1.11-paranoiacdda.patch
Patch15:           cdrkit-1.1.11-utf8.patch
Patch16:           cdrkit-1.1.11-cmakewarn.patch
Patch17:           cdrkit-1.1.11-memset.patch
Patch19:           cdrkit-1.1.11-ppc64le_elfheader.patch
Patch20:           cdrkit-1.1.11-werror_gcc5.patch
Patch21:           cdrkit-1.1.11-devname.patch
Patch22:           cdrkit-1.1.11-sysmacros.patch
Patch23:           cdrkit-1.1.11-gcc10.patch
%ifarch sw_64
Patch24:           cdrkit-1.1.11-sw.patch
%endif

BuildRequires:     gcc cmake libcap-devel zlib-devel perl-interpreter 
BuildRequires:     perl-generators file-devel bzip2-devel 

Requires:          perl-interpreter >= 4:5.8.1 genisoimage = %{version}-%{release} 
Requires:          libusal = %{version}-%{release} 
Requires(preun):   %{_sbindir}/alternatives coreutils
Requires(post):    %{_sbindir}/alternatives coreutils

%description
A collection of CD/DVD utilities

%package        -n genisoimage
Summary:           genisoimage packages for cdrkit
Requires:          libusal = %{version}-%{release}
Requires(preun):   %{_sbindir}/alternatives coreutils
Requires(post):    %{_sbindir}/alternatives coreutils
Obsoletes:	   cdrkit-help < %{version}-%{release}

%description    -n genisoimage
Genisoimage packages for cdrkit

%package        -n libusal
Summary:           Libarary package for cdrkit

%description    -n libusal
Libarary package for cdrkit

%package        -n icedax
Summary:           icedax for cdrkit
BuildRequires:     cdparanoia-devel
Requires:          libusal = %{version}-%{release} vorbis-tools cdparanoia
Requires(preun):   %{_sbindir}/alternatives coreutils
Requires(post):    %{_sbindir}/alternatives coreutils
Obsoletes:	   cdrkit-help < %{version}-%{release}

%description    -n icedax
Icedax for cdrkit

%package           devel
Summary:           header files for cdrkit
Requires:          libusal = %{version}-%{release}
Provides:          libusal-devel
Obsoletes:         libusal-devel

%description       devel
Header files for cdrkit.

%prep
%autosetup -n %{name}-%{version} -p1

%build
mkdir build
cd build
export CFLAGS="$RPM_OPT_FLAGS -Wno-error=format-security -fno-strict-aliasing"
export CXXFLAGS="$CFLAGS"
export FFLAGS="$CFLAGS"
%cmake CMAKE_VERBOSE=1 -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} -DBUILD_SHARED_LIBS:BOOL=ON ..
%make_build VERBOSE=1

%install
cd build
%make_install
perl -pi -e 's#^require v5.8.1;##g' %{buildroot}%{_bindir}/dirsplit
ln -s genisoimage %{buildroot}%{_bindir}/mkisofs
ln -s genisoimage %{buildroot}%{_bindir}/mkhybrid
ln -s icedax %{buildroot}%{_bindir}/cdda2wav
ln -s wodim %{buildroot}%{_bindir}/cdrecord
ln -s wodim %{buildroot}%{_bindir}/dvdrecord

cd  ..
rm -rf build

ln -sf wodim.1.gz %{buildroot}/%{_mandir}/man1/netscsid.1.gz

%post
link=`readlink %{_bindir}/cdrecord`
if [ "$link" == "%{_bindir}/wodim" ]; then
	rm -f %{_bindir}/cdrecord
fi
link=`readlink %{_bindir}/dvdrecord`
if [ "$link" == "wodim" ]; then
	rm -f %{_bindir}/dvdrecord
fi

%{_sbindir}/alternatives --install %{_bindir}/cdrecord cdrecord \
		%{_bindir}/wodim 50 \
	--slave %{_mandir}/man1/cdrecord.1.gz cdrecord-cdrecordman \
		%{_mandir}/man1/wodim.1.gz \
	--slave %{_bindir}/dvdrecord cdrecord-dvdrecord %{_bindir}/wodim \
	--slave %{_mandir}/man1/dvdrecord.1.gz cdrecord-dvdrecordman \
		%{_mandir}/man1/wodim.1.gz \
	--slave %{_bindir}/readcd cdrecord-readcd %{_bindir}/readom \
	--slave %{_mandir}/man1/readcd.1.gz cdrecord-readcdman \
		%{_mandir}/man1/readom.1.gz

%preun
if [ $1 = 0 ]; then
	%{_sbindir}/alternatives --remove cdrecord %{_bindir}/wodim
fi

%post           -n genisoimage
link=`readlink %{_bindir}/mkisofs`
if [ "$link" == "genisoimage" ]; then
	rm -f %{_bindir}/mkisofs
fi

%{_sbindir}/alternatives --install %{_bindir}/mkisofs mkisofs \
		%{_bindir}/genisoimage 50 \
	--slave %{_mandir}/man1/mkisofs.1.gz mkisofs-mkisofsman \
		%{_mandir}/man1/genisoimage.1.gz \
	--slave %{_bindir}/mkhybrid mkisofs-mkhybrid %{_bindir}/genisoimage \
	--slave %{_mandir}/man1/mkhybrid.1.gz mkisofs-mkhybridman \
		%{_mandir}/man1/genisoimage.1.gz

%preun          -n genisoimage
if [ $1 = 0 ]; then
	%{_sbindir}/alternatives --remove mkisofs %{_bindir}/genisoimage
fi

%post           -n icedax
link=`readlink %{_bindir}/cdda2wav`
if [ "$link" == "icedax" ]; then
	rm -f %{_bindir}/cdda2wav
fi
%{_sbindir}/alternatives --install %{_bindir}/cdda2wav cdda2wav \
		%{_bindir}/icedax 50 \
	--slave %{_mandir}/man1/cdda2wav.1.gz cdda2wav-cdda2wavman \
		%{_mandir}/man1/icedax.1.gz 

%preun          -n icedax
if [ $1 = 0 ]; then
	%{_sbindir}/alternatives --remove cdda2wav %{_bindir}/icedax
fi

%ldconfig_scriptlets libusal

%files 
%defattr(-,root,root)
%license COPYING
%{_sbindir}/netscsid
%{_bindir}/devdump
%{_bindir}/wodim
%{_bindir}/readom
%{_bindir}/dirsplit
%exclude %{_bindir}/cdda2mp3
%ghost %{_bindir}/cdrecord
%ghost %{_bindir}/dvdrecord
%{_mandir}/man1/devdump.*
%{_mandir}/man1/wodim.*
%{_mandir}/man1/netscsid.*
%{_mandir}/man1/readom.*
%{_mandir}/man1/dirsplit.*

%files          -n genisoimage
%defattr(-,root,root)
%license COPYING
%{_bindir}/iso*
%{_bindir}/readmult
%{_bindir}/pitchplay
%{_bindir}/genisoimage
%ghost %{_bindir}/mkisofs
%ghost %{_bindir}/mkhybrid
%{_mandir}/man5/genisoimagerc.*
%{_mandir}/man1/genisoimage.*
%{_mandir}/man1/isodebug.*
%{_mandir}/man1/isodump.*
%{_mandir}/man1/isoinfo.*
%{_mandir}/man1/isovfy.*
%{_mandir}/man1/pitchplay.*
%{_mandir}/man1/readmult.*

%files          -n libusal
%defattr(-,root,root)
%license COPYING
%{_libdir}/lib*.so.*

%files          -n icedax
%defattr(-,root,root)
%license COPYING
%{_bindir}/icedax
%{_bindir}/cdda2ogg
%ghost %{_bindir}/cdda2wav
%{_mandir}/man1/icedax.*
%{_mandir}/man1/cdda2ogg.*
%{_mandir}/man1/list_audio_tracks.*

%files             devel
%defattr(-,root,root)
%license COPYING
%{_libdir}/*.so
%{_includedir}/usal

%changelog
* Mon Oct 30 2023 yueyuankun<yueyuankun@kylinos.cn> - 1.1.11-50
- Type:update
- ID:NA
- SUG:NA
- DESC:delete Requires git

* Wed Nov 23 2022 wangkerong<wangkerong@h-partners.com> - 1.1.11-49
- fix spell error

* Wed Nov 16 2022 wangkerong<wangkerong@h-partners.com> - 1.1.11-48
- fix empty link

* Thu Nov 3 2022 wuzx<wuzx1226@qq.com> - 1.1.11-47
- add sw64 patch

* Tue Oct 25 2022 wangkerong <wangkerong@h-partners.com> - 1.1.11-46
- rebuild for next release

* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 1.1.11-45
- DESC: delete -S git from %autosetup, and delete BuildRequires git

* Fri Jul 30 2021 liuyumeng <liuyumeng5@huawei.com> - 1.1.11-44
- fix build fail on gcc-10

* Fri Sep 20 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.1.11-43
- Package init
