-
Notifications
You must be signed in to change notification settings - Fork 4
/
httpup-repgen
executable file
·84 lines (71 loc) · 1.73 KB
/
httpup-repgen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
# httpup-repgen - One way sync from an http server to a local directory
#
# Copyright 2003-2005 (c) Johannes Winkelmann, # [email protected]
#
# - Filtering code adapted from Per Liden's pkgmk
# - optimized and made portable (sh-compliant) by Han Boetes
# The repo file is place on the server. httpup downloads it,
# makes the update and afterwards moves it to the REPOCURRENTFILE
# which keeps track of the files which have been checked out. The
# REPOCURRENTFILE contains only file names
REPOFILE=REPO
REPOCURRENTFILE=REPO.CURRENT
VERSION=0.8
info()
{
echo $*
}
debug()
{
return # echo $*
}
printUsage()
{
cat << EOF
httpup-repgen $VERSION
Copyright (c) 2003 Johannes Winkelmann
Usage:
httpup-repgen [directory]
EOF
exit -1
}
generateRepoFile()
{
dir=${1:-.}
if [ ! -d $dir ]; then
echo "Can't generate repository for '$dir': No such directory"
exit -2
fi
echo "Generating repository for directory '$dir'"
OLDPWD=$PWD
cd $dir
rm -f $REPOFILE || exit -3
IGNORE_FILE=.httpup-repgen-ignore
if [ -r $HOME/$IGNORE_FILE ]; then
FILTER="grep -E -v -f $HOME/$IGNORE_FILE"
else
FILTER="cat"
fi
if [ -r $IGNORE_FILE ]; then
FILTER_LOCAL="grep -E -v -f $IGNORE_FILE"
else
FILTER_LOCAL="cat"
fi
FILTER_OWN="egrep -v ($REPOFILE|$REPOCURRENTFILE|$IGNORE_FILE)"
find . -type d ! -name . -printf "%P\n"|$FILTER|$FILTER_LOCAL|$FILTER_OWN|\
awk '{print "d:"$1}' > $REPOFILE
files="$(find . -type f -printf "%P\n"|$FILTER|$FILTER_LOCAL|$FILTER_OWN)"
if [ -n "$files" ]; then
echo $files|xargs md5sum|awk '{print "f:"$1":"$2}' >> $REPOFILE
fi
cd $OLDPWD
}
case $1 in
-*)
printUsage
;;
*)
generateRepoFile $1
;;
esac