#!/bin/sh
# Copyright for the Uniform Repository Service (c) 1995, 1996, 1997,
# 1998,
# by Gerald Banon. All rights reserved.
# Version 1.1
# update@z
a1=$1
umask 2
col=../../../../..
serv=dpi.inpe.br/banon/1995/08.08.00.00
echo ""
cp=`pwd` # cp (current path)
cd $col/..
hp=`pwd` # hp (home path)
cd $cp
if test -f .setenv/last_change
then
cat address | sort -u -o address
comm -23 address .setenv/last_change >.t/df # difference
comm -23 .setenv/last_change address >>.t/df
cat .t/df | egrep -v '^[ ]*$' >.t/ax # cut blank lines
cat .t/ax >.t/df
if test -s .t/df
then
cat .t/df | sed 's/,.*//' | sort -u | \
sed 's/^ *//
s/ /_/' >.t/ln # >.t/ln (last name)
fi
fi
cat $a1 >.t/i1
rm -f .t/add
while test -s .t/i1
do
cat .t/i1 | sed -n '1p' >.t/rp
set `cat .t/rp`; rp=$1 # rp
if test -d $col/$rp/bib
then
# first repository generation
# >
find \
$col/$rp/bib -newer $col/$rp/.reserved/last_change -print >.t/ax
if test -s .t/ax
then
set yes; update_bib=$1
# echo 1
else
if test -s .t/ln
then
ls -d $col/$rp/bib/* | egrep -f .t/ln >.t/ax
if test -s .t/ax
then
set yes; update_bib=$1
# echo 2
else
ls -dt \
$col/$rp $col/$rp/download $col/$rp/.reserved/last_change >.t/ax 2>.t/bx
cat .t/ax | \
sed '/.reserved\/last_change/,$d' >.t/bx
if test -s .t/bx
then
set yes; update_bib=$1
# echo 3
else
set no; update_bib=$1
# echo 4
fi
fi
else
ls -dt \
$col/$rp $col/$rp/download $col/$rp/.reserved/last_change >.t/ax 2>.t/bx
cat .t/ax | \
sed '/.reserved\/last_change/,$d' >.t/bx
if test -s .t/bx
then
set yes; update_bib=$1
# echo 5
else
set no; update_bib=$1
# echo 6
fi
fi
fi
find \
$col/$rp/bib/.@AV.html -newer $col/$rp/.reserved/last_change -print \
>.t/ax 2>.t/bx
if \
( test -s .t/ax || test ! -f $col/$rp/bib/.@AV.html ) && \
test -f ../$col/$serv/not_sent/.setenv/library_location
then
set yes; update_bib=$1
fi
# new link(s)
find \
$col/$rp/.reserved/link -newer $col/$rp/.reserved/last_change -print \
>.t/ax 2>.t/bx
if test -s .t/ax
then
set yes; new_link=$1
else
set no; new_link=$1
fi
find \
$col/$rp/doc -follow -newer $col/$rp/.reserved/last_change -print >.t/ax
if test -s .t/ax
then
set yes; update_doc=$1
else
set no; update_doc=$1
fi
find \
$col/$rp/bib/*/.h -newer $col/$rp/.reserved/last_change -print \
>.t/ax 2>.t/bx
if test -s .t/ax
then # see sr
set no; update_version=$1
else
set yes; update_version=$1
fi
# echo update_bib = $update_bib
# echo update_doc = $update_doc
# echo update_version = $update_version
if test $update_bib = yes || test $update_doc = yes || \
test ! -f .setenv/last_change || test $new_link = yes
then
echo updating $rp/bib ...
if test $update_doc = yes
then
# update the .reserved/ref file ------------
# if something in the doc directory has been changed
find $col/$rp/doc -follow -print >.t/find
cat .t/find | egrep '\.wk\.Z$' | \
awk '{ printf "cp %s .t/tmp/%s.Z; '\
'chmod +w .t/tmp/%s.Z; '\
'rm -f .t/tmp/%s; '\
'uncompress .t/tmp/%s.Z; '\
'cat .t/tmp/%s >>.t/f1\n", $1, NR, NR, NR, NR, NR }' >.t/d1
rm -f .t/f1
if test -s .t/d1
then
mkdir -p .t/tmp
chmod g+s .t/tmp
chmod +x .t/d1
.t/d1 # cp; uncompress;
# cat >>.t/f1
fi
cat .t/find | \
egrep '\.html$|\.ref$|\.wk$|\.tcl$|\.rtf$' | sed 's/$/" \\/' | \
sed 's/^/"/' >.t/e1
# with some special character we must write cat "../A&B"
if test -s .t/e1
then
echo 'cat \' >.t/e2
echo '>>.t/f1' >.t/e3
cat .t/e2 .t/e1 .t/e3 >.t/e4
chmod +x .t/e4
.t/e4 # cat >>.t/f1
fi
if test -f .t/f1
then
# chmod -f 666 $col/$rp/ref
# migration
# (April 12)
cat .t/f1 | \
egrep '../../../col/' | \
sed -n '/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/col\//p' | \
sed 's/^.*\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/col\///' | \
awk -F/ '{ printf "%s/%s/%s/%s\n", $1, $2, $3, $4 }' >.t/f2
cat .t/f1 | \
egrep 'NAME=repository_rel *VALUE="' | \
sed 's/^.*NAME=repository_rel *VALUE="//
s/"/\//' | \
awk -F/ '{ printf "%s/%s/%s/%s\n", $1, $2, $3, $4 }' >>.t/f2
cat .t/f2 | sort -u | \
grep -v $rp | grep -v '//' \
>$col/$rp/.reserved/ref # // because $i can be void
# cat .t/f2 | sort -u | \
#grep -v $rp | grep -v '//' | \
#awk '{ printf "%s\n", $1, $1 }' \
#>.t/f3 # // because $i can be void
#cat >$col/$rp/.reserved/ref <
#Relative references
#
#`cat .t/f3`
#