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
|
# Created by: Andrew Pantyukhin <infofarmer@FreeBSD.org>
# $FreeBSD$
# XPI_ID - Extension id, might be in {12345-...} or dev@org format
# XPI_NUM - Extension number, as in addons.mozilla.org URL
# XPI_FILES - List of files in xpi archive. This is used to produce
# PLIST_FILES. XPI_FILES can be generated by xpi-gen, but be
# sure to put chrome.manifest in ${FILESDIR} before that if you
# need it.
# XPI_DIRS - List of directories in xpi archive. This is used to produce
# PLIST_DIRS.
# XPI_DISTNAME - The name of distribution
# Default: ${PORTNAME}
# PORTNAME, PORTVERSION, DISTVERSIONSUFFIX, CATEGORIES, MAINTAINER, COMMENT
# - These should all be set manually for port to be functional. See
# ${PORTSDIR}/Mk/bsd.port.mk for details.
# MASTER_SITES - This should be set if port is unavailable at the default site.
# Default: ${MASTER_SITE_MOZILLA}
# MASTER_SITE_SUBDIR
# - Default: extensions/${PORTNAME}
# LATEST_LINK - Default: ${PKGBASE:S/_//g}
# XPI_LIBDIR - Name of the directory to install extensions in.
# Default: ${PREFIX}/lib/xpi
# XPI_XPIDIR - Name of the directory to install extension's files in.
# Default: ${XPI_LIBDIR}/${XPI_ID}
# USE_XPI - If set, the port installs one or more xpi extensions.
# If this is set to a list of apps (wildcards possible) the
# extensions will be installed for them only.
# WITH_XPI - A user-tunable variable, determines which apps should
# extension be made available for. Can be set to a list of
# apps, same as USE_XPI, and/or to "ext:app[,app,app,...]" tuples.
# ext should be a portname. If ext starts and ends with a slash
# (`/'), it is treated as an extended regular expression (see
# re_format(7)). Right of the colon should be a list of apps in
# the same format as USE_XPI, but comma- instead of whitespace-
# delimited. If no matching tuples for an extension are found,
# WITH_XPI is scanned for non tuple-records which are then treated
# as a USE_XPI list. If several tuples match, the last non-regexp
# one takes precedence, then the last regexp one.
#
# This Makefile is a beta-version of the new xpi infrastructure. It currently
# supports Gecko 1.8+ (Firefox 1.5+). Support for Gecko 1.7x (and Seamonkey 1.0)
# may be merged later from Thierry Thomas works.
#
# A new xpi will require a PORTNAME, PORTVERSION, DISTVERSIONSUFFIX and
# CATEGORIES. In case it is not published on the mozilla.org sites, MASTER_SITES
# can be redefined. XPI_* vars will also need to be defined manually, which helps
# keep the infrastructure simpler.
#
# Gecko 1.8 xpi engine tries to detect various compatibility issues all by itself.
# Thus, xpi's are installed into ${LOCALBASE}/lib/xpi/${XPI_ID} by default and
# links are made to all apps which have the engine (firefox, thunderbird, sunbird
# thunderbird3, seamonkey and flock at the moment). relink and relink-all targets
# can be invoked to refarm the links of a single extensions or all installed
# extensions accordingly.
#
# In case an xpi does not have chrome.manifest, it should be generated manually by
# a maintainer and placed in files, where it will be noticed.
#
# xpi ports do not depend on their master applications. You can install an
# extension before the app and run relink when the app is present.
.ifndef MASTER_SITES
MASTER_SITES?= MOZILLA_EXTENDED
.ifdef XPI_NUM
MASTER_SITE_SUBDIR?= addons/${XPI_NUM}
.endif
MASTER_SITE_SUBDIR?= extensions/${XPI_DISTNAME}
.endif
PKGNAMEPREFIX?= xpi-
EXTRACT_SUFX?= .xpi
DISTNAME?= ${XPI_DISTNAME}-${DISTVERSIONPREFIX}${DISTVERSION}${DISTVERSIONSUFFIX}
DIST_SUBDIR?= xpi
LATEST_LINK?= ${PKGBASE:S/_//g}
NO_BUILD= yes
USES+= zip:infozip
EXTRACT_AFTER_ARGS= -d ${WRKSRC}
XPI_DISTNAME?= ${PORTNAME}
XPI_APPS_ALL_WC= *firefox* *thunderbird* *seamonkey*
XPI_APPS_ALL= firefox linux-firefox thunderbird linux-thunderbird \
seamonkey linux-seamonkey
# kompozer linux-kompozer
# Other apps: mango
# === Let's process WITH_XPI into WITH_XPI_APPS
WITH_XPI_TUPLES= ${WITH_XPI:M*?\:?*}
WITH_XPI_NTUPLES= ${WITH_XPI:N*\:*}
WITH_XPI_TUPLES_RX= ${WITH_XPI_TUPLES:M/*?*/\:?*}
WITH_XPI_TUPLES_WC= ${WITH_XPI_TUPLES:N/*?*/\:?*}
WITH_XPI_MATCH?= ${PORTNAME}
WITH_XPI_MATCHSTRING?= _=~match~=_
.for tuple_rx in ${WITH_XPI_TUPLES_RX}
_rx= ${tuple_rx:C!/(.*)/\:.*!\1!}
_apps= ${tuple_rx:C!/.*/\:(.*)!\1!}
_testrx=${WITH_XPI_MATCH:C!.*${_rx}.*!${WITH_XPI_MATCHSTRING}!}
.if ${_testrx} == ${WITH_XPI_MATCHSTRING}
WITH_XPI_APPS:= ${_apps:S/,/ /g}
.endif
.endfor
.for tuple_wc in ${WITH_XPI_TUPLES_WC}
_wc= ${tuple_wc:C!(.*)\:.*!\1!}
_apps= ${tuple_wc:C!.*\:(.*)!\1!}
.if ${_wc} == ${WITH_XPI_MATCH}
WITH_XPI_APPS:= ${_apps:S/,/ /g}
.endif
.endfor
.if ${WITH_XPI_NTUPLES}
WITH_XPI_APPS?= ${WITH_XPI_NTUPLES}
.endif
# === WITH_XPI has been processed
.ifdef WITH_XPI_APPS
USE_XPI= ${WITH_XPI_APPS}
.endif
.if !defined(USE_XPI) || ${USE_XPI:tu} == "YES" || ${USE_XPI} == "*"
USE_XPI= ${XPI_APPS_ALL_WC}
.endif
.if !defined(XPI_APPS)
.for xpi in ${USE_XPI}
_xpi:= ${xpi}
.if ${_xpi:M*firefox*}
XPI_APPS+= ${LOCALBASE}/lib/${xpi}/browser/extensions
.else
XPI_APPS+= ${LOCALBASE}/lib/${xpi}/extensions
.endif
.endfor
.endif
XPI_SLDIRS_ALL= ${XPI_APPS_ALL:S.^.${XPI_SLDIR}/.}
XPI_SLDIRS= ${USE_XPI:S.^.${XPI_SLDIR}/.}
XPI_LINKFARMS= ${XPI_APPS} ${XPI_SLDIRS}
XPI_LIBDIR?= ${PREFIX}/lib/xpi
XPI_SLDIR?= ${XPI_LIBDIR}/symlinks
.ifndef XPI_DISTNAMES
XPI_XPIDIR?= ${XPI_LIBDIR}/${XPI_ID}
.endif
XPI_DIRS_TRY= ${XPI_SLDIRS_ALL:S,^${PREFIX}/,,} \
${XPI_SLDIR:S,^${PREFIX}/,,} \
${XPI_LIBDIR:S,^${PREFIX}/,,}
PLIST_SUB+= XPI_LIBDIR="${XPI_LIBDIR:S,^${PREFIX}/,,}" \
XPI_XPIDIR="${XPI_XPIDIR:S,^${PREFIX}/,,}"
_TD= ${XPI_XPIDIR:S,^${PREFIX}/,,}
_TD_FULL= ${XPI_XPIDIR}
_A= >> ${TMPPLIST}
_Q= 2>/dev/null || true
PLIST_FILES+= ${XPI_FILES:S!^!${_TD}/!}
PLIST_DIRS+= ${XPI_DIRS:S!^!${_TD}/!} ${_TD}
.for dist in ${XPI_DISTNAMES}
XPI_XPIDIR_${dist}= ${XPI_LIBDIR}/${XPI_ID_${dist}}
_TD_${dist}= ${XPI_XPIDIR_${dist}:S,^${PREFIX}/,,}
PLIST_FILES+= ${XPI_FILES_${dist}:S!^!${_TD_${dist}}/!}
PLIST_DIRS+= ${XPI_DIRS_${dist}:S!^!${_TD_${dist}}/!} ${_TD_${dist}}
.endfor
.if !target(do-install)
do-install:
@${MKDIR} ${STAGEDIR}${_TD_FULL} ${XPI_SLDIRS_ALL:S/^/${STAGEDIR}/}
@cd ${WRKSRC}; ${PAX} -rw . ${STAGEDIR}${_TD_FULL}/
@if [ -d ${FILESDIR} -a -f ${FILESDIR}/chrome.manifest ] ; \
then ${INSTALL_DATA} ${FILESDIR}/chrome.manifest ${STAGEDIR}${_TD_FULL}/ ; fi
@${CHMOD} -R a+rX,go-w ${STAGEDIR}${_TD_FULL}/
@${ECHO_CMD} '@exec ${INSTALL} -d ${XPI_SLDIRS_ALL:S,^${STAGEDIR}${PREFIX},%D,}' ${_A}
@${ECHO_CMD} '@exec for _dir in ${XPI_LINKFARMS} ; { ${LN} -sf ${_TD_FULL} $$_dir/ ${_Q}; }' ${_A}
@${ECHO_CMD} '@unexec for _dir in ${XPI_LINKFARMS} ; { ${RM} -f $$_dir/${XPI_ID} ; }' ${_A}
@for _dir in ${XPI_DIRS_TRY} ; { ${ECHO_CMD} "@unexec rmdir %D/$$_dir ${_Q}" ${_A} ; }
.endif
.if !target(relink)
relink:
@-for _app in ${XPI_APPS} ; { ${LN} -sf ${_TD_FULL} $$_app ${_Q} ; }
.endif
.if !target(relink-all)
relink-all:
@-for _app in ${XPI_APPS} ; { for _xpi in ${XPI_LIBDIR}/*[\{@]* ; { \
${LN} -sf $$_xpi $$_app ${_Q} ; } ; }
.endif
.if !target(xpi-post-extract)
xpi-post-extract:
.endif
post-extract: xpi-post-extract
@${RM} -rf ${WRKSRC}/META-INF
# Maintainer section
xpi-gen: extract
@${ECHO_CMD} -n 'XPI_ID='
@${SED} -En '/<(RDF:)?Description (RDF:)?about="urn:mozilla:install-manifest"/,/>/p' ${WRKSRC}/install.rdf | \
${GREP} -Em1 'em:id|<id>' | ${CUT} -f2- -d\> | \
${CUT} -f1 -d\< | ${CUT} -f2 -d\"
@${ECHO_CMD} -n 'XPI_FILES='
@cd ${WRKSRC} && ${FIND} -s . -not -type d | cut -f2- -d/ | ${TR} '\n' ' '
@if [ -d ${FILESDIR} -a -f ${FILESDIR}/chrome.manifest ] ; \
then ${ECHO_CMD} chrome.manifest ; fi
@${ECHO_CMD}
@${ECHO_CMD} -n 'XPI_DIRS='
@cd ${WRKSRC} && ${FIND} -ds . -not -name . -type d | cut -f2- -d/ | ${TR} '\n' ' '
@${ECHO_CMD}
xpi-plist: extract
@${FIND} -s ${WRKSRC} -not -type d | ${SED} -e "s,^${WRKSRC},%%XPI_XPIDIR%%," > ${PLIST}
@if [ -d ${FILESDIR} -a -f ${FILESDIR}/chrome.manifest ] ; \
then ${ECHO_CMD} %%XPI_XPIDIR%%/chrome.manifest >> ${PLIST} ; fi
@${FIND} -ds ${WRKSRC} -type d -not -name ${DISTNAME} | \
${SED} -e "s,^${WRKSRC},@dirrm %%XPI_XPIDIR%%," >> ${PLIST}
xpi-pre-chrome:
@${CHMOD} g+w ${_TD_FULL}
@${RM} -f ${_TD_FULL}/chrome.manifest
xpi-post-chrome:
@${CP} -f ${_TD_FULL}/chrome.manifest ${FILESDIR}/
|