From 51f63d95205bf9aae33974fd0086ba778b233356 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 9 Jul 2015 12:35:20 +0200 Subject: [PATCH] plugins: hello world --- Makefile | 9 ++++ Mk/plugins.mk | 85 ++++++++++++++++++++++++++++++++++++ README.md | 18 ++++++++ test/Makefile | 7 +++ test/src/testdir/testfile.in | 1 + 5 files changed, 120 insertions(+) create mode 100644 Makefile create mode 100644 Mk/plugins.mk create mode 100644 README.md create mode 100644 test/Makefile create mode 100644 test/src/testdir/testfile.in diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..4bb59a450 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +PAGER?= less + +all: + @cat ${.CURDIR}/README.md | ${PAGER} + +PLUGIN_DIRS!= ls -1d [a-z]* + +list: + @echo ${PLUGIN_DIRS} diff --git a/Mk/plugins.mk b/Mk/plugins.mk new file mode 100644 index 000000000..9d1af599a --- /dev/null +++ b/Mk/plugins.mk @@ -0,0 +1,85 @@ +# Copyright (c) 2015 Franco Fichtner +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +all: check + +PLUGIN_COMMENT!= git rev-list HEAD --max-count=1 | cut -c1-9 +PLUGIN_DEPENDS+= opnsense +PLUGIN_PREFIX= os- + +check: + @[ -n "${PLUGIN_NAME}" ] || echo "PLUGIN_NAME not set" + @[ -n "${PLUGIN_VERSION}" ] || echo "PLUGIN_VERSION not set" + @[ -n "${PLUGIN_DESC}" ] || echo "PLUGIN_DESC not set" + @[ -n "${PLUGIN_MAINTAINER}" ] || echo "PLUGIN_MAINTAINER not set" + +mount: check + mount_unionfs ${.CURDIR}/src ${DESTDIR}/usr/local + +umount: check + umount -f ":${.CURDIR}/src" + +install: check + # move all sources to their destination + @mkdir -p ${DESTDIR}/usr/local + @(cd ${.CURDIR}/src; find * -type f) | \ + (xargs -n1 tar -C ${.CURDIR}/src -cpf -) | \ + tar -C ${DESTDIR}/usr/local -xpf - + # finally pretty-print a list of files present + @(cd ${.CURDIR}/src; find * -type f) | \ + xargs -n1 printf "/usr/local/%s\n" + +manifest: check + @echo "name: ${PLUGIN_PREFIX}${PLUGIN_NAME}" + @echo "version: \"${PLUGIN_VERSION}\"" + @echo "origin: opnsense/${PLUGIN_PREFIX}${PLUGIN_NAME}" + @echo "comment: \"${PLUGIN_COMMENT}\"" + @echo "desc: \"${PLUGIN_DESC}\"" + @echo "maintainer: ${PLUGIN_MAINTAINER}" + @echo "www: https://opnsense.org/" + @echo "prefix: /" + @echo "deps: {" + @for DEP in ${PLUGIN_DEPENDS}; do \ + pkg query ' %n: { version: "%v", origin: "%o" }' $${DEP}; \ + done + @echo "}" + +collect: check + # collect known files present in system + @(cd ${.CURDIR}/src; find * -type f) | \ + (xargs -n1 tar -C /usr/local -cpf -) | \ + tar -C ${.CURDIR}/src -xpf - + +remove: check + # remove known files and directories from system + @(cd ${.CURDIR}/src; find * -type f) | \ + xargs -n1 -I% rm -f ${DESTDIR}/usr/local/% + @(cd ${.CURDIR}/src; find * -type d) | \ + xargs -n1 -I% rmdir ${DESTDIR}/usr/local/% + +clean: check + @git reset -q . && git checkout -f . && git clean -xdqf . + +.PHONY: check diff --git a/README.md b/README.md new file mode 100644 index 000000000..2b8e35a9e --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +About the OPNsense plugins +========================== + +Brace yourselves, plugins are coming to 16.1. + +The make targets for the root directory: + +list: print a list of all plugin directories + +The make targets for any plugin directory: + +manifest: generate +MANIFEST file +install: install to target directory +remove: remove from target directory +collect: gather updates from target directory +mount: unionfs mount above target directory +umount: unionfs umount from target directory +clean: remove all changes and unknown files diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 000000000..4b95a7159 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,7 @@ +PLUGIN_NAME= test +PLUGIN_VERSION= 1.0 +PLUGIN_DESC= A test package +PLUGIN_DEPENDS= git vim tmux +PLUGIN_MAINTAINER= franco@opnsense.org + +.include "../Mk/plugins.mk" diff --git a/test/src/testdir/testfile.in b/test/src/testdir/testfile.in new file mode 100644 index 000000000..6de7b8c69 --- /dev/null +++ b/test/src/testdir/testfile.in @@ -0,0 +1 @@ +This is a test file.