aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-08-29 20:06:44 -0400
committerB. Watson <urchlay@slackware.uk>2026-08-29 20:06:44 -0400
commit55504fefce3078ac683b85508fa8af9e4d1b2059 (patch)
treee5590710b084f84520cfcce5f421403ea5a54132
parent8a78cfe513eb112585a5c5660fcbeb7cb3c58719 (diff)
downloadsbostuff-55504fefce3078ac683b85508fa8af9e4d1b2059.tar.gz
admin/*: added.
-rw-r--r--admin/README5
-rwxr-xr-xadmin/getmaintbuilds9
-rwxr-xr-xadmin/getmaintdependees58
l---------admin/getmaintreqs1
-rwxr-xr-xadmin/masschangemaint24
-rwxr-xr-xadmin/offerbuild90
-rwxr-xr-xadmin/orphanize34
-rwxr-xr-xadmin/orphm3
-rwxr-xr-xadmin/pingmaint91
-rwxr-xr-xadmin/sbodeathrow171
10 files changed, 486 insertions, 0 deletions
diff --git a/admin/README b/admin/README
new file mode 100644
index 0000000..fff6f01
--- /dev/null
+++ b/admin/README
@@ -0,0 +1,5 @@
+These tools are intended for SBo admins. I include them here because
+they may also be useful for others, and because they need to be hosted
+in a git repo *somewhere*.
+
+Don't expect them to be polished or well-documented.
diff --git a/admin/getmaintbuilds b/admin/getmaintbuilds
new file mode 100755
index 0000000..ea665c9
--- /dev/null
+++ b/admin/getmaintbuilds
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+source ~/sbostuff/sbostuff.sh
+cd $SBO_GITROOT || exit 1
+if echo "$*" | grep -q '@'; then
+ echo $( git grep 'EMAIL="'"$*"'"' '*/*/*.info' | cut -d/ -f2 )
+else
+ echo $( git grep 'MAINTAINER="'"$*"'"' '*/*/*.info' | cut -d/ -f2 )
+fi
diff --git a/admin/getmaintdependees b/admin/getmaintdependees
new file mode 100755
index 0000000..3fc31e1
--- /dev/null
+++ b/admin/getmaintdependees
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# dependees maintained by the same maintainer are listed without
+# name/email. only "external" dependees (ones maintained by someone else)
+# have the name/email displayed.
+
+EES=ees
+if [ "$( basename $0 )" = "getmaintreqs" ]; then
+ REV=-r
+ EES=encies
+fi
+
+source ~/sbostuff/sbostuff.sh
+
+##if [ "$1" = "-b" ]; then
+## shift
+## builds="$1"
+## cdsb $builds && maint="$( source ./*.info && echo $MAINTAINER )"
+## shift
+## if [ "$*" ]; then
+## echo "$( basename $0 ): -b only allows one build" 1>&2
+## exit 1
+## fi
+##else
+## maint="$*"
+## builds="$( getmaintbuilds "$@" )"
+##fi
+
+maint="$*"
+builds="$( getmaintbuilds "$@" )"
+
+for i in $builds; do
+ set $( hoorex -m $REV $i )
+ if [ "$2" ]; then
+ echo -n "$1"
+ shift
+ echo -n ": "
+ can_orphan=yes
+ for j in "$@"; do
+ echo -n "$j "
+ cdsb $j
+ source ./$j.info
+ if [ "$MAINTAINER" != "$maint" -a "$EMAIL" != "NOEMAIL" ]; then
+ can_orphan=no
+ echo -n "('$MAINTAINER' $EMAIL) "
+ fi
+ done
+ echo
+ [ "$can_orphan" = "yes" ] && orphanable+="$i "
+ else
+ orphanable+="$1 "
+ fi
+done
+
+if [ "$orphanable" != "" ]; then
+ echo "These have no depend$EES by other maintainers:"
+ echo "$orphanable"
+fi
diff --git a/admin/getmaintreqs b/admin/getmaintreqs
new file mode 120000
index 0000000..acec184
--- /dev/null
+++ b/admin/getmaintreqs
@@ -0,0 +1 @@
+getmaintdependees \ No newline at end of file
diff --git a/admin/masschangemaint b/admin/masschangemaint
new file mode 100755
index 0000000..1c5dbdd
--- /dev/null
+++ b/admin/masschangemaint
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+source ~/sbostuff/sbostuff.sh
+
+if [ "$1" = "" ]; then
+ echo "Builds to change?"
+ read builds
+ set $builds
+fi
+
+echo "New maintainer as [Real Name <email@addr>]?"
+read maint
+name="$( echo $maint | cut -d'<' -f1 | sed 's, *$,,' )"
+mail="$( echo $maint | cut -d'<' -f2 | cut -d'>' -f1 )"
+
+echo "name: '$name'"
+echo "mail: '$mail'"
+
+export SBOLINT=no
+for i in $*; do
+ cdsb $i
+ sbonewmaint "$name" "$mail"
+ git commit -a -m'New maintainer'
+done
diff --git a/admin/offerbuild b/admin/offerbuild
new file mode 100755
index 0000000..d067888
--- /dev/null
+++ b/admin/offerbuild
@@ -0,0 +1,90 @@
+#!/bin/bash
+
+source ~/sbostuff/sbostuff.sh
+
+FROM_NAME="B. Watson"
+FROM_EMAIL="urchlay@slackware.uk"
+
+SELF="$( basename $0 )"
+
+die() {
+ echo "$SELF: $@" 2>&1
+ exit 1
+}
+
+get_dependees() {
+ local build="$1"
+ local i
+
+ i="$( git grep -l "^REQUIRES=.*\<$build\>" | cut -d/ -f1,2 )"
+ echo $i
+}
+
+make_offer() {
+ local i
+ local j
+ local mailto
+ local build="$1"
+ local dependees="$( get_dependees "$1" )"
+
+ if [ "$dependees" = "" ]; then
+ echo "No dependees for $build"
+ return
+ fi
+ echo "$build dependees: $dependees"
+ if [ "$dependees" = "" ]; then
+ echo "=> no dependees for $build, nobody offer to!"
+ return
+ fi
+
+ for i in $dependees; do
+ cdsb $i
+ mailto="$( git grep '^EMAIL=' *.info | cut -d\" -f2 )"
+
+ [ "$mailto" = "NOEMAIL" ] && continue
+
+ echo "=> Enter email address for offer [$mailto]:"
+ read j
+ [ "$j" = "" ] && j="$mailto"
+ mailto="$j"
+
+ tmpfile="$( mktemp $SELF.XXXXXXXXXX )"
+ rm -f $tmpfile
+
+ echo "To: $mailto"
+ cat <<EOF >$tmpfile
+From: $FROM_NAME <$FROM_EMAIL>
+Subject: $( basename $i ) and $build on SBo
+
+$build needs a new maintainer. Your build $( basename $i ) lists it as
+a dependency, so you're the logical choice to take it over.
+
+If you want, I can update the .info file with your contact
+information, so you don't even have to submit an update.
+EOF
+ cat $tmpfile
+
+ echo
+ echo -n "=> Send this email[y]? "
+ read j
+
+ if [ "$j" = "y" -o "$j" = "Y" -o "$j" = "" ]; then
+ j="y"
+ echo "==> Sending email to $mailto"
+ cat $tmpfile | msmtp "$mailto"
+ fi
+
+ rm -f $tmpfile
+ [ "$j" = "y" ] && return
+ done
+}
+
+### main()
+hoorex --version > /dev/null || die "hoorex not installed"
+
+cd $SBO_GITROOT || die "edit sbostuff.sh and set SBO_GITROOT"
+
+for build in "$@"; do
+ echo "checking $build"
+ make_offer "$build"
+done
diff --git a/admin/orphanize b/admin/orphanize
new file mode 100755
index 0000000..40da6a2
--- /dev/null
+++ b/admin/orphanize
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+source ~/sbostuff/sbostuff.sh
+export SBOLINT=no
+
+usage() {
+ cat <<EOF
+Usage:
+orphanize <build> [<build> ...]
+orphanize -m <maintainer>
+EOF
+}
+
+
+orphanize_builds() {
+ local b
+ for b in "$@"; do
+ cdsb "$b" && sbonewmaint nobody && git commit -a -m'Orphaned (unmaintained).'
+ done
+}
+
+orphanize_maint() {
+ local i
+ cdsb
+ for i in $( git grep "^MAINTAINER=\"$@\"" '*/*/*.info' | cut -d/ -f1,2 ); do
+ orphanize_builds "$i"
+ done
+}
+
+case "$1" in
+ "-m") shift; orphanize_maint "$@" ;;
+ ""|"-") usage ;;
+ *) orphanize_builds "$@" ;;
+esac
diff --git a/admin/orphm b/admin/orphm
new file mode 100755
index 0000000..6d173c7
--- /dev/null
+++ b/admin/orphm
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec orphanize -m "$*"
diff --git a/admin/pingmaint b/admin/pingmaint
new file mode 100755
index 0000000..76c6a34
--- /dev/null
+++ b/admin/pingmaint
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+FROM_NAME="B. Watson"
+FROM_EMAIL="urchlay@slackware.uk"
+
+# Usage:
+# pingmaint "Maintainer Name"
+# pingmaint maintainer@domain.tld
+
+SELF=$( basename $0 )
+
+die() {
+ echo "$SELF: $@" 1>&2
+ exit 1
+}
+
+source ~/sbostuff/sbostuff.sh
+cdsb
+
+interactive=yes
+if [ "$1" = "-m" ]; then
+ interactive=no
+ shift
+fi
+
+# given a maintainer's name as args, set TO_ADDR to the email address.
+# if there are more than one email address for the name, print them
+# all and die.
+get_email() {
+ TO_ADDR=""
+
+ TO_ADDR="$( git grep -lF "MAINTAINER=\"$*\"" '*/*/*.info' | xargs grep '^EMAIL=' | cut -d\" -f2 | sort -u | cut -d\" -f2 )"
+
+ if [ "$( echo "$TO_ADDR" | wc -l )" -gt 1 ]; then
+ if [ "$interactive" = "no" ]; then
+ die "Multiple email addresses: $TO_ADDR"
+ fi
+ echo "Multiple email addresses: $TO_ADDR"
+ echo "==> Which address to use?"
+ read TO_ADDR
+ fi
+}
+
+builds="$( getmaintbuilds "$@" )"
+
+if echo "$*" | grep -q '@'; then
+ TO_ADDR="$@"
+else
+ get_email "$@"
+fi
+
+if ! echo "$TO_ADDR" | grep -q '@'; then
+ if [ "$interactive" = "no" ]; then
+ die "Obfuscated address: $TO_ADDR"
+ else
+ echo "==> Enter unobfuscated version of: $TO_ADDR"
+ read TO_ADDR
+ fi
+fi
+
+tmpfile="$( mktemp $SELF.XXXXXXXXXX )"
+rm -f $tmpfile
+
+echo "To: $TO_ADDR"
+cat <<EOF >$tmpfile
+From: $FROM_NAME <$FROM_EMAIL>
+Subject: builds on SlackBuilds.org
+
+You're listed as maintainer for these builds:
+
+$builds
+
+It's been a while since your last update on SBo. Are you still
+maintaining these?
+
+Please let me know.
+EOF
+
+cat $tmpfile
+
+if [ "$interactive" = "yes" ]; then
+ echo
+ echo "===> Press Enter to send this email, ^C to abort."
+ read
+fi
+
+echo
+echo "==> Sending email to $TO_ADDR"
+cat $tmpfile | msmtp "$TO_ADDR"
+
+rm -f $tmpfile
diff --git a/admin/sbodeathrow b/admin/sbodeathrow
new file mode 100755
index 0000000..1e111c2
--- /dev/null
+++ b/admin/sbodeathrow
@@ -0,0 +1,171 @@
+#!/bin/bash
+
+# sbodeathrow by B. Watson <urchlay@slackware.uk>, WTFPL.
+# You shouldn't have to edit anything but SBO_GITROOT to make
+# this work (or just set it in the environment).
+
+# Default for $THRESH, in days. Don't change this; change THRESH, below.
+DEFTHRESH=180
+
+#######################################################################
+#### Configuration:
+
+# Where you keep your local git tree (which you must create yourself,
+# and keep up to date)
+SBO_GITROOT="${SBO_GITROOT:-/home/urchlay/sbogit}"
+
+# Builds orphaned >= $THRESH days ago will be removed (or just listed)
+THRESH=${THRESH:-${DEFTHRESH}}
+
+#### End of config
+#######################################################################
+
+SELF="$( basename $0 )"
+
+# For use with urchlay's git hooks. Ignore these if you don't
+# know what they're for.
+export NOAUTOCOMMIT=1
+export SBOLINT=no
+
+usage() {
+cat <<EOF
+$SELF - remove orphaned builds from the SBo repo.
+
+$SELF looks for builds that have been orphaned for more that $DEFTHRESH
+days, and (optionally) removes them with "git rm -rf", each in its own
+git commit.
+
+Builds that have dependees will not be removed, unless all the
+dependees have also been orphaned for >= $DEFTHRESH days. These builds
+will instead be listed on stderr, along with the dependee and its
+maintainer's name/email.
+
+Options:
+ --remove Actually remove the builds. Without this, builds that
+ would be removed are listed on stdout, but not removed.
+ --help Show this help message.
+
+Environment:
+ THRESH - threshold (in days) for deleting orphans. Default is $DEFTHRESH.
+ Please don't change this in production; it's only provided for testing.
+
+ SBO_GITROOT - where the local git clone of the SBo tree lives. This
+ script will *not* create the tree nor keep it up-to-date; use e.g.
+ "git clone" to create it, and "git pull" before each run.
+ Currently set to: $SBO_GITROOT
+EOF
+}
+
+die() {
+ echo "$SELF: fatal: $@" 2>&1
+ exit 1
+}
+
+warn() {
+ echo "$SELF: $@" 2>&1
+}
+
+set_cat_prg() {
+ category="$( echo $1 | cut -d/ -f1 )"
+ prgnam="$( echo $1 | cut -d/ -f2 )"
+}
+
+print_maint_info() {
+ local name="$( grep ^MAINTAINER $1/*.info | cut -d'"' -f2 )"
+ local email="$( grep ^EMAIL $1/*.info | cut -d'"' -f2 )"
+ echo "$name <$email>" 1>&2
+}
+
+# Return true if it's safe to remove the build $category/$prgnam.
+# It's not safe if it has dependees, unless all the dependees are
+# also going to be removed during this run.
+safe_to_remove() {
+ local catprg="$category/$prgnam"
+ # hoorex adds a trailing space...
+ local d="$( hoorex -l $prgnam | sed 's, *$,,' )"
+
+ if [ "$d" != "$catprg" ]; then
+ for i in $d; do
+ if [ "$i" != "$catprg" ]; then
+ if echo $INFOS | grep -q "\\<$i\\/"; then
+ #echo "$catprg: dependee $i exists, but is to be removed" 1>&2
+ : # NOP, don't print a message
+ else
+ echo -n "$catprg: can't remove due to dependee:" 1>&2
+ echo -n " $i: " 1>&2
+ print_maint_info $i
+ return 1 # false
+ fi
+ fi
+ done
+ fi
+ return 0 # remember, 0 is 'true' in bash!
+}
+
+# Die if hoorex isn't installed, or doesn't support --auto option
+check_hoorex_version() {
+ local hoohelp="$( hoorex --help || echo MISSING )"
+ [ "$hoohelp" = "MISSING" ] && die "hoorex not installed"
+ echo "$hoohelp" | grep -q -- --auto || \
+ die "hoorex too old (needs -a/--auto option; upgrade to >=0.10.4)"
+}
+
+# With --remove, remove a build. Otherwise, print a message to stdout
+# letting us know it would be removed.
+remove_build() {
+ local catprg="$1"
+ if [ "$REMOVE" = "1" ]; then
+ git rm -rf "$catprg" || die "$catprg: git rm command failed"
+ git commit -m"$catprg: Removed (orphaned >$THRESH days)." || die "$catprg: git commit failed"
+ warn "removed $catprg"
+ else
+ echo "$catprg"
+ fi
+}
+
+### main()
+case "$1" in
+ "") ;; # NOP
+ --remove) REMOVE=1 ;;
+ --help) usage; exit 0 ;;
+ *) die "unknown argument $1, try --help" ;;
+esac
+
+check_hoorex_version
+
+cd $SBO_GITROOT || die "edit script or set SBO_GITROOT in environment"
+[ -d academic/ -a -d system/ -a -d .git/ ] || \
+ die "$SBO_GITROOT is not a SBo git tree (set SBO_GITROOT)"
+
+case "$THRESH" in
+ [0-9]*) ;; # NOP
+ *) die "invalid THRESH '$THRESH' (non-numeric)"
+esac
+
+hoorex -a -s `pwd` >/dev/null || die "hoorex failed"
+
+thresh_sec="$( date -d "$THRESH days ago" +%s )"
+case "$thresh_sec" in
+ [1-9][0-9]*) ;; # OK, NOP
+ *) die "failed to get thresh_sec, coreutils too old or bad THRESH?" ;;
+esac
+
+INFOS="$( git grep -l '^EMAIL="NOEMAIL"' '*/*/*.info' )"
+
+if [ "$INFOS" = "" ]; then
+ # nothing to do!
+ warn "nothing to do; no orphaned builds in the repo at $SBO_GITROOT"
+ exit 0
+fi
+
+for infofile in $INFOS; do
+ set_cat_prg $infofile
+ orphaned_sec="$( git blame --porcelain -L/MAINTAINER/,+1 $infofile | grep ^author-time | cut -d' ' -f2 )"
+ if [ "$orphaned_sec" -lt "$thresh_sec" ]; then
+ if safe_to_remove; then
+ remove_build "$category/$prgnam"
+ fi
+ fi
+done
+
+exit 0