File purr-data.spec of Package purr-data

# Maintainer: <aggraef at gmail.com>

# This is Jonathan Wilkes' nw.js variant of Pd-L2Ork nick-named "Purr-Data".
# Basically, it is Pd-L2Ork with the Tk GUI replaced with a JavaScript GUI
# implemented using nw.js (http://nwjs.io/). **NOTE:** Gem's quicktime backend
# isn't included right now, as Fedora doesn't ship the required library (see
# the notes in the BuildRequires section below). Other than that, it's
# basically the same package as the one available in the Arch User
# Repositories (also maintained by yours truly). In particular, it installs
# into /opt/purr-data and renames the executable and library directories so
# that it can be installed alongside pd-l2ork.

# We use a custom install prefix here so that the package can be installed
# alongside classic pd-l2ork.
%define prefix /opt/purr-data

# Extra build options: E.g., you can change this to 'light' for a light build
# including only essential externals (which builds much faster).
%define buildopt all V=0 dpkg=disabled

# nw.js version and architecture
%define nwjs_version 0.55.0
%ifarch x86_64
%define nwjs_arch x64
%else
%define nwjs_arch ia32
%endif

# XXXFIXME: Debianism. We use that version number for convenience here since
# we actually use the Debian snapshot (.orig tarball) to build the package. Is
# there a versioning scheme for git packages in RPM land that we should use?
Name:           purr-data
Version:        2.20.0+git5326+0468b25d
Release:        1
Summary:        Interactive multimedia programming environment (nw.js variant)
Group:          Productivity/Multimedia/Other
URL:            https://agraef.github.io/purr-data/
License:        BSD-3-Clause
Source0:        %{name}_%{version}.orig.tar.gz
Source1:        nwjs-sdk-v%{nwjs_version}-linux-%{nwjs_arch}.tar.gz

BuildRequires:  gcc-c++, autoconf, automake, libtool, libtirpc-devel, pkg-config, bison, flex, gtk2-devel, gtk3-devel, ladspa-devel, pkgconfig(alsa), pkgconfig(jack), bluez-libs-devel, cairo-devel, mesa-libGL-devel, mesa-libGLU-devel, glew-devel, gsl-devel, ImageMagick-devel, libdc1394-devel, fftw3-devel, fluidsynth-devel, ftgl-devel, gsm-devel, libjpeg-devel, lua-devel, lame-devel, libraw1394-devel, speex-devel, stk-devel, libtiff-devel, libv4l-devel, libdv-devel, libiec61883-devel, libXv-devel, libXxf86vm-devel, libvorbis-devel, zlib-devel, rsync, GConf2-devel, nss-devel, libXtst-devel, libXScrnSaver-devel

# This isn't packaged by Fedora. However, you can get it from RPM Fusion
# (https://rpmfusion.org) and rebuild the package to improve Gem's video
# playback capabilities.
#BuildRequires: libquicktime-devel

# We trimmed this down a bit, since many of the originally "recommended"
# packages aren't available in Fedora. We also removed some stuff like
# xdg-utils which really doesn't belong here. Finally, all recommended
# packages are demoted to suggestions to prevent that dnf will install them
# anyway in its default configuration.
Suggests: ladspa-tap-plugins, ladspa-swh-plugins, ladspa-mcp-plugins, ladspa-cmt-plugins, ladspa-blop-plugins, ladspa-vco-plugins, ladspa-FIL-plugins
Suggests: fluid-soundfont-common, dssi

