Blob Blame History Raw
%bcond_without tests

%global forgeurl https://github.com/monocasual/%{name}/

%global rtaudio_forgeurl https://github.com/monocasual/rtaudio/
# Version for the bundled rtaudio fork
%global rtaudio_version 5.1.0
# Commit hash for the bundled rtaudio fork, included as a git submodule:
%global rtaudio_commit eca619244a6c045efc7f30473040d4f27aa96a6e
%global rtaudio_shortcommit %(echo %{rtaudio_commit} | cut -b -8)

Name:           giada
Version:        0.18.0.1
%forgemeta
Release:        %autorelease
Summary:        Your hardcore loop machine

# LICENSING NOTE:
#
# The upstream source, when downloaded from the main website (i.e.,
# %%{url}/data/%%{name}-%%{version}-src.tar.gz), contains excerpts from the
# Steinberg VST 3 SDK, which has additional restrictions on top of the GPLv3
# that make it unsuitable for distribution in Fedora. See
# https://lists.fedoraproject.org/archives/list/legal@lists.fedoraproject.org/message/FMFIZU22AP36J3DOUVCXUPHQ3MNDN5P6/.
#
# These problematic components may be filtered from the upstream source archive
# using a script to produce a distributable source archive. At once point this
# package followed that approach. Now we use the GitHub release tarball; since
# the problematic components (vst3sdk and juce) are git submodules, they are
# not included in the automatically-generated release tarball. Two other git
# submodules—json and geompp—are unbundled downstream. The final git submodule,
# a giada-specific rtaudio fork, must be provided as an additional source.
#
# Note that this means Giada will *not* be built with VST3 support in Fedora.
# (The situation for VST2 is even worse, as it is available only under a
# proprietary license.)

# The entire source is GPLv3+, except:
#   - src/deps/rtaudio (i.e., the contents of Source1) is MIT, except:
#     * src/deps/rtaudio/include/soundcard.h is BSD
License:        GPLv3+ and MIT and BSD
URL:            https://www.giadamusic.com
Source0:        %{forgesource}
Source1:        %{rtaudio_forgeurl}/archive/%{rtaudio_commit}/rtaudio-%{rtaudio_shortcommit}.tar.gz
# https://github.com/monocasual/rtaudio/tree/eca619244a6c045efc7f30473040d4f27aa96a6e
# https://github.com/monocasual/giada/pull/358
Source2:        https://raw.githubusercontent.com/monocasual/giada/ff1ba651301a2419d6a2b7680ea8432f8e440a74/extras/com.giadamusic.Giada.desktop
# https://github.com/monocasual/giada/pull/358
Source3:        https://raw.githubusercontent.com/monocasual/giada/ff1ba651301a2419d6a2b7680ea8432f8e440a74/extras/com.giadamusic.Giada.appdata.xml

# This is a C++ logging wrapper that passes its format string parameter through
# to std::fprintf, which inherently means the format string cannot be a
# literal. We use GCC pragmas to suppress the warning in just this one spot.
# See https://github.com/monocasual/giada/issues/447, where this is discussed,
# and the patch is offered, upstream.
Patch0:         %{name}-0.17.2-suppress-format-security.patch

BuildRequires:  desktop-file-utils
# For AppData file validation
BuildRequires:  libappstream-glib

BuildRequires:  gcc-c++
BuildRequires:  cmake
# It is our choice whether to use the make backend or the ninja backend.
BuildRequires:  ninja-build

BuildRequires:  pkgconfig(rtmidi)

BuildRequires:  cmake(FLTK)

BuildRequires:  pkgconfig(sndfile)
BuildRequires:  pkgconfig(samplerate)

BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xcursor)
BuildRequires:  pkgconfig(xfixes)
BuildRequires:  pkgconfig(xft)
BuildRequires:  pkgconfig(xinerama)
BuildRequires:  pkgconfig(xpm)
BuildRequires:  pkgconfig(xrandr)
BuildRequires:  pkgconfig(xrender)

BuildRequires:  pkgconfig(alsa)
BuildRequires:  pkgconfig(libpulse)
BuildRequires:  pkgconfig(libpulse-simple)
BuildRequires:  pkgconfig(fontconfig)
BuildRequires:  pkgconfig(jack)
BuildRequires:  pkgconfig(freetype2)

BuildRequires:  pkgconfig(nlohmann_json)
# https://bugzilla.redhat.com/show_bug.cgi?id=1944047
%if 0%{?fedora} != 33 && 0%{?fedora} != 34
BuildRequires:  json-static
%endif
BuildRequires:  geompp-devel
BuildRequires:  geompp-static

%if %{with tests}
BuildRequires:  cmake(Catch2)
# Support graphical tests in non-graphical environment
BuildRequires:  xorg-x11-server-Xvfb
%endif

# For /usr/share/icons/hicolor/*/apps
Requires:  hicolor-icon-theme

