blob: 08f40b94094761fb54fd1d5c6dfddfc8ab0b0c47 (
plain)
1 #!/bin/bash
2 # httpup-repgen - One way sync from an http server to a local directory
3 # Copyright 2003 (c) Johannes Winkelmann, jw@tks6.net
4
5
6 # The repo file is place on the server. httpsync downloads it, makes the
7 # update and afterwards moves it to the REPOCURRENTFILE which keeps track
8 # of the files which have been checked out. The REPOCURRENTFILE contains
9 # only file names
10 REPOFILE=REPO
11 REPOCURRENTFILE=REPO.CURRENT
12
13 VERSION=0.5
14
15 function info(){
16 echo $*
17 }
18 function debug() {
19 return # echo $*
20 }
21
22 function printUsage() {
23 echo "httpup-repgen $VERSION"
24 echo " Copyright (c) 2003 Johannes Winkelmann"
25 echo ""
26 echo "Usage:"
27 echo " httpup-repgen [directory]"
28 exit -1
29 }
30
31 function generateRepoFile() {
32 dir="."
33 if [ ! "$1" = "" ]; then
34 dir=$1
35 fi
36 if [ ! -d $dir ]; then
37 echo "Can't generate repository for '$dir': No such directory"
38 exit -2
39 fi
40 echo "Generating repository for directory '$dir'"
41
42 OLDPWD=`pwd`
43 cd $dir
44 rm -f $REPOFILE || exit -3
45 touch $REPOFILE
46 if [ ! "$HS_IGNORE" = "" ]; then
47 ignore=$HS_IGNORE
48 ignore="-and $ignore"
49 debug "$ignore"
50 fi
51 for f in `find . -not -name \. $ignore`; do
52 f=`echo $f|sed -e 's/^\.\///'`
53 if [ "$f" == "$REPOFILE" ] || [ "$f" = "$REPOCURRENTFILE" ]; then
54 continue
55 elif [ -d $f ]; then
56 echo "d:$f" >> $REPOFILE
57 else
58 md5=`md5sum $f|awk '{print $1}'`
59 echo "f:$md5:$f" >> $REPOFILE
60 fi
61 done
62
63 cd $OLDPWD
64 }
65
66 if [ "$1" = "--help" ]; then
67 printUsage
68 else
69 generateRepoFile $1
70 fi
|