.include "${.CURDIR}/../../editors/libreoffice/Makefile.common"

MASTER_SITES=	https://download.documentfoundation.org/libreoffice/${MASTER_SITE_SUBDIR}/
.if defined(PRERELEASE)
MASTER_SITES+=	https://dev-builds.libreoffice.org/pre-releases/deb/x86_64/
MASTER_SITE_SUBDIR=	testing/${LOVERSION}/deb/x86_64
.	if defined(DEVRELEASE)
LO_NAME=	LibreOfficeDev
.	else
LO_NAME=	LibreOffice
.	endif
LO_I18N_FILE=	${LO_NAME}_${DISTVERSION}_Linux_x86-64_deb
.else
MASTER_SITE_SUBDIR=	stable/${LOVERSION}/deb/x86_64
LO_NAME=	LibreOffice
LO_I18N_FILE=	${LO_NAME}_${LOVERSION}_Linux_x86-64_deb
.endif
PKGNAMEPREFIX=	${LO_I18N}-
DISTFILES=	${LO_I18N_FILE}_langpack_${LO_I18N:S/_/-/}${EXTRACT_SUFX}
.if defined(LO_HAS_HELPPACK)
DISTFILES+=	${LO_I18N_FILE}_helppack_${LO_I18N:S/_/-/}${EXTRACT_SUFX}
.endif
DIST_SUBDIR=	libreoffice/i18n

COMMENT?=	${LO_I18N} language pack for ${PORTNAME}
WWW?=		https://www.libreoffice.org/

DESCR?=	${.CURDIR}/../../editors/libreoffice/pkg-descr.i18n

RUN_DEPENDS?=	libreoffice:editors/libreoffice

NO_ARCH=	yes
NO_BUILD=	yes

EXTRACT_AFTER_ARGS=	--exclude '${PORTNAME}*-dict-*.deb' \
			--strip-components 1

post-extract:
	@${MKDIR} ${WRKSRC}
	for deb in ${WRKDIR}/DEBS/*.deb ; do \
		${TAR} xfO $${deb} data.tar.xz | ${TAR} -C ${WRKSRC} -xf - ; \
	done

do-install:
	@${MKDIR} ${STAGEDIR}${PREFIX}/lib/${PORTNAME}
	cd ${WRKSRC}/opt/${LO_NAME:tl}${LOVERSION:R} ; \
	    ${PAX} -rw . ${STAGEDIR}${PREFIX}/lib/${PORTNAME}

post-install:
	@cd ${WRKSRC}/opt/${LO_NAME:tl}${LOVERSION:R} && \
		${FIND} -s * -not -type d \
			-exec ${ECHO_CMD} "lib/${PORTNAME}/{}" \; >> ${TMPPLIST} && \
		${FIND} -d * -type d -empty \
			-exec ${ECHO_CMD} "@dir lib/${PORTNAME}/{}" \; >> ${TMPPLIST}
