File nutty.spec of Package nutty

#
# spec file for package nutty
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 https://bugs.opensuse.org/
#


Name:           nutty
Version:        1.1.1
Release:        0
Summary:        A Network Information Utility
License:        GPL-3.0-or-later
Group:          Productivity/Networking/Diagnostic
URL:            https://babluboy.github.io/nutty
Source:         https://github.com/babluboy/nutty/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source99:       nutty.rpmlintrc
BuildRequires:  fdupes
BuildRequires:  libxml2-tools
BuildRequires:  meson
BuildRequires:  pkgconfig
BuildRequires:  update-desktop-files
BuildRequires:  vala
BuildRequires:  pkgconfig(gee-0.8)
BuildRequires:  pkgconfig(granite) >= 0.5
BuildRequires:  pkgconfig(gtk+-3.0) >= 3.5.9
BuildRequires:  pkgconfig(libnotify)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(polkit-agent-1)
BuildRequires:  pkgconfig(sqlite3)
Requires:       curl
Requires:       iproute2
Requires:       libnotify-tools
Requires:       lshw
Requires:       net-tools
Requires:       nethogs
Requires:       nmap
Requires:       pciutils
Requires:       sudo
Requires:       traceroute
Requires:       vnstat
Requires:       wireless-tools
Recommends:     %{name}-lang

%description
Nutty provides an intuitive user interface for some commonly used network
related command line tools.

%lang_package

%prep
%setup -q

# Add full path to commands: iwconfig lspci lshw traceroute
sed -i 's|\(\biwconfig\b\)|%{_sbindir}/\1|' $(grep -rwl iwconfig)
sed -i 's|\(\biwlist\b\)|%{_sbindir}/\1|' $(grep -rwl iwlist)
sed -i 's|\(\blspci\b\)|/sbin/\1|' $(grep -rwl lspci)
sed -i 's|\(\blshw\b\)|%{_sbindir}/\1|' $(grep -rwl 'lshw' {data,src/nutty.vala})
sed -i 's|\(\btraceroute\b\)|%{_sbindir}/\1|' $(grep -rwl 'traceroute' {data,src/nutty.vala})

%build
%meson
%meson_build

%install
%meson_install
%suse_update_desktop_file -r com.github.babluboy.nutty GTK Network Monitor
%find_lang com.github.babluboy.nutty %{name}.lang
%fdupes %{buildroot}/%{_datadir}

chmod 0644 %{buildroot}%{_datadir}/polkit-1/actions/org.freedesktop.policykit.nutty.policy

# Fix: env-script-interpreter
pushd %{buildroot}
for _file in $(grep -rl '^\#\!\/'); do
    find -name ${_file##*/} -type f -not -perm /111 -exec sed '/^\#\!\//d' -i {} \;
    find -name ${_file##*/} -type f -perm /111 -exec sed '/^\#\!\/.\+py/s/env\ \+//' -i {} \;
    find -name ${_file##*/} -type f -perm /111 -exec sed '/^\#\!\/.\+sh/c\#\!/bin/bash' -i {} \;
done
popd

# dirlist HiDPI icons (see: hicolor/index.theme)
touch $PWD/dir.lst
_dirlist=$PWD/dir.lst
pushd %{buildroot}
find ./ | while read _list; do
    echo $_list | grep '[0-9]\@[0-9]' || continue
    _path=$(echo $_list | sed 's/[^/]//')
    if ! ls ${_path%/*}; then
        grep -xqs "\%dir\ ${_path%/*}" $_dirlist || echo "%dir ${_path%/*}" >> $_dirlist
    fi
done
popd

%files -f dir.lst
%license COPYING
%doc AUTHORS README.md
%{_bindir}/com.github.babluboy.nutty
%{_datadir}/applications/com.github.babluboy.nutty.desktop
%{_datadir}/glib-2.0/schemas/com.github.babluboy.nutty.gschema.xml
%{_datadir}/icons/hicolor/*/apps/com.github.babluboy.nutty.??g
%{_datadir}/polkit-1/actions/org.freedesktop.policykit.nutty.policy
%{_datadir}/metainfo/com.github.babluboy.nutty.appdata.xml
%{_datadir}/com.github.babluboy.nutty/

%files lang -f %{name}.lang

%changelog
openSUSE Build Service is sponsored by