3 #=======================================================================
5 # File ID: 6d23a156-5d3e-11df-9a9a-90e6ba3022ac
7 # Compile and install Vim
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
15 rcfile
="$HOME/.${progname}rc"
16 configure_opts
="--with-features=huge --with-x --enable-multibyte"
17 cloneurl
=https
://github.com
/vim
/vim.git
38 " -n "$progname" -- "$@
")"
39 test "$?" = "0" ||
exit 1
53 -h|
--help) opt_help
=1; shift ;;
54 -n|
--dry-run) opt_dry_run
=1; shift ;;
55 --no-install) opt_no_install
=1; shift ;;
56 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
57 -u|
--update) opt_update
=1; shift ;;
58 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
59 -y|
--yes) opt_yes
=1; shift ;;
60 --version) echo $progname $VERSION; exit 0 ;;
62 *) echo $progname: Internal error
>&2; exit 1 ;;
65 opt_verbose
=$
(($opt_verbose - $opt_quiet))
67 if test "$opt_help" = "1"; then
68 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
71 Compile and install Vim
73 Usage: $progname [options]
78 Remove lockdir before installing The Holy Editor.
82 Don't do anything, output commands that would be executed instead.
84 Exit after the tests have been run, don't install.
86 Be more quiet. Can be repeated to increase silence.
88 Fetch new commits and update the source code before starting the
91 Increase level of verbosity. Can be repeated.
93 Answer 'y' to all questions, perform an automated build. May cause
94 the script to hang if sudo is used and it's timed out.
96 Print version information.
98 If "$rcfile" exists, execute it before the compilation starts.
99 Use it to configure the build for each computer. For example:
104 will place everything below the ~/local directory and not use sudo.
106 These are the main variables to control the build:
109 Git URL to clone the source from if the \$srcdir directory
111 Default value: $cloneurl
113 Local name of cloned remote.
114 Default value: $remotename
116 Check out this branch after cloning the source from \$cloneurl.
117 Default value: $branch
119 Directory where the cloned source from \$cloneurl is stored.
120 Default value: \$HOME/src/other/vim
122 Top directory of the installed files.
123 Default value: /usr/local
125 Directory where the symlink of the current version is stored. Points
127 Default value: \$prefix/prg
129 Directory where the compiled files are installed.
130 Default value: \$prefix/varprg/vim-\$desc
132 Options passed to "./configure".
133 Default value: $configure_opts
135 Version number, you shouldn't need to touch this.
136 Default value is the output of "git describe --long --tags".
138 Owner of the \$prefix directory.
139 Default value is the output of "whoami". "make install" is not
140 executed as root to be sure that no files are installed outside
143 Group of the \$prefix directory.
144 Default value: Same as \$user.
146 Set to "1" or "true" if sudo(8) should be used. Any other value
155 test -e "$rcfile" && .
"$rcfile"
160 if test "$1" = "-n"; then
161 # If -n is first argument, don't terminate with \n
165 if test "$1" = "-s"; then
166 # If -s is specified, skip initial \n
171 echo $no_lf "$progname: $*" >&2
175 if test $
(tput cols
) -lt 80 -o $
(tput lines
) -lt 24; then
176 echo $progname: The tests need screen size
80x24 or
more to run
>&2
180 lockdir
="$HOME/.$progname.LOCK"
182 if test "$opt_f" = "1"; then
187 if test "$opt_dry_run" = "1"; then
189 sim_str
=" (Simulated)"
193 rmdir "$lockdir" || msg
-s $lockdir: Cannot remove lockdir
197 if test "$opt_yes" = "1"; then
201 until test "$choice_y" = "y"; do
203 test "$choice_y" = "n" && exit 0
204 if test "$choice_y" != "y"; then
205 msg
-n -s "Please press 'y' or 'n': "
212 mkdir
"$lockdir" ||
{
213 msg
-s $lockdir: Lockdir exists
, aborting
219 srcdir
="$HOME/src/other/vim"
221 if test ! -d "$srcdir/READMEdir"; then
222 msg
-s $srcdir/ doesn
\'t exist
, clone it
&&
223 msg
-n -s "from $cloneurl (y/n)?$sim_str " &&
225 $sim git clone
-o "$remotename" $cloneurl "$srcdir" &&
227 $sim git checkout
"$branch" &&
232 if test "$sim" = "echo"; then
233 msg
$srcdir doesn
\'t exist
,
234 msg
-s values of \
$desc and \
$destdir are not shown correctly.
235 msg
-s Not a problem
, since we
\'re only simulating.
249 test "$sudo" = "1" -o "$sudo" = "true" && sudo
=sudo ||
unset sudo
251 if test "$sim" != "echo"; then
252 test -z "$(git status --porcelain)" ||
{
253 msg
-s $srcdir is not clean
256 msg
-n Press
\'y
\' to clean it
, or
\'n
\' to abort...
263 if test "$opt_update" = "1"; then
264 $sim git fetch origin
265 $sim git merge
--ff-only
268 desc
="$(git describe --long --tags)"
269 destdir
="$prefix/varprg/vim-$desc"
271 if test "$opt_no_install" != "1"; then
272 test -e "$destdir" && {
273 $sim $sudo rmdir "$destdir" ||
{
274 msg
-s $destdir already exists
280 test "$opt_no_install" = "1" && butnot_str
=", but not" || butnot_str
=" and"
282 Going to compile$butnot_str install "vim-$desc"$sim_str
284 cloneurl = "$cloneurl"
285 remotename = "$remotename"
291 configure_opts = "$configure_opts"
298 echo -n If that looks OK
, press
\'y
\' to start the build or
\'n
\' to abort...
301 if test "$opt_no_install" != "1"; then
302 msg mkdir and chown
$destdir &&
303 $sim $sudo mkdir
-p "$destdir" &&
304 $sim $sudo chown
"$user".
"$group" "$destdir" &&
306 msg mkdir
-p $prefix/share
/man
/man1
&&
307 $sim mkdir
-p "$prefix/share/man/man1" &&
309 msg mkdir
-p $prefix/bin
&&
310 $sim mkdir
-p "$prefix/bin" ||
exit 1
315 msg git clean
in $srcdir/ &&
316 $sim git clean
-fxd &&
318 msg .
/configure
$configure_opts &&
319 $sim .
/configure
--prefix="$destdir" $configure_opts &&
326 test "$opt_no_install" != "1" &&
332 msg Update the vim symlink
in $prgdir/ &&
333 $sim $sudo ln -fnsv "../varprg/vim-$desc" vim
&&
335 $sim cd "$prefix/share/man/man1" &&
336 msg Create manpage symlinks
in $prefix/share
/man
/man
1/ &&
337 $sim $sudo ln -fnsv ..
/..
/..
/prg
/vim
/share
/man
/man
1/* .
&&
339 $sim cd "$prefix/share" &&
340 msg Create
$prefix/share
/vim symlink
&&
341 $sim $sudo ln -fnsv ..
/prg
/vim
/share
/vim .
&&
343 $sim cd "$prefix/bin" &&
344 msg Create symlinks
in $prefix/bin
/ &&
345 $sim $sudo ln -fnsv ..
/prg
/vim
/bin
/* .
&&
347 if test -d "$prefix/.git/."; then
348 msg Commit the symlink
&&
350 echo $progname installed vim-
$desc on $
(hostname
)
351 if suuid
--version 2>/dev
/null |
grep -q "^suuid v"; then
353 $sim suuid
-t commit
,$progname
357 $sim $sudo git add vim
&&
358 echo Commit message
: &&
360 $sim $sudo git commit
-m "$commitmsg"
364 msg Successfully installed vim-
$desc$sim_str
367 if test "$opt_no_install" = "1"; then
368 msg
--no-install is used
, skipping
install
371 msg Something went bananas
378 # vim: set ts=4 sw=4 sts=4 et fenc=utf8 :