aboutsummaryrefslogtreecommitdiff
blob: 8378fab15086f85d5e9e69c0bd78446b9e7dd98d (plain)
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
" Vim plugin
" Purpose:      Intelligently create content for new ebuild files
" Author:       Ciaran McCreesh <ciaranm@gentoo.org>
" Copyright:    Copyright (c) 2004-2005 Ciaran McCreesh
" Licence:      You may redistribute this under the same terms as Vim itself

if &compatible || v:version < 603 || exists("g:loaded_newebuild")
    finish
endif

let g:loaded_newebuild=1

runtime! plugin/gentoo-common.vim

fun! <SID>MakeNewEbuild()
    let l:pastebackup = &paste
    set nopaste

    " {{{ variables
    let l:arch = GentooGetArch()
    let l:filename = expand("%:p")
    let l:category = substitute(l:filename,
                \ "^.*/\\([^/]\\+\\)/[^/]\\+/[^/]\\+\\.ebuild", "\\1", "g")

    " use empty keywords for live ebuilds
    if l:filename =~# "-9999\\+.ebuild\$"
        let l:keywords = ""
    else
        let l:keywords = "~" . l:arch
        if l:arch ==# "amd64"
            let l:keywords = l:keywords . " ~x86"
        endif
    endif

    " }}}

    call GentooHeader()

    if expand("%:e") =~# "eclass\$"
        " {{{ eclass special setup
        let l:eclass=expand("%:t")
        put ='# @ECLASS: ' . l:eclass
        put ='# @MAINTAINER:'
        put ='# ' . GentooGetUser()
        put ='# @AUTHOR:'
        put ='# ' . GentooGetUser()
        put ='# @BLURB: '
        put ='# @DESCRIPTION:'
        put =''
        " }}}

        " {{{ go to the first thing to edit
        0
        /^# @BLURB:/
        normal $
        nohls
        " }}}
    else
        put ='EAPI=7'
        put =''
        if l:category ==# "acct-group"
            " {{{ acct-group special setup
            put ='inherit acct-group'
            put =''
            put ='ACCT_GROUP_ID='
            " }}}
        elseif l:category ==# "acct-user"
            " {{{ acct-user special setup
            let l:username=substitute(expand("%:t:r"),
                    \ "\\(.*\\)-[0-9]*.*", "\\1", "")
            put ='inherit acct-user'
            put =''
            put ='DESCRIPTION=\"\"'
            put ='ACCT_USER_ID='
            put ='ACCT_USER_GROUPS=( ' . l:username . ' )'
            put =''
            put ='acct-user_add_deps'
            " }}}
        elseif l:category ==# "app-vim"
            " {{{ app-vim special setup
            put ='#VIM_PLUGIN_VIM_VERSION=\"7.0\"'
            put ='inherit vim-plugin'
            put =''
            put ='DESCRIPTION=\"vim plugin: \"'
            put ='HOMEPAGE=\"http://www.vim.org/scripts/script.php?script_id=\"'
            put ='LICENSE=\"\"'
            put ='KEYWORDS=\"' . l:keywords . '\"'
            put =''
            put ='VIM_PLUGIN_HELPFILES=\"\"'
            put ='VIM_PLUGIN_HELPTEXT=\"\"'
            put ='VIM_PLUGIN_HELPURI=\"\"'
            put ='VIM_PLUGIN_MESSAGES=\"\"'
            put =''
            " }}}
        elseif l:category ==# "www-apache" && expand("%:t") =~# "^mod_"
            " {{{ www-apache default setup (for module pkgs)
            put ='inherit apache-module'
            put =''
            put ='DESCRIPTION=\"\"'
            put ='HOMEPAGE=\"\"'
            put ='LICENSE=\"\"'
            put =''
            put ='KEYWORDS=\"' . l:keywords . '\"'
            put ='SLOT=\"0\"'
            put =''
            put ='# See apache-module.eclass for more information.'
            put ='APACHE2_MOD_CONF=\"XX_${PN}\"'
            put ='APACHE2_MOD_DEFINE=\"\"'
            put =''
            put ='need_apache2'
            " }}}
        elseif l:category ==# "dev-java"
            " {{{ dev-java generation-2 default java-pkg-simple ebuild
            put ='JAVA_PKG_IUSE=\"doc source\"'
            put =''
            put ='inherit java-pkg-2 java-pkg-simple'
            put =''
            put ='DESCRIPTION=\"\"'
            put ='HOMEPAGE=\"\"'
            put ='SRC_URI=\"${P}.zip\"'
            put =''
            put ='LICENSE=\"\"'
            put ='SLOT=\"0\"'
            put ='KEYWORDS=\"' . l:keywords . '\"'
            put =''
            put ='CP_DEPEND=\"\"'
            put =''
            put ='RDEPEND=\">=virtual/jre-1.8'
            put ='  ${CP_DEPEND}\"'
            put ='DEPEND=\">=virtual/jdk-1.8'
            put ='  ${CP_DEPEND}\"'
        elseif l:category ==# "dev-perl" || l:category ==# "perl-core"
            " {{{ perl modules default setup
            put ='DIST_AUTHOR=\"\"'
            put ='inherit perl-module'
            put =''
            put ='DESCRIPTION=\"\"'
            put =''
            put ='#LICENSE=\"\|\| ( Artistic GPL-1+ )\"'
            put ='SLOT=\"0\"'
            put ='KEYWORDS=\"' . l:keywords . '\"'
            put =''
            put ='RDEPEND=\"\"'
            put ='DEPEND=\"${RDEPEND}\"'
            " }}}
        else
            " {{{ standard default setup
            " {{{ extra inherits for some categories
            if l:category ==# "dev-python"
                put ='PYTHON_COMPAT=( ' . GentooGetPythonTargets() . ' )'
                put ='inherit distutils-r1'
                put =''
            endif
            " }}}

            put ='DESCRIPTION=\"\"'
            put ='HOMEPAGE=\"\"'
            put ='SRC_URI=\"\"'
            put =''
            put ='LICENSE=\"\"'
            put ='SLOT=\"0\"'
            put ='KEYWORDS=\"' . l:keywords . '\"'
            put =''

            " {{{ extra deps for some categories
            put ='DEPEND=\"\"'
            put ='RDEPEND=\"${DEPEND}\"'
            put ='BDEPEND=\"\"'
            " }}}
        endif

        " {{{ go to the first thing to edit
        0
        /^\(ACCT_GROUP_ID\|DIST_AUTHOR\|DESCRIPTION\)=/
        exec "normal f=ll"
        nohls
        " }}}
    endif

    if pastebackup == 0
        set nopaste
    endif
endfun

com! -nargs=0 NewEbuild call <SID>MakeNewEbuild()

if !exists("g:ebuild_create_on_empty")
    " Enable autogeneration of ebuilds by default
    let g:ebuild_create_on_empty = 1
endif

" check to see if v:progname is vimdiff to disable new ebuild creation
if v:progname =~ "vimdiff"
    let g:ebuild_create_on_empty = 0
endif

augroup NewEbuild
    au!
    autocmd BufNewFile *.e{build,class}
                \ if g:ebuild_create_on_empty |
                \    call <SID>MakeNewEbuild() |
                \ endif
augroup END

" vim: set et foldmethod=marker : "