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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
|
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/vim.eclass,v 1.72 2004/09/20 17:12:01 usata Exp $
# Authors:
# Ryan Phillips <rphillips@gentoo.org>
# Seemant Kulleen <seemant@gentoo.org>
# Aron Griffis <agriffis@gentoo.org>
# Ciaran McCreesh <ciaranm@gentoo.org>
# This eclass handles vim, gvim and vim-core. Starting with vim 7, it will also
# handle kvim. Support for -cvs ebuilds is included in the eclass, since it's
# rather easy to do, but there are no official vim*-cvs ebuilds in the tree.
# gvim's GUI preference order is as follows:
# carbon CARBON (not yet)
# -carbon gtk gtk2 gnome GNOME2 (6.3-r1+, earlier uses GTK2)
# -carbon gtk gtk2 -gnome GTK2
# -carbon gtk -gtk2 gnome GNOME1
# -carbon gtk -gtk2 -gnome GTK1
# -carbon -gtk motif MOTIF
# -carbon -gtk -motif ATHENA
inherit eutils vim-doc flag-o-matic versionator
# Support -cvs ebuilds, even though they're not in the official tree.
MY_PN="${PN%-cvs}"
# This isn't a conditional inherit from portage's perspective, since $MY_PN is
# constant at cache creation time. It's therefore legal and doesn't break
# anything. I even checked with carpaski first :) (08 Sep 2004 ciaranm)
if [[ "${MY_PN}" != "vim-core" ]] ; then
inherit debug
fi
if [[ "${PN##*-}" == "cvs" ]] ; then
inherit cvs
fi
ECLASS=vim
INHERITED="$INHERITED $ECLASS"
EXPORT_FUNCTIONS src_unpack
IUSE="$IUSE selinux ncurses nls acl"
if [[ "${MY_PN}" != "vim-core" ]] ; then
IUSE="$IUSE cscope gpm perl python ruby"
DEPEND="$DEPEND
cscope? ( dev-util/cscope )
gpm? ( >=sys-libs/gpm-1.19.3 )
perl? ( dev-lang/perl )
python? ( dev-lang/python )
selinux? ( sys-libs/libselinux )
acl? ( sys-apps/acl )
ruby? ( virtual/ruby )"
RDEPEND="$RDEPEND
cscope? ( dev-util/cscope )
gpm? ( >=sys-libs/gpm-1.19.3 )
perl? ( dev-lang/perl )
python? ( dev-lang/python )
selinux? ( sys-libs/libselinux )
acl? ( sys-apps/acl )
ruby? ( virtual/ruby )"
if [[ "${MY_PN}" == "vim" ]] ; then
IUSE="$IUSE vim-with-x minimal"
DEPEND="$DEPEND vim-with-x? ( virtual/x11 )"
RDEPEND="$RDEPEND vim-with-x? ( virtual/x11 )"
elif [[ "${MY_PN}" == "gvim" ]] ; then
IUSE="$IUSE gnome gtk gtk2 motif"
fi
fi
HOMEPAGE="http://www.vim.org/"
SLOT="0"
LICENSE="vim"
# Portage dependancy is for use_with/use_enable.
# ctags dependancy allows help tags to be rebuilt properly, along
# with detection of exuberant-ctags by configure.
DEPEND="$DEPEND
>=sys-apps/portage-2.0.45-r3
>=sys-apps/sed-4
sys-devel/autoconf
ncurses? ( >=sys-libs/ncurses-5.2-r2 )
!ncurses? ( sys-libs/libtermcap-compat )
dev-util/ctags
"
RDEPEND="$RDEPEND
ncurses? ( >=sys-libs/ncurses-5.2-r2 )
!ncurses? ( sys-libs/libtermcap-compat )
dev-util/ctags
"
apply_vim_patches() {
local p
cd ${S} || die "cd ${S} failed"
# Scan the patches, applying them only to files that either
# already exist or that will be created by the patch
einfo "Filtering vim patches..."
p=${WORKDIR}/${VIM_ORG_PATCHES%.tar*}.patch
ls ${WORKDIR}/vimpatches | sort | \
while read f; do gzip -dc ${WORKDIR}/vimpatches/${f}; done | awk '
/^Subject: Patch/ {
if (patchnum) {printf "\n" >"/dev/stderr"}
patchnum = $3
printf "%s:", patchnum >"/dev/stderr"
}
$1=="***" && $(NF-1)~/^[0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/ {
# First line of a patch; suppress printing
firstlines = $0
next
}
$1=="---" && $(NF-1)~/^[0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/ {
# Second line of a patch; try to open the file to see
# if it exists.
thisfile = $2
if (!seen[thisfile] && (getline tryme < thisfile) == -1) {
# Check if it will be created
firstlines = firstlines "\n" $0
getline
firstlines = firstlines "\n" $0
getline
if ($0 != "*** 0 ****") {
# Non-existent and not created, stop printing
printing = 0
printf " (%s)", thisfile >"/dev/stderr"
next
}
}
# Print the previous lines and start printing
print firstlines
printing = 1
printf " %s", thisfile >"/dev/stderr"
# Remember that we have seen this file
seen[thisfile] = 1
}
printing { print }
END { if (patchnum) {printf "\n" >"/dev/stderr"} }
' > ${p} || die
# For reasons yet unknown, epatch fails to apply this cleanly
ebegin "Applying filtered vim patches..."
TMPDIR=${T} patch -f -s -p0 < ${p}
eend 0
}
vim_src_unpack() {
unpack ${A}
if [[ "${PN##*-}" == "cvs" ]] ; then
ECVS_SERVER="cvs.sourceforge.net:/cvsroot/vim"
ECVS_PASS=""
ECVS_MODULE="vim"
ECVS_TOP_DIR="${DISTDIR}/cvs-src/${ECVS_MODULE}"
cvs_src_unpack
else
# Apply any patches available from vim.org for this version
[[ -n "$VIM_ORG_PATCHES" ]] && apply_vim_patches
# Unpack the runtime snapshot if available (only for vim-core)
if [[ -n "$VIM_RUNTIME_SNAP" ]] ; then
cd ${S} || die
ebegin "Unpacking vim runtime snapshot"
rm -rf runtime
bzip2 -dc ${DISTDIR}/${VIM_RUNTIME_SNAP} | tar xf -
assert # this will check both parts of the pipeline; eend would not
eend 0
fi
fi
# Another set of patches borrowed from src rpm to fix syntax errors etc.
cd ${S} || die "cd ${S} failed"
EPATCH_SUFFIX="gz" EPATCH_FORCE="yes" \
epatch ${WORKDIR}/gentoo/patches-all/
# Fixup a script to use awk instead of nawk
sed -i '1s|.*|#!/usr/bin/awk -f|' ${S}/runtime/tools/mve.awk \
|| die "mve.awk sed failed"
# Patch to build with ruby-1.8.0_pre5 and following
sed -i 's/defout/stdout/g' ${S}/src/if_ruby.c
# Read vimrc and gvimrc from /etc/vim
echo '#define SYS_VIMRC_FILE "/etc/vim/vimrc"' >> ${S}/src/feature.h
echo '#define SYS_GVIMRC_FILE "/etc/vim/gvimrc"' >> ${S}/src/feature.h
# Use exuberant ctags which installs as /usr/bin/exuberant-ctags.
# Hopefully this pattern won't break for a while at least.
# This fixes bug 29398 (27 Sep 2003 agriffis)
sed -i 's/\<ctags\("\| [-*.]\)/exuberant-&/g' \
${S}/runtime/doc/syntax.txt \
${S}/runtime/doc/tagsrch.txt \
${S}/runtime/doc/usr_29.txt \
${S}/runtime/menu.vim \
${S}/src/configure.in || die 'sed failed'
# Don't be fooled by /usr/include/libc.h. When found, vim thinks
# this is NeXT, but it's actually just a file in dev-libs/9libs
# This fixes bug 43885 (20 Mar 2004 agriffis)
sed -i 's/ libc\.h / /' ${S}/src/configure.in || die 'sed failed'
}
src_compile() {
local myconf confrule
# Fix bug 37354: Disallow -funroll-all-loops on amd64
# Bug 57859 suggests that we want to do this for all archs
filter-flags -funroll-all-loops
# Fix bug 18245: Prevent "make" from the following chain:
# (1) Notice configure.in is newer than auto/configure
# (2) Rebuild auto/configure
# (3) Notice auto/configure is newer than auto/config.mk
# (4) Run ./configure (with wrong args) to remake auto/config.mk
sed -i 's/ auto.config.mk:/:/' src/Makefile || die "Makefile sed failed"
rm -f src/auto/configure
# vim-6.2 changed the name of this rule from auto/configure to autoconf
confrule=auto/configure
grep -q ^autoconf: src/Makefile && confrule=autoconf
# autoconf-2.13 needed for this package -- bug 35319
# except it seems we actually need 2.5 now -- bug 53777
WANT_AUTOCONF_2_5=yes WANT_AUTOCONF=2.5 \
make -C src $confrule || die "make $confrule failed"
# This should fix a sandbox violation (see bug 24447)
for file in /dev/pty/s* /dev/console; do
addwrite $file
done
if [[ "${MY_PN}" == "vim-core" ]] ||
( [[ "${MY_PN}" == "vim" ]] && use minimal ); then
myconf="--with-features=tiny \
--enable-gui=no \
--without-x \
--disable-perlinterp \
--disable-pythoninterp \
--disable-rubyinterp \
--disable-gpm"
else
use debug && append-flags "-DDEBUG"
myconf="--with-features=huge \
--enable-multibyte"
myconf="${myconf} `use_enable cscope`"
myconf="${myconf} `use_enable gpm`"
myconf="${myconf} `use_enable perl perlinterp`"
myconf="${myconf} `use_enable python pythoninterp`"
myconf="${myconf} `use_enable ruby rubyinterp`"
# tclinterp is broken; when you --enable-tclinterp flag, then
# the following command never returns:
# VIMINIT='let OS=system("uname -s")' vim
#myconf="${myconf} `use_enable tcl tclinterp`"
# --with-features=huge forces on cscope even if we --disable it. We need
# to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
if ! use cscope ; then
sed -i -e '/# define FEAT_CSCOPE/d' src/feature.h || \
die "couldn't disable cscope"
fi
if [[ "${MY_PN}" == "vim" ]] ; then
# don't test USE=X here... see bug #19115
# but need to provide a way to link against X... see bug #20093
myconf="${myconf} --enable-gui=no `use_with vim-with-x x`"
elif [[ "${MY_PN}" == "gvim" ]] ; then
myconf="${myconf} --with-vim-name=gvim --with-x"
# prior to gvim 6.3-r1 we do things a bit strangely
if version_is_at_least "6.3-r1" ; then
if use gtk ; then
if use gtk2 ; then
myconf="${myconf} --enable-gtk2-check"
if use gnome ; then
einfo "Building gvim with the GNOME 2 GUI"
myconf="${myconf} --enable-gui=gnome2"
else
einfo "Building gvim with the gtk+-2 GUI"
myconf="${myconf} --enable-gui=gtk2"
fi
else
if use gnome ; then
einfo "Building gvim with the GNOME 1 GUI"
myconf="${myconf} --enable-gui=gnome"
else
einfo "Building gvim with the gtk+-1.2 GUI"
myconf="${myconf} --enable-gui=gtk"
fi
fi
elif use motif ; then
einfo "Building gvim with the MOTIF GUI"
myconf="${myconf} --enable-gui=motif"
else
einfo "Building gvim with the Athena GUI"
myconf="${myconf} --enable-gui=athena"
fi
else
if use gtk && use gtk2 ; then
myconf="${myconf} --enable-gui=gtk2 --enable-gtk2-check"
elif use gnome ; then
myconf="${myconf} --enable-gui=gnome"
elif use gtk ; then
myconf="${myconf} --enable-gui=gtk"
elif use motif ; then
myconf="${myconf} --enable-gui=motif"
else
myconf="${myconf} --enable-gui=athena"
fi
fi
else
die "vim.eclass doesn't understand MY_PN=${MY_PN}"
fi
fi
if [[ "${MY_PN}" == "vim" ]] && use minimal ; then
myconf="${myconf} --disable-nls --disable-multibyte --disable-acl"
else
myconf="${myconf} `use_enable nls` `use_enable acl`"
fi
# Note: If USE=gpm, then ncurses will still be required
use ncurses \
&& myconf="${myconf} --with-tlib=ncurses" \
|| myconf="${myconf} --with-tlib=termcap"
use selinux \
|| myconf="${myconf} --disable-selinux"
econf ${myconf} || die "vim configure failed"
# The following allows emake to be used
make -C src auto/osdef.h objects || die "make failed"
if [[ "${MY_PN}" == "vim-core" ]] ; then
emake tools || die "emake tools failed"
rm -f src/vim
else
emake || die "emake failed"
fi
}
src_install() {
if [[ "${MY_PN}" == "vim-core" ]] ; then
dodir /usr/{bin,share/{man/man1,vim}}
cd src || die "cd src failed"
make \
installruntime \
installhelplinks \
installmacros \
installtutor \
installtools \
install-languages \
install-icons \
DESTDIR=${D} \
BINDIR=/usr/bin \
MANDIR=/usr/share/man \
DATADIR=/usr/share \
|| die "install failed"
keepdir /usr/share/vim/vim${VIM_VERSION/.}/keymap
# Azarah put in the below "fix" in early 2002 but it makes
# things painful when going from 6.1->6.2a, etc. It also
# seems to be completely unnecessary, so I'm removing it.
# (24 Apr 2003 agriffis)
#
# fix problems with vim not finding its data files.
#echo "VIMRUNTIME=/usr/share/vim/vim${VIM_VERSION/.}" > 40vim
#insinto /etc/env.d
#doins 40vim
# default vimrc is installed by vim-core since it applies to
# both vim and gvim
insinto /etc/vim/
doins ${FILESDIR}/vimrc
elif [[ "${MY_PN}" == "gvim" ]] ; then
dobin src/gvim
dosym gvim /usr/bin/gvimdiff
dosym gvim /usr/bin/evim
dosym gvim /usr/bin/eview
insinto /etc/vim
doins ${FILESDIR}/gvimrc
# as of 6.3-r1, we install a desktop entry. bug #44633.
if version_is_at_least "6.3-r1" ; then
insinto /usr/share/applications
doins ${FILESDIR}/gvim.desktop
insinto /usr/share/pixmaps
doins ${FILESDIR}/gvim.xpm
fi
else
dobin src/vim
ln -s vim ${D}/usr/bin/vimdiff && \
ln -s vim ${D}/usr/bin/rvim && \
ln -s vim ${D}/usr/bin/ex && \
ln -s vim ${D}/usr/bin/view && \
ln -s vim ${D}/usr/bin/rview \
|| die "/usr/bin symlinks failed"
fi
}
# Make convenience symlinks, hopefully without stepping on toes. Some
# of these links are "owned" by the vim ebuild when it is installed,
# but they might be good for gvim as well (see bug 45828)
update_vim_symlinks() {
local f syms="vi vimdiff rvim ex view rview"
# Make or remove convenience symlink, vim -> gvim
if [[ -f /usr/bin/gvim ]]; then
ln -s gvim /usr/bin/vim 2>/dev/null
elif [[ -L /usr/bin/vim && ! -f /usr/bin/vim ]]; then
rm /usr/bin/vim
fi
# Make or remove convenience symlinks to vim
if [[ -f /usr/bin/vim ]]; then
for f in ${syms}; do
ln -s vim /usr/bin/${f} 2>/dev/null
done
else
for f in ${syms}; do
if [[ -L /usr/bin/${f} && ! -f /usr/bin/${f} ]]; then
rm -f /usr/bin/${f}
fi
done
fi
# This will still break if you merge then remove the vi package,
# but there's only so much you can do, eh? Unfortunately we don't
# have triggers like are done in rpm-land.
}
pkg_postinst() {
# Update documentation tags (from vim-doc.eclass)
update_vim_helptags
einfo
if [[ "${MY_PN}" == "gvim" ]] ; then
einfo "To enable UTF-8 viewing, set guifont and guifontwide: "
einfo ":set guifont=-misc-fixed-medium-r-normal-*-18-120-100-100-c-90-iso10646-1"
einfo ":set guifontwide=-misc-fixed-medium-r-normal-*-18-120-100-100-c-180-iso10646-1"
einfo
einfo "note: to find out which fonts you can use, please read the UTF-8 help:"
einfo ":h utf-8"
einfo
einfo "Then, set read encoding to UTF-8:"
einfo ":set encoding=utf-8"
elif [[ "${MY_PN}" == "vim" ]] ; then
einfo "gvim has now a seperate ebuild, 'emerge gvim' will install gvim"
fi
einfo
if [[ "${MY_PN}" != "vim-core" ]] ; then
einfo "To see what's new in this release, use :help version${VIM_VERSION/.*}.txt"
einfo
fi
# Warn about VIMRUNTIME
if [ -n "$VIMRUNTIME" -a "${VIMRUNTIME##*/vim}" != "${VIM_VERSION/.}" ] ; then
ewarn
ewarn "WARNING: You have VIMRUNTIME set in your environment from an old"
ewarn "installation. You will need to either unset VIMRUNTIME in each"
ewarn "terminal, or log out completely and back in. This problem won't"
ewarn "happen again since the ebuild no longer sets VIMRUNTIME."
ewarn
fi
# Scream loudly if the user is using a -cvs ebuild
if [[ -z "${PN/*-cvs}" ]] ; then
ewarn "You are using a -cvs ebuild. Be warned that this is not"
ewarn "officially supported and may not work."
ewarn " "
ebeep 5
fi
# Make convenience symlinks
update_vim_symlinks
}
pkg_postrm() {
# Update documentation tags (from vim-doc.eclass)
update_vim_helptags
# Make convenience symlinks
update_vim_symlinks
}
src_test() {
if [[ "${MY_PN}" == "vim-core" ]] ; then
einfo "No testing needs to be done for vim-core"
return
fi
einfo " "
einfo "Starting vim tests. Several error messages will be shown "
einfo "whilst the tests run. This is normal behaviour and does not "
einfo "indicate a fault."
einfo " "
ewarn "If the tests fail, your terminal may be left in a strange "
ewarn "state. Usually, running 'reset' will fix this."
ewarn " "
epause 5
# Don't let vim talk to X
unset DISPLAY
if [[ "${MY_PN}" == "gvim" ]] ; then
# Make gvim not try to connect to X. See :help gui-x11-start
# in vim for how this evil trickery works.
ln -s ${S}/src/gvim ${S}/src/testvim
testprog="../testvim"
else
testprog="../vim"
fi
# We've got to call make test from within testdir, since the Makefiles
# don't pass through our VIMPROG argument
cd ${S}/src/testdir
# Test 49 won't work inside a portage environment
sed -i -e 's~test49.out~~g' Makefile
# We don't want to rebuild vim before running the tests
sed -i -e 's,: \$(VIMPROG),: ,' Makefile
# Don't try to do the additional GUI test
make VIMPROG=${testprog} nongui \
|| die "At least one test failed"
}
|