#!/bin/bash BinNeed="dpkg-deb realpath" Wai=$(dirname $(realpath $0)) usage () { echo "$0 permet de générer les versions de monithor server et client en paquet debian" exit $1 } GetOut () { [[ $1 == "pkg" ]] && echo "Le paquet $2 est nécessaire" && usage 1 } CheckDep() { for CheckBinNeed in ${BinNeed} do TestCheckBinNeed=$(which $CheckBinNeed) [[ -z $TestCheckBinNeed ]] && GetOut pkg $CheckBinNeed done } GitVersion() { LastTag=$(git tag | sed "s/^V//g" | cut -d"-" -f1 | sort -n -k2 -t. | tail -n1) NewTag=${LastTag}-rebuild } CpArchName() { rm -Rf /tmp/monithor-* cp -Rf ${Wai}/monithor-${1} /tmp/monithor-${1}_${2}_all } SedControl() { sed -i "/^Version/s/:.*/: ${2}/g" /tmp/monithor-${1}_${2}_all/DEBIAN/control } BuildDeb(){ echo -n "Gen monithor-${1} [$2] : " cd /tmp/ &> /dev/null Dist=$(lsb_release -a 2> /dev/null | grep Distributor |awk '{print $NF}' |tr '[:upper:]' '[:lower:]') [[ $Dist == "ubuntu" ]] && Compress=' -Z gzip -S fixed ' dpkg-deb ${Compress} --build --root-owner-group monithor-${1}_${2}_all &> /dev/null [[ "$?" -eq "0" ]] && echo "OK" || echo "FAILED" cp monithor-*deb ${Wai}/build } CleanTemp() { mkdir $Wai/build &> /dev/null mv monithor-*deb $Wai/build rm -Rf monithor-* } ManPage() { mkdir -p /tmp/monithor-${1}_${2}_all/usr/share/man/man1/ pandoc -s -t man ${Wai}/doc/monithor-${1}.md -o /tmp/monithor-${1}_${2}_all/usr/share/man/man1/monithor-${1}.1 gzip /tmp/monithor-${1}_${2}_all/usr/share/man/man1/monithor-${1}.1 } [[ ! -z $1 ]] && usage CheckDep GitVersion CpArchName server $NewTag SedControl server $NewTag ManPage server $NewTag BuildDeb server $NewTag CpArchName client $NewTag SedControl client $NewTag ManPage client ${NewTag} BuildDeb client $NewTag