plugins: hello world

This commit is contained in:
Franco Fichtner
2015-07-09 14:13:08 +02:00
commit 51f63d9520
5 changed files with 120 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
PAGER?= less
all:
@cat ${.CURDIR}/README.md | ${PAGER}
PLUGIN_DIRS!= ls -1d [a-z]*
list:
@echo ${PLUGIN_DIRS}
+85
View File
@@ -0,0 +1,85 @@
# Copyright (c) 2015 Franco Fichtner <franco@opnsense.org>
#
# 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 "<above>:${.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
+18
View File
@@ -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
+7
View File
@@ -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"
+1
View File
@@ -0,0 +1 @@
This is a test file.