forked from tcalmant/ipopo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
distribute.sh
executable file
·130 lines (106 loc) · 2.74 KB
/
distribute.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
export PYTHONPATH="."
HOST="ipopo.coderxpress"
REMOTE_DIR=www-ipopo
# iPOPO Version
VERSION="0.6.4"
# Directories
API_HTML="api"
API_PDF="api-pdf"
# Files
DIST_DIR="dist"
DIST_TGZ="iPOPO-$VERSION.tar.gz"
DIST_ZIP="ipopo-$VERSION.zip"
TEST_ZIP="ipopo-$VERSION-tests.zip"
HTML_ZIP="ipopo-$VERSION-doc-html.zip"
PDF_FILE="ipopo-$VERSION-doc.pdf"
PDF_ZIP="ipopo-$VERSION-doc-pdf.zip"
LATEST_DIST_LINK="ipopo-latest.zip"
LATEST_TEST_LINK="ipopo-latest-tests.zip"
LATEST_HTML_LINK="ipopo-latest-doc-html.zip"
LATEST_PDF_LINK="ipopo-latest-doc-pdf.zip"
# Generate the API
echo "API..."
echo "... HTML ..."
epydoc --html pelix -o "$API_HTML" || exit 1
echo "... PDF ..."
epydoc --pdf pelix -o "$API_PDF" || exit 1
# Compress API files
echo "API Compression..."
echo "... HTML ..."
zip -r "$HTML_ZIP" "$API_HTML" || exit 1
pushd $API_PDF
echo "... PDF ..."
mv "api.pdf" "$PDF_FILE"
zip "$PDF_ZIP" "$PDF_FILE" || exit 1
popd
mv "$API_PDF/$PDF_ZIP" . || exit 1
# Clean up API folders
echo "API clean up..."
rm -fr "$API_HTML"
rm -fr "$API_PDF"
# Test files
echo "Unit tests..."
find tests -name '*.py' -print | zip "$TEST_ZIP" -@
# Python distribution
echo "Python source distribution..."
python setup.py sdist
# Convert the .tgz file into a .zip file
pushd "$DIST_DIR"
echo "... Extracting ..."
tar xf $DIST_TGZ || exit 1
echo "... Adding license ..."
cp ../LICENSE "iPOPO-$VERSION"
echo "... Zipping ..."
zip -r "$DIST_ZIP" "iPOPO-$VERSION"
popd
mv "$DIST_DIR/$DIST_ZIP" .
# Clean up
echo "Clean up distribution..."
rm -fr $DIST_DIR
rm MANIFEST
# Send to CoderXpress
echo "Creating SFTP script..."
BATCH_FILE=$(mktemp)
REMOTE_SHELL="remote_dist_ipopo_$VERSION.sh"
files=("$HTML_ZIP" "$PDF_ZIP" "$DIST_ZIP" "$TEST_ZIP")
for file in ${files[@]}
do
echo "put '$file'" >> $BATCH_FILE
done
echo "put '$REMOTE_SHELL'" >> $BATCH_FILE
# Make the remote script
echo "Creating remote script..."
cat > "$REMOTE_SHELL" <<END
echo "Moving files..."
mkdir -p $REMOTE_DIR/dl
mv "$DIST_ZIP" "$REMOTE_DIR/dl/"
mv "$TEST_ZIP" "$REMOTE_DIR/dl/"
mv "$HTML_ZIP" "$REMOTE_DIR/dl/"
mv "$PDF_ZIP" "$REMOTE_DIR/dl/"
pushd $REMOTE_DIR
echo "Replacing API..."
rm -fr "$API_HTML"
unzip "dl/$HTML_ZIP"
echo "Making latest links..."
cd dl
ln -sf $DIST_ZIP $LATEST_DIST_LINK
ln -sf $TEST_ZIP $LATEST_TEST_LINK
ln -sf $HTML_ZIP $LATEST_HTML_LINK
ln -sf $PDF_ZIP $LATEST_PDF_LINK
popd
END
echo "Sending files..."
# Batch mode info :
# http://www.derkeiler.com/Newsgroups/comp.security.ssh/2007-06/msg00142.html
sftp -o "batchmode no" -b $BATCH_FILE $HOST
rm $BATCH_FILE
rm $REMOTE_SHELL
# Remote script
echo "Remote commands..."
ssh $HOST REMOTE_SHELL="$REMOTE_SHELL" "bash -s" <<'ENDSSH'
echo "On remote site - REMOTE SHELL = $REMOTE_SHELL"
bash "$REMOTE_SHELL"
rm "$REMOTE_SHELL"
ENDSSH
echo "All done"