File qos.spec of Package qos

#
# Copyright 2013 Archie L. Cobbs.
# 
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# 

%define initdir     %{_sysconfdir}/init.d
%define netconfdir  %{_sysconfdir}/sysconfig/network
%define modprobe    /sbin/modprobe
%define tcutil      %{_sbindir}/tc
%define iputil      /bin/ip
%define fillupdir   %{_var}/adm/fillup-templates

Name:               qos
Version:            1.0.1
Release:            1
Buildarch:          noarch
Summary:            Simple traffic shaping utility for fighting bufferbloat
Group:              System/Management
License:            Apache-2.0
#Source0:            https://github.com/archiecobbs/qos/archive/1.0.1.tar.gz
Source0:            %{name}-%{version}.tar.gz
BuildRoot:          %{_tmppath}/%{name}-root
URL:                https://github.com/archiecobbs/qos
Requires:           iproute2
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}/*
%attr(0644,root,root) %{fillupdir}/*

%changelog
openSUSE Build Service is sponsored by