summaryrefslogtreecommitdiffstats
path: root/bin/padd.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/padd.sh')
-rwxr-xr-xbin/padd.sh160
1 files changed, 160 insertions, 0 deletions
diff --git a/bin/padd.sh b/bin/padd.sh
new file mode 100755
index 0000000..c561fc6
--- /dev/null
+++ b/bin/padd.sh
@@ -0,0 +1,160 @@
+#!/bin/sh
+
+set -e
+
+case "$(basename ${0})" in
+ p*)
+ MODE="progress-linux"
+ ;;
+
+ b*)
+ MODE="bfh"
+ ;;
+esac
+
+HOSTNAME="$(hostname -f)"
+
+RED="\033[1;33;31m"
+GREEN="\033[1;33;32m"
+YELLOW="\033[1;33;33m"
+BLUE="\033[1;33;34m"
+WHITE="\033[1;33;37m"
+NORMAL="\033[0m"
+PURPLE="\033[1;33;35m"
+
+case "${MODE}" in
+ progress-linux)
+ CHANNELS="progress-linux bfh-linux-systems"
+ ;;
+
+ bfh)
+ CHANNELS="bfh-linux-systems"
+ ;;
+esac
+
+Irk ()
+{
+ MESSAGE="${1}"
+
+ echo ${MESSAGE}
+
+ for CHANNEL in ${CHANNELS}
+ do
+ irk irc://irc.oftc.net:7000/${CHANNEL} ${MESSAGE}
+ done
+}
+
+ARCHITECTURES="arm64 armel armhf amd64 i386"
+
+case "$(basename ${PWD})" in
+ *_arm64)
+ _ARCH="arm64"
+ ;;
+
+ *_armel)
+ _ARCH="armel"
+ ;;
+
+ *_armhf)
+ _ARCH="armhf"
+ ;;
+
+ *_amd64)
+ _ARCH="amd64"
+ ;;
+
+ *_i386)
+ _ARCH="i386"
+ ;;
+
+ *_all)
+ _ARCH="all"
+ ;;
+
+ *_source)
+ _ARCH="source"
+ ;;
+esac
+
+#_DIST="$(cd ../../../ && echo $(basename ${PWD}))"
+
+case "${_ARCH}" in
+ source)
+ #_DIST="$(grep -m1 '^Distribution: ' *.dsc | awk '{ print $2 }')"
+ _DIST="$(pwd | awk -F/ '{ print $5 }')"
+ _PACKAGE="$(basename *.dsc .dsc | awk -F_ '{ print $1 }')"
+ ;;
+
+ *)
+ _DIST="$(grep -m1 '^Distribution: ' *.changes | awk '{ print $2 }')"
+ _PACKAGE="$(basename *.changes .changes | awk -F_ '{ print $1 }')"
+ ;;
+esac
+
+# HACK
+_POOL="/srv/${HOSTNAME}/packages"
+
+if ls *.dsc > /dev/null 2>&1
+then
+ echo "### Removing ${_PACKAGE} sources..."
+
+ # Remove source and binary upload
+ reprepro -b ${_POOL} removesrc ${_DIST} ${_PACKAGE} || true
+
+ # Include source upload
+ echo "### Including ${_PACKAGE} upload..."
+ reprepro -b ${_POOL} ${_REPREPRO_OPTIONS} includedsc ${_DIST} *.dsc
+else
+ #echo "### Removing ${_PACKAGE} binary..."
+ ## Remove binary upload
+ #reprepro -b ${_POOL} --architecture ${_ARCH} remove ${_DIST} ${_PACKAGE} || true
+
+ echo "### Including ${_PACKAGE} upload..."
+ reprepro -b ${_POOL} ${_REPREPRO_OPTIONS} include ${_DIST} *.changes
+fi
+
+if [ "${1}" != "quiet" ]
+then
+ case "${_ARCH}" in
+ source)
+ FILE="dsc"
+ ;;
+ *)
+ FILE="changes"
+ ;;
+ esac
+
+ _SOURCE="$(grep -m1 '^Source: ' *.${FILE} | awk '{ print $2 }')"
+ _VERSION="$(grep -m1 '^Version: ' *.${FILE} | awk '{ print $2 }')"
+ #_URGENCY="$(grep -m1 '^Urgency: ' *.${FILE} | awk '{ print $2 }')"
+ _URGENCY="$(grep -m1 '^Urgency: ' *.${FILE} | awk '{ print $2 }')"
+ #_DISTRIBUTION="$(grep -m1 '^Distribution: ' *.${FILE} | awk '{ print $2 }')"
+ _DISTRIBUTION="${_DIST}"
+ #_ARCHITECTURE="$(grep -m1 '^Architecture: ' *.${FILE} | awk '{ $1=""; print $0 }' | sed -e 's|^ ||')"
+ _ARCHITECTURE="${_ARCH}"
+
+ _UPLOADER="$(grep -m1 '^Changed-By: ' *.${FILE} | awk -F: '{ print $2 }' | sed -e 's|^ ||' -e 's|<.*||')"
+
+ case "${_ARCH}" in
+ source)
+ ;;
+
+ *)
+ if grep -qs '^Closes: ' *.changes
+ then
+ _BUGS="(Closes: ${PURPLE}$(grep -m1 '^Closes: ' *changes | sed -e 's|^Closes: |#|' -e "s| |\\\033\\[0m, \\\033\\[1;33;35m#|g")${NORMAL})"
+ fi
+ ;;
+ esac
+
+ case "${_ARCH}" in
+ source)
+ Irk "${GREEN}${_SOURCE}${NORMAL} ${_VERSION} [${_ARCHITECTURE}] uploaded to ${BLUE}${_DISTRIBUTION}${NORMAL}"
+ ;;
+
+ *)
+ Irk "${GREEN}${_SOURCE}${NORMAL} ${_VERSION} [${_ARCHITECTURE}] uploaded to ${BLUE}${_DISTRIBUTION}${NORMAL} with urgency ${RED}${_URGENCY}${NORMAL} by ${YELLOW}${_UPLOADER}${NORMAL}${_BUGS}"
+ ;;
+ esac
+ #twidge update "uploaded ${_SOURCE} ${_VERSION} to ${_DISTRIBUTION} #progress_linux"
+fi