summaryrefslogtreecommitdiffstats
path: root/update-scripts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:19:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:19:02 +0000
commit03929dac2a29664878d2c971648a4fe1fb698462 (patch)
tree02c5e2b3e006234aa29545f7a93a1ce01b291a8b /update-scripts
parentInitial commit. (diff)
downloadirssi-scripts-upstream.tar.xz
irssi-scripts-upstream.zip
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'update-scripts')
-rwxr-xr-xupdate-scripts227
1 files changed, 227 insertions, 0 deletions
diff --git a/update-scripts b/update-scripts
new file mode 100755
index 0000000..0bda7a5
--- /dev/null
+++ b/update-scripts
@@ -0,0 +1,227 @@
+#!/bin/bash
+
+usage () {
+ printf "\nUsage:\n"
+ printf "\t update-scripts [options]\n\n"
+ printf "Options:\n\n"
+ printf "\t -c, --check Don't actually apply any changes.\n"
+ printf "\t -n, --nodown Don't download any scripts.\n"
+ printf "\t -h, --help Print this help text.\n\n"
+}
+
+parse () {
+ while read -r col1 col2; do
+ case $col1 in
+ script)
+ if [[ $scrdup = no && $scrpack = yes ]]; then
+ if [ "$urlfnd" = "no" ]; then
+ echo "$script has no upstream source."
+ printf "url\t\tNo upstream source.\n" >> INDEX
+ fi
+ if [ "$descfnd" = "no" ]; then
+ echo "$script has no description."
+ printf "description\tNo description.\n\n" >> INDEX
+ printf "%-29s No description.\n" "$script" >> debian/description-list
+ fi
+ fi
+ script="$col2"
+ urlfnd="no"
+ descfnd="no"
+ if ! grep -q "^$script$" .scriptlist; then
+ scrdup="no"
+ echo "$script --------------------"
+ echo "$script" >> .scriptlist
+ if grep -q "^$script$" .packagedlist; then
+ scrpack="yes"
+ printf "script\t\t%s\n" "$script" >> INDEX
+ else
+ scrpack="no"
+ echo "$script is not included yet, skipping."
+ echo "$script" >> .nonincludes
+ fi
+ else
+ scrdup="yes"
+ fi
+ ;;
+ url)
+ urlfnd="yes"
+ url="$col2"
+ if [[ $scrdup = no && $scrpack = yes ]]; then
+ if [[ $url =~ ^(https?|ftps?):// ]]; then
+ printf "url\t\t%s\n" "$url" >> INDEX
+ if [ "$nodown" != "yes" ]; then
+ get_new "$script" "$url"
+ fi
+ else
+ echo "$script has no upstream source."
+ printf "url\t\tNo upstream source.\n" >> INDEX
+ fi
+ fi
+ ;;
+ description)
+ descfnd="yes"
+ desc="$col2"
+ if [[ $scrdup = no && $scrpack = yes ]]; then
+ if [ "$urlfnd" = "no" ]; then
+ urlfnd="yes"
+ echo "$script has no upstream source."
+ printf "url\t\tNo upstream source.\n" >> INDEX
+ fi
+ if [ -z "$desc" ]; then
+ echo "$script has no description."
+ desc="No description."
+ fi
+ printf "description\t%s\n\n" "$desc" >> INDEX
+ printf "%-29s %s\n" "$script" "$desc" >> debian/description-list
+ fi
+ ;;
+ esac
+ done <<< "$1" | tee -a update-scripts.log
+}
+
+get_new () {
+ script="$1"
+ url="$2"
+ wget -t 5 -T 10 -qO "scripts/$script.new" "$url" || {
+ echo "$script failed to download."
+ rm "scripts/$script.new"
+ return
+ }
+ if diff "scripts/$script" "scripts/$script.new" > /dev/null; then
+ echo "$script is up to date."
+ rm "scripts/$script.new"
+ else
+ echo "$script needs updating."
+ echo "$script" >> .changes
+ if [ "$noapply" != "yes" ]; then
+ mv "scripts/$script.new" "scripts/$script"
+ else
+ rm "scripts/$script.new"
+ fi
+ fi
+}
+
+opts=$(getopt -o "cnh" -l "check,nodown,help" -- "$@")
+eval set -- "$opts"
+
+while true; do
+ case $1 in
+ -c|--check)
+ noapply="yes"
+ shift
+ ;;
+ -n|--nodown)
+ nodown="yes"
+ shift
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ --)
+ shift
+ break
+ ;;
+ esac
+done
+
+shopt -s extglob
+
+debclean > /dev/null 2>&1 || exit 1
+
+### Main
+
+indexweb=$(wget -t 5 -T 10 -qO - http://scripts.irssi.org/) && {
+ wording="Downloaded"
+ indexweb=$(sed -ne '/<tr>/,/<\tr>/ {/<tr>/h; /<tr>/!H; /<\/tr>/ {g; /<td class="filename">.*<small>.*<td class="description">/ '\
+'{s/[[:space:]]\+/ /g;s/[^[:print:]]//g;s@^.*<td class="filename">.*<a href="[^"]*/\([^/"]\+\)".*<small>.*<a href="\([^"]\+\)"'\
+'.*<td class="description">\([^<]*\)</td>.*$@script\t\t\1\nurl\t\t\2\ndescription\t\3\n@;s|\(github.com/.*\)/blob/|\1/raw/|g;p}}}' <<< "$indexweb" \
+ | perl -MHTML::Entities -ne 'print decode_entities($_)')
+} || wording="Could not download"
+printf "\n%s web index.\n\n" "$wording" | tee update-scripts.log
+
+indexcurr=$(sed -n 's/^\(script\|\url\)[ \t]\+/\1\t\t/p;s/^\(description\)[ \t]\+\(.*\)$/\1\t\2\n/p' INDEX)
+touch $(awk -F '[\t]+' '$1 == "script" {print "scripts/" $2}' <<< "$indexcurr")
+
+packlist=(scripts/!(*.asc|*.new|XMMSInfo.pm))
+packlist=("${packlist[@]##*/}")
+printf "%s\n" "${packlist[@]}" > .packagedlist
+
+mv INDEX INDEX.orig
+mv debian/description-list debian/description-list.orig
+> .scriptlist
+> .changes
+> .nonincludes
+
+parse "$indexweb"
+parse "$indexcurr"
+
+buffer=$(sort .scriptlist)
+echo "$buffer" > .scriptlist
+
+### Index
+
+if ! diff INDEX.orig INDEX > /dev/null; then
+ if [ "$noapply" != "yes" ]; then
+ wording="has been updated"
+ rm INDEX.orig
+ else
+ wording="needs updating"
+ mv INDEX.orig INDEX
+ fi
+ printf "\nThe index file %s.\n" "$wording" | tee -a update-scripts.log
+fi
+
+### Descriptions
+
+buffer=$(sort -t ' ' -k 1,1 debian/description-list)
+echo "$buffer" > debian/description-list
+
+buffer=$(debian/rewrap.pl)
+echo "$buffer" > debian/description-list
+
+if ! diff debian/description-list.orig debian/description-list > /dev/null; then
+ if [ "$noapply" != "yes" ]; then
+ wording="has been updated"
+ rm debian/description-list.orig
+ else
+ wording="needs updating"
+ mv debian/description-list.orig debian/description-list
+ fi
+ printf "\nThe description list %s.\n" "$wording" | tee -a update-scripts.log
+fi
+
+### Missing
+
+diff .scriptlist .packagedlist | awk '/^>/ {print $2}' > .missinglist
+rm .scriptlist .packagedlist
+
+sed -n '/^Known-Missing:/ {s/^Known-Missing: //;s/, /\n/g;p}' debian/copyright | sort > .knownlist
+missdiff=$(diff .knownlist .missinglist | grep '^[><]')
+if [ -n "$missdiff" ]; then
+ printf "\nThese are the differences between the known missing\nupstreams and the discovered missing upstreams:\n%s\n" "$missdiff" \
+ | tee -a update-scripts.log
+fi
+rm .missinglist .knownlist
+
+### Changes
+
+changes=$(sed -n '1 h; 2,$ {s/^.\+$/, &/;H}; $ {g;s/\n//g;p}' .changes)
+if [ -n "$changes" ]; then
+ if [ "$noapply" != "yes" ]; then
+ wording="Updated"
+ dch "Update: $changes"
+ else
+ wording="Updating needed"
+ fi
+ printf "\n%s: %s\n" "$wording" "$changes" | tee -a update-scripts.log
+fi
+rm .changes
+
+### Non-includes
+
+nonincludes=$(sed -n '1 h; 2,$ {s/^.\+$/, &/;H}; $ {g;s/\n//g;p}' .nonincludes)
+if [ -n "$nonincludes" ]; then
+ printf "\nNot included: %s\n" "$nonincludes" | tee -a update-scripts.log
+fi
+rm .nonincludes