-
Notifications
You must be signed in to change notification settings - Fork 0
/
snapshot.sh
executable file
·81 lines (71 loc) · 2.37 KB
/
snapshot.sh
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
#!/bin/bash
ROOT=$(cd $(dirname $0); pwd)
DATE="$(date +"%Y-%m-%d")"
NAME=hachoir-snapshot-$DATE
TMPDIR=/tmp/$NAME
if test $# -eq 0; then
echo >>/dev/stderr "usage: $0 [--win32] component1 component2 ..."
echo >>/dev/stderr
echo >>/dev/stderr "component: metadata, urwid, ... (core and parser are always included)"
exit 1
fi
echo "[+] Prepare destination"
rm -rf "$TMPDIR"
mkdir -p "$TMPDIR"
WIN32=0
WITHTEST=1
COMPONENTS=""
TOOLS=1
for component in core parser $*; do
if [ "$component" = "--win32" ]; then
WIN32=1
else
COMPONENTS="$COMPONENTS $component"
fi
done
for component in $COMPONENTS; do
echo "[+] svn export hachoir-$component"
svn export "$ROOT/hachoir-$component/hachoir_$component" "$TMPDIR/hachoir_$component"
if [ -e "$ROOT/hachoir-$component/hachoir-$component" ]; then
echo "[+] copy hachoir-$component script"
if [ $WIN32 -eq 1 ]; then
cp "$ROOT/hachoir-$component/hachoir-$component" "$TMPDIR/hachoir-$component.py"
else
cp "$ROOT/hachoir-$component/hachoir-$component" "$TMPDIR/hachoir-$component"
fi
fi
if [ -e "$ROOT/hachoir-$component/README" ]; then
echo "[+] copy README.hachoir-$component"
if [ $WIN32 -eq 1 ]; then
# TODO: Convert Unix EOL to Windows EOL
sed -e 's/$/\r/g' "$ROOT/hachoir-$component/README" > "$TMPDIR/README.hachoir-$component.txt"
else
cp "$ROOT/hachoir-$component/README" "$TMPDIR/README.hachoir-$component"
fi
fi
done
if [ $WIN32 -eq 0 -a $WITHTEST -eq 1 ]; then
echo "[+] Include tests"
cp hachoir-parser/tests/download_testcase.py $TMPDIR/
cp hachoir-parser/tests/run_testcase.py $TMPDIR/test_parser.py
cp hachoir-metadata/run_testcase.py $TMPDIR/test_metadata.py
cp test_code_snapshot.sh $TMPDIR/testall.sh
fi
# Include some tools
if [ $TOOLS -eq 1 ]; then
cp hachoir-tools/hachoir-grep $TMPDIR/
cp hachoir-tools/hachoir-strip $TMPDIR/
fi
if [ $WIN32 -eq 1 ]; then
ARCHIVE=$ROOT/$NAME.zip
rm -f $ARCHIVE
echo "[+] Create archive $(basename $ARCHIVE)"
(cd $(dirname $TMPDIR); zip -9 -r $ARCHIVE $(basename $TMPDIR)/)
else
ARCHIVE=$ROOT/$NAME.tar.bz2
echo "[+] Create archive $(basename $ARCHIVE)"
(cd $(dirname $TMPDIR); tar -cjf $ARCHIVE $(basename $TMPDIR)/)
fi
rm -rf $TMPDIR
echo
echo "Done: snapshot is $ARCHIVE"