Commit 0672c2f4 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Initial commit

parents
.gitlab-ci.yml export-ignore
.gitattributes export-ignore
debian export-ignore
image: debian:stretch
stages:
- sources-upload
- sources-mock
- package-build
- package-install
- package-upload
# Create the targz which we will inject into the build
sources-mock:
stage: sources-mock
only:
- tags
except:
- master
- tags@idms-linux/awit-ifupdown-addons
script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get dist-upgrade -y
- apt-get install -y git xz-utils
- cd "$CI_PROJECT_DIR"
# Work out naming
- export ARCHIVE_VERSION="${CI_BUILD_TAG%%-*}"
- export ARCHIVE_NAME=${CI_PROJECT_NAME##package-}-${ARCHIVE_VERSION##v}
# Create tar archive
- git archive --format=tar --prefix=${ARCHIVE_NAME}/ ${CI_BUILD_TAG} > ../${ARCHIVE_NAME}.tar
# Create compressed versions
- xz --keep --extreme -9 ../${ARCHIVE_NAME}.tar
# Save the source build for later
- mkdir build
- mv ../*.tar.xz build/
# Artifacts
artifacts:
expire_in: 1 day
paths:
- build/
sources-upload:
stage: sources-upload
only:
- tags@idms-linux/awit-ifupdown-addons
except:
- master
script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get dist-upgrade -y
- apt-get install -y git xz-utils curl lftp gnupg
- cd "$CI_PROJECT_DIR"
# Import signing key
- echo "$SOURCES_GPG_SIGNKEY" | gpg --import
# Work out naming
- export ARCHIVE_VERSION="${CI_BUILD_TAG%%-*}"
- export ARCHIVE_NAME=${CI_PROJECT_NAME##package-}-${ARCHIVE_VERSION##v}
# Create tar archive
- git archive --format=tar --prefix=${ARCHIVE_NAME}/ ${CI_BUILD_TAG} > ../${ARCHIVE_NAME}.tar
# Create compressed versions
- xz --keep --extreme -9 ../${ARCHIVE_NAME}.tar
# Sign compressed tar files
- gpg --sign --detach-sign --armor ../${ARCHIVE_NAME}.tar.xz
# Upload files, translating .asc into .sign
- lftp -e "set ssl:ca-file '/etc/ssl/certs/ca-certificates.crt'; set net:max-retries '5'; set net:timeout '60'; rm -r -f '${ARCHIVE_VERSION}'; mkdir '${ARCHIVE_VERSION}' && put ../'${ARCHIVE_NAME}.tar.xz' -o '${ARCHIVE_VERSION}/${ARCHIVE_NAME}.tar.xz' && put ../'${ARCHIVE_NAME}.tar.xz.asc' -o '${ARCHIVE_VERSION}/${ARCHIVE_NAME}.tar.xz.sign'; quit" -u "$UPLOAD_CRED" "$UPLOAD_HOST" 2>&1
# Test uploaded files
- curl --fail -o /dev/null "$DOWNLOAD_URL/${ARCHIVE_VERSION}/${ARCHIVE_NAME}.tar.xz"
- curl --fail -o /dev/null "$DOWNLOAD_URL/${ARCHIVE_VERSION}/${ARCHIVE_NAME}.tar.xz.sign"
# Create empty build dir
- mkdir build
# Artifacts
artifacts:
expire_in: 1 day
paths:
- build/
package-build:
stage: package-build
only:
- tags
except:
- master
script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get dist-upgrade -y
- apt-get install -y devscripts git
- cd "$CI_PROJECT_DIR"
# Set debuild variables
- export DEBFULLNAME="IDMS Linux CI"
- export DEBEMAIL="cibuild@idms-linux.com"
- export DEBUILD_LINTIAN_OPTS="--fail-on-warnings"
# Package variables
- export CLEAN_CI_BUILD_TAG=$(echo "$CI_BUILD_TAG" | sed -e 's/%/~/g')
- export PACKAGE_CODENAME=$(echo "$CI_BUILD_TAG" | grep -q "%" && echo testing || echo stretch)
- export PACKAGE_NAME="${CI_PROJECT_NAME##package-}"
- export PACKAGE_VERSION_FULL="${CLEAN_CI_BUILD_TAG##v}"
- export ARCHIVE_VERSION="${CLEAN_CI_BUILD_TAG%%-*}"
- export ARCHIVE_NAME="${CI_PROJECT_NAME##package-}-${ARCHIVE_VERSION##v}"
- export ARCHIVE_NAME_ORIG="${CI_PROJECT_NAME##package-}_${ARCHIVE_VERSION##v}.orig"
# Install build deps
- mk-build-deps --install --remove debian/control
# Update changelog
- debchange --create --newversion "${PACKAGE_VERSION_FULL}" --package "$PACKAGE_NAME" --distribution "$PACKAGE_CODENAME" "CI build."
# Download sources, first try from build directory, then using uscan
- cp build/"${ARCHIVE_NAME}.tar.xz" ../"${ARCHIVE_NAME_ORIG}".tar.xz || /bin/true
- if [ ! -e ../"${ARCHIVE_NAME_ORIG}.tar.xz" ]; then uscan --verbose --force-download; fi
# Move build directory for build
- mv build ../
# Remove files that we don't include in the sources package
- rm -f .gitlab-ci.yml
# Build
- debuild -uc -us
# Move build directory bank and move package files to build directory
- mv ../build .
- mv ../"${PACKAGE_NAME_WITHOUT_S_AT_END}"*.* build/
# Artifacts
artifacts:
expire_in: 1 day
paths:
- build/
package-install:
stage: package-install
only:
- tags
except:
- master
script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get dist-upgrade -y
- cd "$CI_PROJECT_DIR"
- dpkg -i build/*.deb || /bin/true
- apt-get install -y -f
# Artifacts
artifacts:
expire_in: 1 day
paths:
- build/
package-upload:
stage: package-upload
only:
- tags@idms-linux/awit-ifupdown-addons
except:
- master
script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get dist-upgrade -y
- apt-get install -y devscripts gnupg
# Set debuild variables
- export DEBFULLNAME="IDMS Linux CI"
- export DEBEMAIL="cibuild@idms-linux.com"
- export DEBUILD_LINTIAN_OPTS="--fail-on-warnings"
# Import signing key
- echo "$DEB_GPG_SIGNKEY" | gpg --import
# Sign package
- cd "$CI_PROJECT_DIR"
- cd build
- debsign -k"$DEBEMAIL" *.dsc *.changes
# Create dput configuration
- echo "[package-upload]" > ~/.dput.cf
- echo "fqdn=package-upload.cdn.idms-linux.org" >> ~/.dput.cf
- echo "method=https" >> ~/.dput.cf
- echo "incoming=/" >> ~/.dput.cf
# Upload package
- dput package-upload *.changes
# Artifacts
artifacts:
expire_in: 1 day
paths:
- build/
rate-limit usr/lib/awit-ifupdown-addons
usr/lib/awit-ifupdown-addons/rate-limit etc/network/if-up.d/rate-limit
usr/lib/awit-ifupdown-addons/rate-limit etc/network/if-down.d/rate-limit
Source: awit-ifupdown-addons
Section: utils
Priority: optional
Maintainer: Nigel Kukard <nkukard@allworld.it>
Build-Depends: debhelper (>=9)
Standards-Version: 3.9.4
Vcs-Browser: https://gitlab.devlabs.linuxassist.net/idms-linux/awit-ifupdown-addons
Vcs-Git: https://gitlab.devlabs.linuxassist.net/idms-linux/awit-ifupdown-addons.git
Package: awit-ifupdown-addons
Architecture: all
Depends: ${misc:Depends}
Description: ifupdown addons for IDMS Linux
Collection of ifupdown addons for IDMS Linux.
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Contact: Nigel Kukard <nkukard@allworld.it>
Source: https://download.allworldit.org/awit-ifupdown-addons
Files: *
Copyright: 2010-2017 AllWorldIT contact Nigel Kukard <nkukard@allworld.it>
License: GPL-3+
#!/usr/bin/make -f
%:
dh $@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFhpvigBEACroNXElHYzKRSe4bK6QCSdY42sUNoY9yzyvQtVTkJtiZtHgXbe
U2CV/dF/uhNvTECfEkjPtWZz6sXqn5z5UcQECPTyF+vGNtwaV1iM+DCe33AjzTPE
sCE49CoZ2N0HVlN7/AGingigpcz76DUx0U/2tw+CEmwZTJ8T9pSq9cbBGFVQPzgw
5nLWtH8oMuound4foniI/3H7+qO873XbJvG3wUR0GFrO0Juac7kDDc5p4TVRW4gm
7qNTXXkpZli2/m8UTQbeVVKcZukQVBtuWyz3Uqqxds52xZD7l6Iu1kPfni10S7Vi
Wv1FZnc2ffO40pDZklV8nKwkP0XQvtRHdi+990P9n85GZvVrDRVnMWzcNKa5JEct
HiWTYlAkGjUYR7kZ4vL0fKZgeAfX51p2Z6b4evVdlReeoeZ/tjRdiOcDHvTontu3
YxnduKLm170sNCOweikgxCjLQtufbvYq0BT9IKzZcEIX5RkzmOj11FwS4+g87UyQ
/jxx1xyvcq5jL4YHYJYwDGD//WRJZ7veQ/ELL6APRipsas9aLpT6TD1E23CmOp3a
RGLkRdckB9vI9yIDq+9qy8JC0dlSDqqde1urHL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s/$/.sign/,\
downloadurlmangle=s/\/v?(\d+\.\d+\.\d+.*)$/\/v$1\/awit-ifupdown-addons-$1.tar.xz/,\
filenamemangle=s/v?(\d+\.\d+\.\d+.*)$/awit-ifupdown-addons-$1.tar.xz/ \
https://download.allworldit.org/awit-ifupdown-addons/v?(\d+\.\d+\.\d+.*)
#!/bin/sh
# rate-limit - Interface rate limit support
# Copyright (c) 2010-2017, AllWorldIT
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# If we're onlining the interface we need to set things up
if [ "$MODE" = "start" ]
then
# Check if we're setting an outbound limit
if [ -n "$IF_LIMIT_OUT" ]
then
# Work out 95% lower limit and 98% upper limit
SPEED_LOW=$(printf '%0.1f' $(echo "scale=1; $IF_LIMIT_OUT * 0.95" | bc -l))
SPEED_HIGH=$(printf '%0.1f' $(echo "scale=1; $IF_LIMIT_OUT * 0.98" | bc -l))
# Clear current qdisc
tc qdisc del dev "$IFACE" root > /dev/null 2>&1 || :
# Setup root hfsc
tc qdisc add dev "$IFACE" root handle 1: hfsc default 1
# Configure speed limit
tc class add dev "$IFACE" parent 1: classid 1:1 hfsc sc rate "${SPEED_LOW}mbit" ul rate "${SPEED_HIGH}mbit"
# Add SFQ for fairness
tc qdisc add dev "$IFACE" parent 1:1 handle 10: sfq perturb 10 divisor 32768 limit 12700 flows 1024
fi
# Check if we're setting an inbound limit
if [ -n "$IF_LIMIT_IN" ]
then
# Work out burst speed
BURST=$(echo "scale=0; ($IF_LIMIT_IN * 1024) / 8 / 2" | bc -l)
# Clear ingress handle
tc qdisc del dev "$IFACE" ingress > /dev/null 2>&1 || :
# Add ingress qdisc
tc qdisc add dev "$IFACE" ingress
# Setup police for inbound traffic
tc filter add dev "$IFACE" parent ffff: u32 match u32 0 0 police rate "${IF_LIMIT_IN}mbit" burst "${BURST}k" mtu 64kb drop
fi
# If we're offlining the interface we need to remove things we setup
elif [ "$MODE" = "stop" ]
then
# Remove root qdisc on interface
tc qdisc del dev "$IFACE" root > /dev/null 2>&1 || :
tc qdisc del dev "$IFACE" ingress > /dev/null 2>&1 || :
# Clear filters
tc filter del dev "$IFACE" parent ffff: > /dev/null 2>&1 || :
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment