espie 71a2ef4f62 Add a denormalized table that instantiates the main ports view.
So, Portsq is a snapshot of Ports... dirty but fast.

I had mixed feelings about this.
There's also a script to resync the table.

Grows the db by about 50% (+25MB)

Discussed with sthen@
2019-05-18 21:35:21 +00:00

56 lines
1.9 KiB
Makefile

# $OpenBSD: Makefile,v 1.113 2019/05/18 21:35:21 espie Exp $
CATEGORIES = databases
V = 7.22
DISTNAME = sqlports-$V
DISTFILES =
COMMENT = sqlite database of ports
COMMENT-main = ${COMMENT}
COMMENT-list = full list of pkgpaths in ports
MAINTAINER = Marc Espie <espie@openbsd.org>
PKGNAME-main = sqlports-$V
PKGNAME-list = portslist-$V
PERMIT_PACKAGE_CDROM = Yes
MULTI_PACKAGES = -main -list
DBNAME = sqlports
SQLCACHE = ${DBNAME}_cache.sql
SQLVIEWS = ${DBNAME}_views.sql
DBS = ${DBNAME}.list ${DBNAME} ports-INDEX ${SQLCACHE}
BUILD_DEPENDS = databases/p5-DBD-SQLite \
databases/sqlite3
RUN_DEPENDS-main = databases/sqlite3
SCRIPTS = print-ports-index show-reverse-deps rebuild-sqlports-cache
do-build:
@unset MAKEFLAGS; unset BUILD_ONCE; cd ${PORTSDIR} && PORTSDIR=${PORTSDIR} ${MAKE_ENV} perl ${FILESDIR}/mksqlitedb -v -V $V -p ${WRKBUILD}/ouch -C ${WRKBUILD}/${SQLCACHE} -w ${WRKBUILD}/${SQLVIEWS} ${WRKBUILD}/${DBNAME}
@if test -s ${WRKBUILD}/ouch; then \
cat ${WRKBUILD}/ouch; \
exit 1; \
fi
cd ${WRKBUILD} && sqlite3 <${SQLCACHE} ${DBNAME}
alter-tables:
@unset MAKEFLAGS; unset BUILD_ONCE; cd ${PORTSDIR} && PORTSDIR=${PORTSDIR} ${MAKE_ENV} ${SUDO} -u ${BUILD_USER} perl ${FILESDIR}/rebuild_schema -v -V $V ${WRKBUILD/${DBNAME}
@${SUDO} -u ${BUILD_USER} ${MAKE} post-build
post-build:
cd ${WRKBUILD} && ${LOCALBASE}/bin/sqlite3 ${DBNAME} 'select min(_paths.fullpkgpath) from _paths join _ports on _paths.id=_ports.fullpkgpath where _ports.static_plist=1 group by fullpkgname order by _paths.fullpkgpath' >${DBNAME}.list
cd ${WRKBUILD} && sh ${FILESDIR}/scripts/print-ports-index ${DBNAME} >ports-INDEX
do-install:
${INSTALL_PROGRAM_DIR} ${PREFIX}/bin
.for s in ${SCRIPTS}
@${SUBST_PROGRAM} ${FILESDIR}/scripts/$s ${PREFIX}/bin/$s
.endfor
@for i in ${DBS}; do \
${INSTALL_DATA} ${WRKBUILD}/$$i ${PREFIX}/share; \
done
NO_TEST = Yes
NO_CHECKSUM = Yes
.include <bsd.port.mk>