File entropypianotuner.spec of Package entropypianotuner

Summary:        Entropy Piano Tuner
Name:           entropypianotuner
Version:        1.2.0
Release:        1%{?dist}
License:        GPL-3.0
Group:          Applications/Productivity
URL:            http://www.piano-tuner.org

# Source from gitlab
# Change the hash according to the current master branch
# Workaround for source containing a '?' (commend at end)
%global BRANCH  v1.2.0
%global ARCHIVE archive.tar.gz?ref=%BRANCH
%global OWNER tp3
%global PROJECT Entropy-Piano-Tuner
Source:         https://gitlab.com/%OWNER/%PROJECT/repository/%ARCHIVE #/archive.tar.gz
%if 0%{?fedora}
BuildRequires:  fdupes, qt5-qtbase-devel, qt5-qtmultimedia-devel, qt5-qtmidi-devel, fftw3-devel, desktop-file-utils, alsa-lib-devel, libuv-devel
Requires:       qt5-qtbase, qt5-qtmultimedia, fftw3, alsa-lib, libuv
%endif
%if 0%{?fedora} >= 22
BuildRequires:  qwt-qt5-devel
Requires:       qwt-qt5
%endif
%if 0%{?fedora} < 22
BuildRequires:  qwt6-qt5-devel
Requires:       qwt6-qt5
%endif

%if 0%{?suse_version}
# qwt does not exist yet for qt5 on suse in stable repos
BuildRequires:  fdupes, libatomic1, libqt5-qtbase-devel, libqt5-qtmultimedia-devel, libQt5Midi-devel, qwt6-qt5-devel, fftw-devel, update-desktop-files, alsa-devel
Requires:       fftw3, alsa
%endif
%if 0%{?suse_version} > 1320
BuildRequires:  libuv-devel
%endif
%if 0%{?suse_version} == 1315
BuildRequires:  libuv-devel
%endif

%description
This is a program for tuning your piano.

%prep
# standard setup, but rename the dir in the archive, because it contains its commit hash!
cd $RPM_BUILD_DIR
rm -rf %{PROJECT}
gzip -dc  $RPM_SOURCE_DIR/archive.tar.gz | tar -xf -
if [ $? -ne 0 ]; then
  exit $?
fi

# remove commit number and move files to build dir
find . -depth -type d -name '%{PROJECT}-%{BRANCH}*' -exec mv {} %{PROJECT} \;
cd %{PROJECT}
ls -A | xargs -I {} mv {} $RPM_BUILD_DIR/{}

cd $RPM_BUILD_DIR
chmod -Rf a+rX,u+w,g-w,o-w .

# create desktop entry file
%{__cat} <<EOF >%{name}.desktop
[Desktop Entry]
Name=Entropy Piano Tuner
Comment=Tune your piano
Exec=entropypianotuner %f
Icon=entropypianotuner
Terminal=false
Type=Application
MimeType=application/ept;
Categories=Education;Music;
EOF

%build
qmake-qt5 -r \
	"EPT_INSTALL_BIN_RDIR=%{_bindir}" \
   	"EPT_INSTALL_DATA_RDIR=%{_datadir}" \
    "EPT_INSTALL_LIB_RDIR=%{_libdir}"
    
make %{?_smp_mflags}


%install

# install files declared in qmake
make INSTALL_ROOT=%{buildroot} install

# install desktop file
%{__install} -d -m0755 %{buildroot}%{_datadir}/applications/
desktop-file-install \
    --delete-original                          \
    --dir %{buildroot}%{_datadir}/applications \
    %{name}.desktop
    
    
# remove unused library files
%{__rm} %{buildroot}%{_libdir}/%{name}/libcore.so


%post
%if 0%{?suse_version} >= 1140
%desktop_database_post
%endif

%postun
%if 0%{?suse_version} >= 1140
%desktop_database_postun
%endif

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root, 0755)
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/128x128
%dir %{_datadir}/icons/hicolor/128x128/mimetypes
%dir %{_libdir}/%{name}

%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/%{name}.png
%{_datadir}/icons/hicolor/128x128/mimetypes/application-ept.png
%{_datadir}/mime/packages/%{name}-mime.xml

%dir %{_libdir}/%{name}
%dir %{_libdir}/%{name}/algorithms

%{_libdir}/%{name}/lib*
%{_libdir}/%{name}/algorithms/*.so


%changelog
* Fri Nov 11 2016 Christoph Wick <info@entropy-tuner.org> - 1.1.7-0
- Updates

* Fri Jun 12 2015 Christoph Wick <info@entropy-tuner.org> - 1.0.4-0
- Initial package.