File qos.spec of Package qos

#
# spec file for package qos
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright 2013 Archie L. Cobbs.
#
# 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 http://bugs.opensuse.org/
#


#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
  %define _fillupdir %{_fillupdir}
%endif

%define initdir     %{_sysconfdir}/init.d
%define netconfdir  %{_sysconfdir}/sysconfig/network
%define modprobe    /sbin/modprobe
%define tcutil      %{_sbindir}/tc
%define iputil      /bin/ip

Name:           qos
Version:        1.0.1
Release:        0
BuildArch:      noarch
Summary:        Simple traffic shaping utility for fighting bufferbloat
#Source0:            https://github.com/archiecobbs/qos/archive/1.0.1.tar.gz
License:        Apache-2.0
Group:          System/Management
Source0:        %{name}-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Url:            https://github.com/archiecobbs/qos
Requires:       iproute2
Requires(pre):      insserv-compat
Requires(post):     %fillup_prereq

%description
The Problem: Bufferbloat (see http://en.wikipedia.org/wiki/Bufferbloat)

    - Your SSH session turns to molasses when your kid watches YouTube
    - Your wife complains that "the internet is slow"
    - You hate the stupid DSL modems supplied by the phone company
      with their giant packet queues that add unnecessary latency
    - You have your own Linux router that routes all your traffic
      or is the only machine you have connected to the Internet
      and know there must be a better way

The Solution: QoS

    QoS = "Quality of Service"

    You probably already know about it. Control and proritize traffic.

    This QoS is new and improved. Previous QoS setups only throttled
    traffic in the download direction. This one handles both directions
    using the (poorly documented) Linux ifb interface and tc(8) 'mirred'
    redirection.

%prep
%setup

%build
subst()
{
    sed -r \
        -e 's|@qosconfig@|%{netconfdir}/%{name}|g' \
        -e 's|@modprobe@|%{modprobe}|g' \
        -e 's|@iputil@|%{iputil}|g' \
        -e 's|@tcutil@|%{tcutil}|g'
}
subst < src/scripts/%{name}.sh > %{name}

%install

# Install init script
install -d -m 0755 %{buildroot}%{initdir}
install -m 0755 %{name} %{buildroot}%{initdir}/
install -d -m 0755 %{buildroot}%{_sbindir}
ln -s %{initdir}/%{name} %{buildroot}%{_sbindir}/rc%{name}

# Install sysconfig template
install -d -m 0755 %{buildroot}%{fillupdir}
install -m 0755 src/fillup/sysconfig.%{name} %{buildroot}%{fillupdir}/

%post
%{fillup_only -n -d %{name} network}

%preun
%{stop_on_removal %{name}}

%postun
%{restart_on_update %{name}}
%insserv_cleanup

%files
%attr(0755,root,root) %{initdir}/*
%attr(0755,root,root) %{_sbindir}/*

%changelog
openSUSE Build Service is sponsored by