[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commit-womb] gnumaint/pkgupdate from-maildir pkg-resolve
From: |
Mike Gerwitz |
Subject: |
[commit-womb] gnumaint/pkgupdate from-maildir pkg-resolve |
Date: |
Fri, 9 Nov 2018 22:51:47 -0500 (EST) |
CVSROOT: /sources/womb
Module name: gnumaint
Changes by: Mike Gerwitz <mikegerwitz> 18/11/09 22:51:46
Added files:
pkgupdate : from-maildir pkg-resolve
Log message:
pkgupdate: Adding WIP scripts
I wrote these ~4 months ago but forgot to commit them. They are a WIP.
I will continue their development within the next month or two.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnumaint/pkgupdate/from-maildir?cvsroot=womb&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnumaint/pkgupdate/pkg-resolve?cvsroot=womb&rev=1.1
Patches:
Index: from-maildir
===================================================================
RCS file: from-maildir
diff -N from-maildir
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ from-maildir 10 Nov 2018 03:51:46 -0000 1.1
@@ -0,0 +1,107 @@
+#!/bin/bash
+# $Id: from-maildir,v 1.1 2018/11/10 03:51:46 mikegerwitz Exp $
+# Produce version listing from info-gnu@ maildir entries
+#
+# Copyright (C) 2018 Mike Gerwitz
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+##
+
+set -uo pipefail
+
+mail-headers()
+{
+ awk -F': ' '
+ BEGIN { OFS="\t" }
+ /^(Date|Subject): / { h[$1] = $2 }
+ /^$/ { print h["Date"], h["Subject"] }'
+}
+
+
+datefmt()
+{
+ local -r date="${1?Missing date}"
+ date --date="$date" +%Y%m%d
+}
+
+
+normalize-subject()
+{
+ # perl used here in place of sed for non-greedy (lazy) matching
+ perl -pe '
+ # remove bracketed tags and common expressions
+ s/\[.+?\]//g;
+ s/\b(released?|version)\b( +of)?//ig;
+ s/\b(now )?available\b//ig;
+ s/(a )?\bnew\b//ig;
+ s/\b(re-?)?announc(ing|ement)( of)?\b//ig;
+ s/\bhas been\b//ig;
+ s/\bbug fix\b//ig;
+ s/\bthe\b//ig; # no package names have "the"
+
+ # swap form "VER of PKG" to "PKG VER"
+ s/(\b[0-9.]+) +of +(.+$)/\2 \1/;
+
+ # strip everything after the last (version?) number
+ s/^(.+?)[ -]+(?:v\.?|\()?([0-9.]+\b).*$/\2 \1/;
+
+ # strip tabs that would screw up our output and remove punctuation
+ s/[\t,]//g;
+ s/ +/ /g;'
+}
+
+
+pkg-guess()
+{
+ local -r subj="${1?Missing subject line}"
+ local ver pkg
+
+ # Attempt to get version and package from subject line
+ read ver pkg < <( normalize-subject <<< "$subj" )
+
+ # If it does not look like a version number, then we cannot
+ # proceed.
+ if [[ ! "$ver" =~ ^[0-9][0-9.]*$ ]]; then
+ echo "missing version: $subj" >&2
+ return 1
+ fi
+
+ # retain subject as metadata for human eyeballs
+ echo -e "$ver\t$pkg"
+}
+
+
+process-message()
+{
+ local -r message="${1?Missing message path}"
+ local date subj
+
+ IFS=$'\t' read date subj < <( mail-headers < "$message" )
+
+ local -r pkg=$( pkg-guess "$subj" )
+ test -n "$pkg" || return
+
+ echo -e "$( datefmt "$date" )\t$pkg\tmail\t$subj"
+}
+
+
+main()
+{
+ while [ $# -gt 0 ]; do
+ process-message "$1"
+ shift
+ done
+}
+
+main "$@"
Index: pkg-resolve
===================================================================
RCS file: pkg-resolve
diff -N pkg-resolve
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ pkg-resolve 10 Nov 2018 03:51:46 -0000 1.1
@@ -0,0 +1,74 @@
+#!/bin/bash
+# $Id: pkg-resolve,v 1.1 2018/11/10 03:51:46 mikegerwitz Exp $
+# Resolve package names from version listing
+#
+# Copyright (C) 2018 Mike Gerwitz
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# This script is slow, but that is not of practical importance for now.
+##
+
+cd "$( dirname "$0" )"
+
+set -euo pipefail
+
+recfile=../rec/gnupackages.rec
+
+
+find-pkg()
+{
+ local -r pkg="${1?Missing source package string}"
+ local -r op="${2:-=}"
+
+ local -r unix="${pkg//[^a-zA-Z0-9-]/}"
+
+ # TODO: error if multiple
+ local -r result=$(
+ recsel -iC \
+ -e "package $op '$unix' || mundane_name $op '$pkg' || search_alias
$op '$pkg'" \
+ -P package \
+ "$recfile" || echo "fail $pkg" >&2 )
+
+ test -n "$result" || return
+
+ # TODO: error if more than one
+ head -n1 <<< "$result"
+}
+
+
+resolve-pkg()
+{
+ local -r pkg="${1?Missing source package string}"
+ local -r clean=$( sed 's/^\(GNU\|FSF\) //i' <<< "$pkg" )
+
+ find-pkg "$pkg" = \
+ || find-pkg "$pkg" \~ \
+ || { test "$pkg" != "$clean" && resolve-pkg "$clean"; }
+}
+
+
+main()
+{
+ local date ver pkg src meta
+
+ while IFS=$'\t' read date ver pkg src meta; do
+ local respkg=$( resolve-pkg "$pkg" )
+ test -n "$respkg" || continue
+
+ echo -e "$date\t$ver\t$respkg\t$src\t$meta"
+ done
+}
+
+main "$@"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [commit-womb] gnumaint/pkgupdate from-maildir pkg-resolve,
Mike Gerwitz <=