-
Notifications
You must be signed in to change notification settings - Fork 10
/
_buildtool-7.2
executable file
·146 lines (126 loc) · 3.54 KB
/
_buildtool-7.2
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
#!/bin/sh
function usage()
{
cat <<EOF
Usage: `basename "$0"` /path/to/vim/source/x.y [ACTION+]
`basename "$0"` x.y [ACTION+]
In second case, x.y is searched in "standard" download locations.
Final directory must be of form major.minor (e.g., 7.2).
Valid ACTIONs are:
download - use rsync to download Vim sources
unpack - unpack Vim sources below CWD
configure - configure Vim with standard build options
build - build Vim and create binary tarball
If no ACTIONs are specified, defaults to unpack configure build.
EOF
}
function setup()
{
if [ -z "$1" ]; then
usage
exit
fi
for DIR in "$1" \
"~/download/programming/vim/$1" \
"/tools/software/vim/$1" \
"$1"; do
if [ -d "$DIR" ]; then
break
fi
done
if [ ! -d "$DIR" ]; then
echo "Cannot find source directory $DIR"
usage
exit
fi
VERSION=`basename "$DIR"`
VIMDIR=vim`echo $VERSION | sed 's/\.//'`
if ! echo $VERSION | grep -q '^[0-9]\+\.[0-9]\+$'; then
echo "Bad version in $DIR"
usage
exit
fi
echo "Vim $VERSION sources in $DIR"
}
function download()
{
SITE=ftp.nluug.nl::Vim
echo "Synchronizing Vim $VERSION into $DIR"
rsync -avzcP \
$SITE/unix/vim-$VERSION.tar.bz2 \
$SITE/extra/vim-$VERSION-extra.tar.gz \
$SITE/extra/vim-$VERSION-lang.tar.gz \
"$DIR"/
rsync -avzcP --delete --exclude="/dos/" $SITE/runtime/ "$DIR"/runtime/
rsync -avzcP --delete $SITE/patches/$VERSION/ "$DIR"/patches/
date > "$DIR"/LAST_RSYNC.txt
}
function unpack()
{
if [ -d "$VIMDIR" ]; then
echo "Must remove directory $VIMDIR manually before continuing"
exit
fi
echo "Unpacking Vim $VERSION..."
echo " Expanding tarballs..."
tar -jxf "$DIR"/vim-$VERSION.tar.bz2
tar -zxf "$DIR"/vim-$VERSION-extra.tar.gz
tar -zxf "$DIR"/vim-$VERSION-lang.tar.gz
echo " Applying patches..."
ls "$DIR"/patches/$VERSION.* | grep -v '\.gz$' | sort | xargs cat | \
(cd $VIMDIR; patch -sp0)
echo " Updating runtime/..."
rsync -ax --delete "$DIR"/runtime/ "$VIMDIR"/runtime/
}
function configure()
{
echo "Configuring in $VIMDIR..."
(
cd $VIMDIR;
./configure \
--quiet \
--with-features=huge \
--enable-perlinterp \
--enable-pythoninterp \
--enable-tclinterp \
--enable-rubyinterp \
--enable-cscope \
)
}
function patchlevel()
{
grep -A 3 '^static int included_patches' src/version.c |
tail -n 1 | perl -pe 's/^\s*(\d+).*/$1/'
}
function build()
{
echo "Building in $VIMDIR..."
(
cd $VIMDIR
echo " Removing DESTDIR..."
rm -rf DESTDIR
mkdir DESTDIR
TARNAME="vim-$VERSION.`patchlevel`.i386.tar.gz"
echo " Compiling Vim $VERSION.`patchlevel`..." && \
make && \
echo " Installing in DESTDIR..." && \
make install DESTDIR=`pwd`/DESTDIR && \
find DESTDIR -type d -print0 | xargs -0 chmod go-w && \
echo " Creating tar from DESTDIR" && \
tar -C DESTDIR --owner=root --group=root -zcf $TARNAME . && \
echo " Created archive $VIMDIR/$TARNAME"
)
}
setup "$1"
shift
if [ -z "$1" ]; then
unpack
configure
build
else
while [ -n "$1" ]; do
$1
shift
done
fi