commit-womb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commit-womb] gnumaint/rec gnupackages2txt.awk


From: Mike Gerwitz
Subject: [commit-womb] gnumaint/rec gnupackages2txt.awk
Date: Sun, 17 Jun 2018 01:24:07 -0400 (EDT)

CVSROOT:        /sources/womb
Module name:    gnumaint
Changes by:     Mike Gerwitz <mikegerwitz>      18/06/17 01:24:07

Modified files:
        rec            : gnupackages2txt.awk 

Log message:
        Summary: rec/gnupackages2txt.awk: Essentially complete
        
        This script is functionally complete and its output has been compared 
with
        that of the existing gnupackages.txt; inconsistencies that remain are 
minor
        and are acceptable.
        
        I just need to do some minor cleanup/commenting and then I'll integrate 
this
        into the Makefile and remove gnupackages.txt from the repo.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnumaint/rec/gnupackages2txt.awk?cvsroot=womb&r1=1.1&r2=1.2

Patches:
Index: gnupackages2txt.awk
===================================================================
RCS file: /sources/womb/gnumaint/rec/gnupackages2txt.awk,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- gnupackages2txt.awk 15 Jun 2018 04:05:40 -0000      1.1
+++ gnupackages2txt.awk 17 Jun 2018 05:24:07 -0000      1.2
@@ -1,4 +1,4 @@
-# $Id: gnupackages2txt.awk,v 1.1 2018/06/15 04:05:40 mikegerwitz Exp $
+# $Id: gnupackages2txt.awk,v 1.2 2018/06/17 05:24:07 mikegerwitz Exp $
 # gnupackages.rec to old gnupackages.txt
 #
 #  Copyright (C) 2018 Mike Gerwitz
@@ -25,6 +25,11 @@
     FS = OFS = ": "
 }
 
+{
+    key   = is_key() ? $1 : ""
+    value = $2
+}
+
 # recfile headers (replace the first one with a warning)
 /^%rec:/ {
     print "# THIS FILE IS NOW GENERATED FROM rec/gnupackages.rec;"
@@ -32,21 +37,30 @@
 }
 /^%/ { next }
 
-$1 == "package" {
-    package = $1
-}
-$1 && $2 {
-    set_key( package, $1, $2 )
+is_key_assign() {
+    add_key( key, value )
 }
 
-$1 ~ /^last_release/ { next }
-$1 == "activity_status" || $1 == "last_activity" { next }
+key == "package"         { package = value }
+key == "blurb_id"        { next }
+key == "activity_status" { next }
+key == "last_activity"   { next }
+key == "container"       { next }
+key == "last_contact"    { next }  # output at end (reorder)
+key == "next_contact"    { next }  # output at end (reorder)
+key == "note"            { next }  # output at end (reorder)
+key ~ /^last_release/    { next }
 
 # end of package block
-!$1 && package {
-    print "activity-status", activity( package )
+eob() {
+    print "activity-status", mkactivity()
+    printkey( "last_contact" )
+    printkey( "next_contact" )
+    printnotes()
 
     package = ""
+    delete pkginfo
+    delete pkginfon
 }
 
 {
@@ -56,30 +70,105 @@
 }
 
 
+# key abstractions and predicates
+function is_key()        { return $1 ~ /^[a-z_]+$/ }
+function is_key_assign() { return is_key() && value }
+function eob()           { return $0 ~ /^$/ && package }
+function is_symnote()    { return get_key( "note" ) ~ /^[a-z-]+$/ }
+
+
+function printkey( k,   n, i )
+{
+    n = keylen( k )
+
+    for ( i = 0; i < n; i++ ) {
+        print gensub( /_/, "-", "g", k ), get_key( k, i )
+    }
+}
+
+function printnotes()
+{
+    if ( is_symnote() ) {
+        return
+    }
+
+    printkey( "note" )
+}
+
+
 # TODO: handle multiple versions (will need to track multiple 
last_release{,_date})
-function activity( pkgid,  status, last )
+function mkactivity()
 {
-    status = get_key( pkgid, "activity_status" )
-    last   = get_key( pkgid, "last_activity" )
+    return mkstatus() mkrelease()
+}
+
 
-    if ( status == "newcomaint" ) {
-        status = status "/" last
+function mkstatus(    status, last_act )
+{
+    status   = get_key( "activity_status" )
+    last_act = get_key( "last_activity" )
+
+    switch ( status )
+    {
+        case "newmaint":
+        case "newcomaint":
+        case "newpkg":
+        case "nomaint":
+            status = status "/" last_act
+            break;
+
+        case "container":
+            status = status " " get_key( "container" )
+            break;
     }
 
-    return status " " \
-        get_key( pkgid, "last_release_date" ) \
-        " (" get_key( pkgid, "last_release" ) ")"
+    # notes that look like symbols were taken from the
+    # old activity-status, so re-add them
+    if ( is_symnote() ) {
+        status = status " " get_key( "note" )
+    }
+
+    return status;
 }
 
 
-# TODO: support multiple values for the same key (see above TODO)
-function set_key( pkgid, key, value )
+function mkrelease(    last_date, last_ver, release, i )
 {
-    pkginfo[pkgid][key] = value
+    i = keylen( "last_release" ) - 1
+
+    if ( i == -1 ) {
+        return ""
+    }
+
+    # begin string with latest version number (last index)
+    release = sprintf( " %d (%s",
+                       get_key( "last_release_date", i ),
+                       get_key( "last_release", i ) )
+
+    # all other releases, if any
+    while ( i-- > 0 ) {
+        release = sprintf( "%s, %s/%d",
+                           release,
+                           get_key( "last_release", i ),
+                           get_key( "last_release_date", i ) )
+    }
+
+    return release ")"
+}
+
+
+function add_key( k, v,   i )
+{
+    i = pkginfon[k]++;
+    pkginfo[k][i] = v
 }
 
+function get_key( k, i )
+{
+    return pkginfo[k][ or( i, 0 ) ]
+}
 
-function get_key( pkgid, key )
+function keylen( k )
 {
-    return pkginfo[pkgid][key]
+    return pkginfon[k]
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]