#!/bin/bash # # Author: Angel Berlanas Vicente # # This Script is licensed by GPL V3 or higher. # VARIABLES WORK_PWD="" CONF_FILE="/etc/lliurex/llxdev.conf" LIB_FILE="/usr/share/lliurex-non-essential-tools/common.sh" FILE_TPL="/usr/share/lliurex-non-essential-tools/templates/copyright.tpl" ALL_STAR="/usr/share/lliurex-non-essential-tools/lliurex-all-star.team" [ -e "$LIB_FILE" -a -e "$CONF_FILE" ] || exit 1 . "$LIB_FILE" . "$CONF_FILE" _die(){ # DIE function to exit echo $@ && exit 1 } _some_sanity_checks(){ [ -e $LLIUREX_UPLOADERS_LIST ] || _die "$LLIUREX_UPLOADERS_LIST not present...please check your configuration" return 0 } _test_package_place(){ # Test if the "debian" directory is present and # store local directory WORK_PWD=$(pwd) [ -d $WORK_PWD/debian ] || _die "debian directory not exists .... Sure that we are in Debian Package Root Directory" return 0 } _usage(){ CMD="$(basename "$0")" echo "Usage: $CMD [ --force ] update " echo " $CMD show-maintainers " exit 0 } _myecho(){ echo "++++++++++++++++++++++" echo "$@" echo "++++++++++++++++++++++" } _show_maintainers(){ cat "$LLIUREX_UPLOADERS_LIST" return 0 } _test_control_sanity(){ # Test if control have some Sanit Values # Uploaders is present # Maintainers Team [ -f $WORK_PWD/debian/control ] || _die "Control file not present, exiting..." TMP_UPLOADERS_LIST=$(mktemp /tmp/lliurex-build.XXXXX) TMP_CONTROL=$(mktemp /tmp/lliurex-build.XXXXXXXX) cp -f $WORK_PWD/debian/control $TMP_CONTROL # Fix Uploaders Line grep -q "^Uploaders" $WORK_PWD/debian/control || sed -i "/^Maintainer/a\Uploaders:" $WORK_PWD/debian/control LIST_UPLOADERS_PRESENT="$(cat $WORK_PWD/debian/control | grep "^Uploaders" | cut -d : -f2 | sed -e "s%,[[:blank:]]%\n%g;s%^[[:blank:]]%%g")" _myecho "Uploaders in Control are: " echo "$LIST_UPLOADERS_PRESENT" | tee $TMP_UPLOADERS_LIST _myecho " There are : $(echo $"$LIST_UPLOADERS_PRESENT" | wc -l ) Uploaders" DIFF=$(combine "$TMP_UPLOADERS_LIST" xor "$LLIUREX_UPLOADERS_LIST") NUM_DIFF=$(echo $DIFF | wc -w) if [ $NUM_DIFF -ne 0 ] ; then _myecho "There Are differences:" echo $DIFF if [ ! $SILENT_MODE ] ; then _myecho "Do you want to Update it ^_^ (Y/n)?" read ANSWER else ANSWER="Y" fi # If Answer is Positive we replace the Uploaders List if [ "$ANSWER" = "Y" ] ; then _myecho "Updating List...." INCOMPLETELIST="$(cat $LLIUREX_UPLOADERS_LIST | sed -e "s%^% %g" | tr "\n" ","| sed -e "s%,\$%%g")" COMPLETELIST="Uploaders:$INCOMPLETELIST" sed -e "s%^Uploaders:.*%$COMPLETELIST%;s%^Maintainer:.*%$LLIUREX_TEAM%g" "$WORK_PWD/debian/control" > $TMP_CONTROL mv "$TMP_CONTROL" "$WORK_PWD/debian/control" dch -a "Uploaders Fixed" fi fi rm -f $TMP_UPLOADERS_LIST rm -f $TMP_CONTROL return 0 } all_star_fix(){ if [ -r "$ALL_STAR" ] ; then STAR_TAG="XBSC-All-Star-Uploaders:" STAR_LIST="$(cat "$ALL_STAR" |tr "\n" "," |sed -e "s%,%, %" )" TMP_FILE="$(tempfile)" cp -a debian/control $TMP_FILE sed -e "/^$STAR_TAG/d;/^Uploaders:/a$STAR_TAG;/^$STAR_TAG/s%$%$STAR_LIST%" $TMP_FILE cat $TMP_FILE > debian/control fi } # # MAIN # #Source of Configuration _some_sanity_checks _test_package_place ACTION="$1" # If --force Flag is sended , enable Silent Mode if [ "$ACTION" = "--force" ] ; then SILENT_MODE="on" ACTION="$2" fi # Actions Available case "$ACTION" in update) _test_control_sanity all_star_fix ;; show-maintainers) _show_maintainers ;; *) _usage ;; esac exit 0