forked from domogik/domoweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.sh
executable file
·93 lines (80 loc) · 2.03 KB
/
package.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
#!/bin/bash
BRANCH='default'
RELEASE='dev'
REV=$(hg id -n)
VERSION="$BRANCH-$RELEASE.$REV"
echo $VERSION
SHORT_VERSION="$BRANCH-$RELEASE"
ARCHIVE_NAME=domoweb-temp
ARCHIVE=/tmp/$ARCHIVE_NAME.tgz
POST_PROCESSING=/tmp/domoweb-post-$$
FINAL_ARCHIVE=/tmp/domoweb-$SHORT_VERSION.tgz
function generate_pkg() {
echo "Generate package..."
hg archive \
-p domoweb-$SHORT_VERSION \
-X re:package.*.sh \
-X .hgignore \
-X .hg_archival.txt \
-X .hgtags \
-t tgz $ARCHIVE
if [ $? -ne 0 ] ; then
echo "Error... exiting"
exit 1
fi
echo "Package successfully created : $ARCHIVE"
}
function extract() {
mkdir -p $POST_PROCESSING
cd $POST_PROCESSING
tar xzf $ARCHIVE
if [ $? -ne 0 ] ; then
echo "Error... exiting"
exit 1
fi
echo "Package extracted in post processing path : $POST_PROCESSING"
}
function force_install_mode() {
FILE=$POST_PROCESSING/domoweb-$SHORT_VERSION/install.sh
sed -i "s/^.*Which install mode do you want.*$/MODE=install/" $FILE
if [ $? -ne 0 ] ; then
echo "Error... exiting"
exit 1
fi
echo "install.sh updated : force install mode"
}
function set_release_number() {
FILE=$POST_PROCESSING/domoweb-$SHORT_VERSION/setup.py
sed -i "s/version = '.*',/version = '"$SHORT_VERSION"',/" $FILE
if [ $? -ne 0 ] ; then
echo "Error... exiting"
exit 1
fi
echo "setup.py : release number updated"
FILE2=$POST_PROCESSING/domoweb-$SHORT_VERSION/generate_revision.py
sed -i "s/ 'rev':.*/ 'rev':'$REV',/" $FILE2
if [ $? -ne 0 ] ; then
echo "Error... exiting"
exit 1
fi
echo "setup: release number updated"
}
function create_final_pkg() {
cd $POST_PROCESSING/
tar czf $FINAL_ARCHIVE *
if [ $? -ne 0 ] ; then
echo "Error... exiting"
exit 1
fi
echo "Final package generated : $FINAL_ARCHIVE"
}
function clean() {
rm -Rf $POST_PROCESSING
}
### main
generate_pkg
extract
force_install_mode
set_release_number
create_final_pkg
clean