%description
This is Jonathan Wilkes' nw.js variant of Pd-L2Ork, nick-named
"Purr-Data". Basically, it is Pd-L2Ork with the Tk GUI replaced
with a JavaScript GUI implemented using nw.js (http://nwjs.io/).

Pd-L2Ork is Linux Laptop Orchestra's (L2Ork) real-time visual
programming environment for interactive multimedia. It is based
on Miller Puckette's Pure Data (Pd).

# no debug package with this build
%global debug_package %{nil}

%prep
%setup -q -b 1
# copy the nw.js sources to where purr-data wants them
rm -rf pd/nw/nw
cp -a ../nwjs-sdk-v%{nwjs_version}-linux-%{nwjs_arch} pd/nw/nw
# Make sure that the html docs in packages/gendoc are current so that we don't
# accidentally try to rebuild them.
cd packages/gendoc && touch *-Linux*.html

# Get rid of some Fedora defaults which break our build. We should really look
# into these issues some time and try to fix them, so that we can do a fully
# hardened build.
%undefine _auto_set_build_flags
# Kludge alert: If we do a full build including debug packages we also have to
# disable the id links to prevent a packaging error. Not sure how to fix this.
%if 0%{?_enable_debug_packages:1}
%define _build_id_links none
%endif

%build
make prefix=%{prefix} %{buildopt}

# XXXTODO: This is unwieldy. Maybe we should deal with at least some of our
# arcane installation requirements upstream.
%install
rm -rf $RPM_BUILD_ROOT
make install prefix=%{prefix} DESTDIR=$RPM_BUILD_ROOT
# Create a link to the executable.
mkdir -p "$RPM_BUILD_ROOT/usr/bin"
ln -sf %{prefix}/bin/pd-l2ork "$RPM_BUILD_ROOT/usr/bin/purr-data"
# Create links to the include and lib directories.
mkdir -p "$RPM_BUILD_ROOT/usr/include"
ln -sf %{prefix}/include/pd-l2ork "$RPM_BUILD_ROOT/usr/include/purr-data"
mkdir -p "$RPM_BUILD_ROOT/usr/lib"
ln -sf %{prefix}/lib/pd-l2ork "$RPM_BUILD_ROOT/usr/lib/purr-data"
# Edit bash completion file.
sed -e 's/pd-l2ork/purr-data/g' < "$RPM_BUILD_ROOT/etc/bash_completion.d/pd-l2ork" > "$RPM_BUILD_ROOT/etc/bash_completion.d/purr-data"
rm -f "$RPM_BUILD_ROOT/etc/bash_completion.d/pd-l2ork"
# For now we just remove the Emacs mode as it would conflict with the pd-l2ork
# package. This is for consistency with the other JGU builds of purr-data,
# even if we don't build classic pd-l2ork on Fedora right now.
rm -rf "$RPM_BUILD_ROOT/usr/share/emacs"
# Fedora's rpmbuild complains about the (wrong) shebang in this file, remove it.
cd "$RPM_BUILD_ROOT%{prefix}/lib/pd-l2ork/doc/manuals/StartHere/po"
rm -f generate-pot.py
# Edit the library paths in the default user.settings file so that it
# matches our install prefix.
cd "$RPM_BUILD_ROOT%{prefix}/lib/pd-l2ork"
sed -e "s!/usr/lib/pd-l2ork!%{prefix}/lib/pd-l2ork!g" -i default.settings
# Remove libtool archives and extra object files.
cd "$RPM_BUILD_ROOT%{prefix}"
rm -f lib/pd-l2ork/extra/*/*.la lib/pd-l2ork/extra/*/*.pd_linux_o
# Sanitize permissions. We try to catch the most obvious cases here, but the
# rpmbuild tools still complain about some more. XXXTODO: Look at the "xyz is
# executable but has no shebang, removing executable bit" warnings and figure
# out what causes them and what the proper resolution is.
cd "$RPM_BUILD_ROOT"
chmod -R go-w *
chmod -R a+r *
chmod a-x .%{prefix}/lib/pd-l2ork/default.settings
find .%{prefix}/lib/pd-l2ork/bin/nw -executable -not -type d -exec chmod a+x {} +
#find . -executable -name '*.pd_linux' -exec chmod a-x {} +
find . -executable -name '*.pd' -exec chmod a-x {} +
find . -executable -name '*.txt' -exec chmod a-x {} +
find . -executable -name '*.aif*' -exec chmod a-x {} +
find . -type d -exec chmod a+x {} +

%files
/etc/bash_completion.d/*
/opt/purr-data
/usr/bin/*
/usr/include/*
/usr/lib/*
/usr/share/applications/*
/usr/share/icons/*
/usr/share/mime/packages/*

%changelog
* Sat Aug 24 2019 Albert Graef <aggraef@gmail.com>
- Initial release
openSUSE Build Service is sponsored by