summaryrefslogtreecommitdiff
path: root/archives/bin
diff options
context:
space:
mode:
authorAlvaro Herrera2008-08-31 05:12:06 +0000
committerAlvaro Herrera2008-08-31 05:12:06 +0000
commit0799581dddf14cbc707de3e7bd94344bba543b74 (patch)
treef606e85ec2206fc90adb16588086ae9180ac9195 /archives/bin
parent7f5c3f98942564953b69cd41112d3890218c5c3c (diff)
Improve script so that it generates a single file containing all needed info.
git-svn-id: file:///Users/dpage/pgweb/svn-repo/trunk@2187 8f5c7a92-453e-0410-a47f-ad33c8a6b003
Diffstat (limited to 'archives/bin')
-rwxr-xr-xarchives/bin/generate-list-descriptions22
1 files changed, 10 insertions, 12 deletions
diff --git a/archives/bin/generate-list-descriptions b/archives/bin/generate-list-descriptions
index cf92b2f7..28f78bb4 100755
--- a/archives/bin/generate-list-descriptions
+++ b/archives/bin/generate-list-descriptions
@@ -22,10 +22,14 @@ done
prevgrp=
curr=0
-psql_exec "select lg.id, lg.name, l.name from listgroups lg join lists l on (lg.id = l.grp) order by sortkey, l.name" |
+> $ARCHIVES_TEMPLATES/groups.new
+> $ARCHIVES_TEMPLATES/groups.complete.new
+psql_exec "select lg.id, lg.name, l.name, l.description from listgroups lg join lists l on (lg.id = l.grp) order by sortkey, l.name" |
while read line; do
# strip backslashes
line=${line//\\/}
+ descr=${line##[^|]*\|}
+ line=${line%%\|$descr}
list=${line##[^|]*\|}
line=${line%%\|$list}
grp=${line##[^|]*\|}
@@ -33,19 +37,13 @@ while read line; do
if [ "$grp" != "$prevgrp" ]; then
curr=$(($curr+1))
filename=$ARCHIVES_TEMPLATES/group.$curr
+ echo "group.$curr" >> $ARCHIVES_TEMPLATES/groups.new
echo "groupname: $grp" > $filename
+ echo "groupname: $grp" >> $ARCHIVES_TEMPLATES/groups.complete.new
prevgrp=$grp
fi
echo "list: $list" >> $filename
+ echo "list: $list $descr" >> $ARCHIVES_TEMPLATES/groups.complete.new
done
-
-# Protect against there being existing files (I assume creating new groups and
-# deleting them right away is going to be a very infrequent operation, but it
-# seems better to be prepared). We don't remove all files, just make sure we
-# leave a gap in the numbering. Thus any script which is going to use the
-# output of this one needs to make sure it stops processing files as soon as it
-# finds a hole in the sequence. NOTE: this feels bogus, but I don't see a
-# better way that doesn't involve a "rm group.*", which we don't want to do
-# (consider what happens if the psql query doesn't work for some reason ...)
-curr=$(($curr+1))
-rm $ARCHIVES_TEMPLATES/group.$curr
+mv $ARCHIVES_TEMPLATES/groups.new $ARCHIVES_TEMPLATES/groups
+mv $ARCHIVES_TEMPLATES/groups.complete.new $ARCHIVES_TEMPLATES/groups.complete