From d5cd97a4923abc80e246f0ea191d9dc4ad714f7e Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 29 Jul 2015 16:45:52 +0200 Subject: [PATCH] pkg: generalise packaging magic; add .in suffix awareness o Makes live-mounting easier as the package config samples won't be clobbered anymore. o Automatically picks up ".in" files, runs replace and moves them to their permanent location. o Refactored src directory install while at it. --- Makefile | 25 ++++++------------- Mk/tree.mk | 19 ++++++++++++-- src/Makefile | 4 +++ ...igin.conf.sample => origin.conf.sample.in} | 0 4 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 src/Makefile rename src/etc/pkg/repos/{origin.conf.sample => origin.conf.sample.in} (100%) diff --git a/Makefile b/Makefile index aebb44b95..9c370073a 100644 --- a/Makefile +++ b/Makefile @@ -9,10 +9,10 @@ force: mount: force @${.CURDIR}/scripts/version.sh > \ ${.CURDIR}/src/opnsense/version/opnsense - /sbin/mount_unionfs ${.CURDIR}/src /usr/local + mount_unionfs ${.CURDIR}/src /usr/local umount: force - /sbin/umount -f ":${.CURDIR}/src" + umount -f ":${.CURDIR}/src" CORE_COMMIT!= ${.CURDIR}/scripts/version.sh CORE_VERSION= ${CORE_COMMIT:C/-.*$//1} @@ -144,25 +144,16 @@ scripts: force ${DESTDIR}/+POST_INSTALL install: force - @${MAKE} -C ${.CURDIR}/lang install DESTDIR=${DESTDIR} @${MAKE} -C ${.CURDIR}/contrib install DESTDIR=${DESTDIR} - @mkdir -p ${DESTDIR}/usr/local - @cp -vr ${.CURDIR}/src/* ${DESTDIR}/usr/local - @sed -i '' -e "s/%%CORE_PACKAGESITE%%/${CORE_PACKAGESITE}/g" \ - ${DESTDIR}/usr/local/etc/pkg/repos/origin.conf.sample - @sed -i '' -e "s/%%CORE_REPOSITORY%%/${CORE_REPOSITORY}/g" \ - ${DESTDIR}/usr/local/etc/pkg/repos/origin.conf.sample + @${MAKE} -C ${.CURDIR}/lang install DESTDIR=${DESTDIR} + @${MAKE} -C ${.CURDIR}/src install DESTDIR=${DESTDIR} \ + CORE_PACKAGESITE=${CORE_PACKAGESITE} \ + CORE_REPOSITORY=${CORE_REPOSITORY} plist: force + @${MAKE} -C ${.CURDIR}/conrtib plist @${MAKE} -C ${.CURDIR}/lang plist - @${MAKE} -C ${.CURDIR}/contrib plist - @(cd ${.CURDIR}/src; find * -type f) | while read FILE; do \ - if [ $${FILE%%.sample} != $${FILE} ]; then \ - echo "@sample /usr/local/$${FILE}"; \ - else \ - echo "/usr/local/$${FILE}"; \ - fi; \ - done + @${MAKE} -C ${.CURDIR}/src plist lint: force find ${.CURDIR}/src ${.CURDIR}/lang/dynamic/helpers \ diff --git a/Mk/tree.mk b/Mk/tree.mk index 11f83e909..3c6a8fdd1 100644 --- a/Mk/tree.mk +++ b/Mk/tree.mk @@ -4,12 +4,27 @@ install: .for TREE in ${TREES} @mkdir -p ${DESTDIR}${ROOT} @cp -vr ${TREE} ${DESTDIR}${ROOT} + @(cd ${TREE}; find * -type f) | while read FILE; do \ + if [ $${FILE%%.in} != $${FILE} ]; then \ + sed -i '' \ + -e "s=%%CORE_PACKAGESITE%%=${CORE_PACKAGESITE}=g" \ + -e "s=%%CORE_REPOSITORY%%=${CORE_REPOSITORY}=g" \ + ${DESTDIR}${ROOT}/${TREE}/$${FILE}; \ + mv -v ${DESTDIR}${ROOT}/${TREE}/$${FILE} \ + ${DESTDIR}${ROOT}/${TREE}/$${FILE%%.in}; \ + fi \ + done .endfor plist: .for TREE in ${TREES} - @(cd ${TREE}; find * -type f) | \ - xargs -n1 printf "${ROOT}/${TREE}/%s\n" + @(cd ${TREE}; find * -type f) | while read FILE; do \ + FILE="$${FILE%%.in}"; PREFIX=""; \ + if [ $${FILE%%.sample} != $${FILE} ]; then \ + PREFIX="@sample "; \ + fi; \ + echo "${PREFIX} ${ROOT}/${TREE}/$${FILE}"; \ + done .endfor .PHONY: install plist diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 000000000..2d513de9b --- /dev/null +++ b/src/Makefile @@ -0,0 +1,4 @@ +ROOT= /usr/local +TREES= captiveportal etc opnsense pkg sbin www + +.include "../Mk/tree.mk" diff --git a/src/etc/pkg/repos/origin.conf.sample b/src/etc/pkg/repos/origin.conf.sample.in similarity index 100% rename from src/etc/pkg/repos/origin.conf.sample rename to src/etc/pkg/repos/origin.conf.sample.in