5 # Each note is just a file. Stored under /var/spool/admin/notes/[open|ack]/<package>/<note>
8 # note ack <note> - moves note to "acknowledged" spool
9 # note list [package] show notes for a given package, or all notes
10 # note delete <note> - delete a note from the system
11 # note edit <package> [file] - edit or create a note
14 # discard unchanged new note file
15 # quiet options to suppress new note name echo
16 # semi-quiet to just output the number
17 # renumber? to renumber all notes/reset sequence
19 # clean up unlocked temp files
21 : ${ZPMSPOOL:=/var/lib/admin/notes}
29 #cd $SPOOL || { echo "can't chdir to $SPOOL" ; exit 1; }
31 [ -z "$1" ] && set list
39 file=$(find $ZPMSPOOL -type f -name "$1")
40 if [ -z "$file" ] ; then
41 [ -z "$quiet" ] || printf "no such note $1\n" 1>&2
48 file=$(find $ZPMSPOOL/open -type f -name "$1")
49 if [ -z "$file" ] ; then
50 [ -z "$quiet" ] || printf "no such open note $1\n" 1>&2
58 notefile=$(findnote $1)
59 printf "%s\n" $(basename $(dirname $notefile))
63 -a) find $ZPMSPOOL/ack -type f -printf '%P\n' | sort -n
65 ?*) if [ -d $ZPMSPOOL/open/$1 ] ; then
66 find $ZPMSPOOL/open/$1 -type f -printf '%P\n' | sort -n
71 *) find $ZPMSPOOL/open -type f -printf '%P\n' | sort -n
76 len=$(find $ZPMSPOOL/open -type f -printf "%P\n" | awk ' { if ( length > x ) { x = length } }END{ print x }')
77 find $ZPMSPOOL/open -type f -printf "%P\n" | sort -n | while read note ; do
78 subject=$(head -1 $ZPMSPOOL/open/$note)
79 date=$(stat -c '%y' $ZPMSPOOL/open/$note | cut -f1 -d' ')
80 owner=$(stat -c '%U' $ZPMSPOOL/open/$note)
81 printf '%*s %8s %s %s\n' $len $note $owner "$date" "$subject"
86 subfile=$(echo $file | sed -e "s|$ZPMSPOOL/open/||")
87 filedir=$(dirname $subfile)
88 mkdir -p $ZPMSPOOL/ack/$filedir
89 mv $file $ZPMSPOOL/ack/$filedir
92 # new -- edit a new file for package general (or ZPMNOTEPACKAGE)
93 # new package -- edit a new note for package
94 # new package file -- use file for new package note
95 if [ $# -eq 0 ]; then set ${ZPMNOTEPACKAGE:-general}; fi
97 # edit a new file for the note
99 tmp=$(mktemp -p $ZPMSPOOL/open)
101 [ -f $ZPMSPOOL/.template ] && cp $ZPMSPOOL/.template $tmp
102 #flock -n -E3 $tmp vim $tmp
103 #if [ $? -eq 3 ]; then echo already editing $1; exit 1; fi
106 # take note from file or stdin
108 mkdir -p $ZPMSPOOL/open/$pkg
111 tmp=$(mktemp -p $ZPMSPOOL/open)
115 tmp=$(mktemp -p $ZPMSPOOL/open)
120 file=$(zpm sequence notes)
121 mkdir -p $ZPMSPOOL/open/$pkg
122 mv $tmp $ZPMSPOOL/open/$pkg/$file || { rm -f $tmp; exit 1; }
123 # TODO run newhooks in $ZPMSPOOL/.hook/newnote
129 flock -n -E3 $file vim $file
130 if [ $? -eq 3 ]; then echo already editing $1; exit 1; fi
145 echo '$0: unknown command ' $cmd 1>&2