# ============================================================================
# RtAudio (https://github.com/thestk/rtaudio)
#
# This version is slightly forked, so it is not possible to build with the
# system copy of RtAudio. See
# https://giadamusic.com/forum/viewtopic.php?f=2&t=177, where upstream
# discusses the decision to maintain a forked copy of RtAudio in the Giada
# source tree.
#
# The version comes from “#define RTAUDIO_VERSION” in
# src/deps/rtaudio/RtAudio.h.
Provides:  bundled(rtaudio) = %{rtaudio_version}
# ============================================================================

%description
Giada is an open source, minimalistic and hardcore music production tool.
Designed for DJs, live performers and electronic musicians.


%prep
%autosetup -p1

%setup -q -T -D -b 1 -n %{name}-%{version}
rm -rvf src/deps/rtaudio
cp -rp ../rtaudio-%{rtaudio_commit} src/deps/rtaudio

# This is a last safeguard against something with an inappropriate license
# slipping into the source tarball. It is no substitute for manual auditing.
echo 'Checking for inappropriate source files:'
echo '> Possible Steinberg proprietary license?'
if grep -Frl 'This Software Development Kit may not be' .
then
  echo 'Found some concerning files!'
  exit 1
else
  echo '> No concerning files were found.'
fi
echo '> Possible Steinberg VST 3 SDK (GPLv3 with conditions)?'
if grep -Erli 'Project[[:blank:]]*:[[:blank:]]*VST SDK' .
then
  echo 'Found some concerning files!'
  exit 1
else
  echo '> No concerning files were found.'
fi

# At least on Fedora, this keeps CMake from expecting the static FLTK library.
# It is not clear whether this is an FLTK bug (upstream or Fedora), or a Giada
# bug, so we have not attempted to report it to any upstream.
sed -r -i 's/(FLTK)[[:blank:]]+CONFIG/\1/' CMakeLists.txt

# Unbundle json/“JSON for Modern C++”/nlohmann_json.
rm -rvf 'src/deps/json'
find 'src' -type f -exec grep -E -l 'deps/json' '{}' '+' |
  xargs sed -r -i 's|deps/json/single_include/||g'

# Unbundle geompp; we can just use a symlink since it is a header-only library.
rm -rvf 'src/deps/geompp'
mkdir 'src/deps/geompp'
ln -s '%{_includedir}/geompp' 'src/deps/geompp/src'


%build
# Make sure any build flags for unbundled libraries are set. For
# json/nlohmann_json, we expect that none are needed in practice.
%set_build_flags
export CFLAGS="${CFLAGS} $(pkgconf --cflags nlohmann_json)"
export CXXFLAGS="${CXXFLAGS} $(pkgconf --cflags nlohmann_json)"
export LDFLAGS="${CXXFLAGS} $(pkgconf --libs nlohmann_json)"

# VST 2 SDK is only available under a proprietary license, and VST 3 SDK is
# dual-licensed with a proprietary license and GPLv3, but additional
# trademark-related conditions are imposed that are not acceptable in Fedora.
# See the notes near the beginning of this spec file. Therefore the VST 3 SDK
# and JUCE sources have been excluded, and all VST support must be disabled at
# build time.
%cmake \
    -DWITH_VST2:BOOL=OFF -DWITH_VST3:BOOL=OFF \
    -DWITH_TESTS:BOOL=%{?with_tests:ON}%{?!with_tests:OFF} \
    -GNinja
%cmake_build


%install 
%cmake_install
# https://github.com/monocasual/giada/pull/358
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE2}
# https://github.com/monocasual/giada/pull/358
install -m 0644 -p -D -t %{buildroot}%{_metainfodir} %{SOURCE3}
install -m 0644 -p -D -t %{buildroot}%{_datadir}/icons/hicolor/128x128/apps \
    extras/%{name}-logo.png


%check
# Verify the bundled rtaudio version in the spec file matches the header in the
# source tree.
[ '"%{rtaudio_version}"' = "$(
  awk '$1 == "#define" && $2 == "RTAUDIO_VERSION" { print $3; exit }' \
      src/deps/rtaudio/RtAudio.h)" ]
# This comment fixes broken vim syntax highlighting --> "

# Validate the installed AppData file. Fedora guidelines require validate-relax
# to pass (but not validate-strict), and do require validation at build time.
appstream-util validate-relax --nonet \
    %{buildroot}%{_metainfodir}/com.giadamusic.Giada.appdata.xml

%if %{with tests}
xvfb-run -a %{buildroot}%{_bindir}/giada --run-tests
%endif


%files
%license COPYING
%doc ChangeLog README.md

%{_bindir}/%{name}

# https://github.com/monocasual/giada/pull/358
%{_metainfodir}/com.giadamusic.Giada.appdata.xml
# https://github.com/monocasual/giada/pull/358
%{_datadir}/applications/com.giadamusic.Giada.desktop
# https://github.com/monocasual/giada/pull/358
%{_datadir}/icons/hicolor/128x128/apps/%{name}-logo.png


%changelog
%autochangelog