--- bsd.port.mk.20030512 Mon May 12 12:47:41 2003 +++ bsd.port.mk Tue May 13 04:24:24 2003 @@ -498,6 +498,13 @@ # NOMANCOMPRESS. The default is "yes" if USE_IMAKE # is set and NO_INSTALL_MANPAGES is not set, and # "no" otherwise. +# HAS_LOCALE - Says that the port contains localization files. +# LOCALE_DIR - Specifies localization files directory. (default : share/locale) +# PORTS_LOCALE - Selected locale. "" means NO_LOCALE=yes +# CLEAN_LOCALE - If specifies (in conjunction with HAS_LOCALE and +# PORTS_LOCALE) all locale, except which are explicitly +# specify, will be removed. +# NO_LOCALE - Gets of rid of localization files. # # Default targets and their behaviors: # @@ -2491,6 +2498,25 @@ @${DO_NADA} .endif +# remove locale stuff... I don't know where I can put them :) +# get pattern maching +.if !defined(LOCALE_DIR) +LOCALE_DIR?= share/locale +.endif +.if defined(NO_LOCALE) && defined(HAS_LOCALE) +PORTS_LOCALE= "" +CLEAN_LOCALE= yes +.endif +.if defined(PORTS_LOCALE) +PORTS_LOCALE_TMP!= ${ECHO_CMD} ${PORTS_LOCALE}| ${TR} -s ' ' '|' +.endif +.if !defined(PLIST_LOCALE) +PLIST_LOCALE= ${WRKDIR}/.PLIST.locale.tmp +.endif +.if !defined(LOCALE_PREFIX) +LOCALE_PREFIX?= ${PREFIX} +.endif + ################################################################ # More standard targets start here. # @@ -3096,8 +3122,8 @@ _INSTALL_SEQ= install-message check-categories check-already-installed \ check-conflicts check-umask run-depends lib-depends \ install-mtree pre-install pre-install-script do-install \ - generate-plist post-install post-install-script compress-man \ - run-ldconfig fake-pkg security-check + clean-locale generate-plist post-install post-install-script \ + compress-man run-ldconfig fake-pkg security-check _PACKAGE_DEP= install _PACKAGE_SEQ= package-message pre-package pre-package-script \ do-package post-package-script @@ -4013,6 +4039,27 @@ .endif .endif +# Locales clean up +.if !target(clean-locale) +clean-locale: +.if defined(HAS_LOCALE) && defined(CLEAN_LOCALE) && defined(PORTS_LOCALE) + @${CP} ${PLIST} ${PLIST_LOCALE} + @${ECHO_MSG} '===> Removing non selected locale' + @${EGREP} "^${LOCALE_DIR}/(.{2}|.{2}_.{2})/" ${PLIST_LOCALE} | \ + ${EGREP} -v "^${LOCALE_DIR}/(${PORTS_LOCALE_TMP})/.+" > ${WRKDIR}/.removed_locale ||\ + ${ECHO_MSG} "** Warning : this port has locale incorrectly set.\ + Please contact the maintainer (${MAINTAINER}) **" + @${GREP} -v -f ${WRKDIR}/.removed_locale ${PLIST_LOCALE} > ${WRKDIR}/.PLIST.tmp.locale-cleanup + @for i in `cat ${WRKDIR}/.removed_locale` ;do \ + ${RM} "${LOCALE_PREFIX}/$${i}"; \ + done + @${MV} ${WRKDIR}/.PLIST.tmp.locale-cleanup ${PLIST_LOCALE} + @${TOUCH} ${WRKDIR}/.PLIST.locale-cleanup-done +.else + @${ECHO_MSG} "PORTS_LOCALE is not defined, skipping..." +.endif +.endif + # Generate packing list. Also tests to make sure all required package # files exist. @@ -4020,7 +4067,11 @@ generate-plist: @${ECHO_MSG} "===> Generating temporary packing list" @${MKDIR} `dirname ${TMPPLIST}` +.if defined(HAS_LOCALE) && defined(CLEAN_LOCALE) && defined(PORTS_LOCALE) + @if [ ! -f ${PLIST_LOCALE} -o ! -f ${DESCR} ]; then ${ECHO_CMD} "** Missing package files for ${PKGNAME}."; exit 1; fi +.else @if [ ! -f ${PLIST} -o ! -f ${DESCR} ]; then ${ECHO_CMD} "** Missing package files for ${PKGNAME}."; exit 1; fi +.endif @>${TMPPLIST} @for man in ${__MANPAGES}; do \ ${ECHO_CMD} $${man} >> ${TMPPLIST}; \ @@ -4057,7 +4108,11 @@ .endif .endif .endfor +.if defined(HAS_LOCALE) && defined(CLEAN_LOCALE) && defined(PORTS_LOCALE) + @${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} ${PLIST_LOCALE} >> ${TMPPLIST} +.else @${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} ${PLIST} >> ${TMPPLIST} +.endif .if !defined(NO_MTREE) @${ECHO_CMD} "@unexec if [ -f %D/info/dir ]; then if sed -e '1,/Menu:/d' %D/info/dir | grep -q '^[*] '; then true; else rm %D/info/dir; fi; fi" >> ${TMPPLIST} .endif