forked from postgis/postgis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_dist.sh
executable file
·153 lines (137 loc) · 3.48 KB
/
make_dist.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/sh
#
# USAGE:
#
# -- postgis-x.y.0dev-r#####.tar.gz
# sh make_dist.sh
#
# -- postgis-1.1.0.tar.gz
# sh make_dist.sh 1.1.0
#
# -- postgis-2.2.tar.gz (from a branch)
# sh make_dist.sh -b 2.2
#
# NOTE: will not work prior to 1.1.0
#
# ENVIRONMENT VARIABLES:
#
# CONFIGURE_ARGS passed to ./configure call
# MAKE useed for builds (defaults to "make")
# newoutdir this variable can be overriden to control the outdir and package name.
# package name will be set to {newoutdir}.tar.gz if this variabe is overridden
#
version=dev
# Define in environment if necessary to get postgis to configure,
# which is only done to build comments.
#CONFIGURE_ARGS=
# Define in environment if Gnu make is not make (e.g., gmake).
if [ "$MAKE" = "" ]; then
MAKE=make
fi
if [ -d ".git" ]; then
git=yes
# Extract tag from git or default to trunk
tag=`git branch | grep \* | awk '{print $2}'`
else
git=no
# Extract tag from svn or default to trunk
tag=`svn info 2> /dev/null | grep ^URL | sed 's/.*\///'`
[ -z "$tag" ] && tag=trunk
[ "$tag" != "trunk" ] && tag=branches/$tag
fi
if [ -n "$1" ]; then
if [ "$1" = "-b" ]; then
shift
if [ "$git" = "yes" ]; then
tag=svn-$1
else
tag="$1"
[ "$tag" != "trunk" ] && tag="branches/$tag"
fi
branch=yes
else
version="$1"
tag="tags/$version"
[ "$git" = "yes" ] && tag=$1
fi
fi
outdir="postgis-$version"
if [ -d "$outdir" ]; then
echo "Output directory $outdir already exists."
exit 1
fi
if [ "$git" = "no" ]; then
echo "Exporting tag $tag"
svnurl="http://svn.osgeo.org/postgis/$tag"
svn export $svnurl "$outdir"
if [ $? -gt 0 ]; then
exit 1
fi
else
git clone -b $tag . $outdir || exit 1
#cd $outdir
#git checkout $tag || exit 1
#cd -
fi
echo "Removing make_dist.sh and HOWTO_RELEASE"
rm -fv "$outdir"/make_dist.sh "$outdir"/HOWTO_RELEASE
# generating configure script and configuring
echo "Running autogen.sh; ./configure"
owd="$PWD"
cd "$outdir"
./autogen.sh
./configure ${CONFIGURE_ARGS}
# generating postgis_svn_revision.h for >= 2.0.0 tags
if test -f utils/svn_repo_revision.pl; then
echo "Generating postgis_svn_revision.h"
perl utils/svn_repo_revision.pl $svnurl
fi
#make
cd "$owd"
# generating comments
echo "Generating documentation"
owd="$PWD"
cd "$outdir"/doc
${MAKE} comments
if [ $? -gt 0 ]; then
exit 1
fi
${MAKE} clean # won't drop the comment files
cd "$owd"
# Run make distclean
echo "Running make distclean"
owd="$PWD"
cd "$outdir"
${MAKE} distclean
if [ "$git" = "yes" ]; then
echo "Removing .git dir"
rm -rf .git
fi
cd "$owd"
# Find a better version name when fetching
# a development branch
if test "$version" = "dev"; then
echo "Tweaking version for development snapshot"
VMAJ=`grep ^POSTGIS_MAJOR_VERSION "$outdir"/Version.config | cut -d= -f2`
VMIN=`grep ^POSTGIS_MINOR_VERSION "$outdir"/Version.config | cut -d= -f2`
VMIC=`grep ^POSTGIS_MICRO_VERSION "$outdir"/Version.config | cut -d= -f2`
VREV=`cat "$outdir"/postgis_svn_revision.h | awk '{print $3}'`
version="${VMAJ}.${VMIN}.${VMIC}-r${VREV}"
#if newoutdir is not already set, then set it
if test "x$newoutdir" = "x"; then
newoutdir=postgis-${version}
else
package=${newoutdir}.tar.gz
fi
rm -rf ${newoutdir}
mv -v "$outdir" "$newoutdir"
outdir=${newoutdir}
fi
#if package name is not already set then set it
if test "x$package" = "x"; then
package="postgis-$version.tar.gz"
fi
echo "Generating $package file"
tar czf "$package" "$outdir"
#echo "Cleaning up"
#rm -Rf "$outdir"