mirror of
https://github.com/opnsense/plugins.git
synced 2026-02-03 20:40:37 -05:00
Framework: support inline built-time replacement
Use Sunny Valley vendor plugin to showcase the implementation. PR://github.com/opnsense/plugins/pull/1693
This commit is contained in:
parent
f1a69249f9
commit
d3ce811139
6 changed files with 62 additions and 25 deletions
8
Makefile
8
Makefile
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2015-2019 Franco Fichtner <franco@opnsense.org>
|
||||
# Copyright (c) 2015-2020 Franco Fichtner <franco@opnsense.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
|
|
@ -23,13 +23,11 @@
|
|||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
PAGER?= less
|
||||
|
||||
PLUGIN_ABI= 20.1
|
||||
|
||||
all:
|
||||
@cat ${.CURDIR}/README.md | ${PAGER}
|
||||
|
||||
.include "Mk/defaults.mk"
|
||||
|
||||
CATEGORIES= benchmarks databases devel dns mail misc net-mgmt \
|
||||
net security sysutils vendor www
|
||||
|
||||
|
|
|
|||
50
Mk/defaults.mk
Normal file
50
Mk/defaults.mk
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# Copyright (c) 2016-2020 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.
|
||||
|
||||
LOCALBASE?= /usr/local
|
||||
PAGER?= less
|
||||
|
||||
OPENSSL?= ${LOCALBASE}/bin/openssl
|
||||
|
||||
_FLAVOUR!= if [ -f ${OPENSSL} ]; then ${OPENSSL} version; fi
|
||||
FLAVOUR?= ${_FLAVOUR:[1]}
|
||||
|
||||
PKG!= which pkg || echo true
|
||||
GIT!= which git || echo true
|
||||
ARCH!= uname -p
|
||||
|
||||
PLUGIN_ABI?= 20.1
|
||||
PLUGIN_ARCH?= ${ARCH}
|
||||
PLUGIN_FLAVOUR= ${FLAVOUR}
|
||||
|
||||
REPLACEMENTS= PLUGIN_ABI \
|
||||
PLUGIN_ARCH \
|
||||
PLUGIN_FLAVOUR
|
||||
|
||||
SED_REPLACE= # empty
|
||||
|
||||
.for REPLACEMENT in ${REPLACEMENTS}
|
||||
SED_REPLACE+= -e "s=%%${REPLACEMENT}%%=${${REPLACEMENT}}=g"
|
||||
.endfor
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2015-2019 Franco Fichtner <franco@opnsense.org>
|
||||
# Copyright (c) 2015-2020 Franco Fichtner <franco@opnsense.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
|
|
@ -25,9 +25,7 @@
|
|||
|
||||
all: check
|
||||
|
||||
LOCALBASE?= /usr/local
|
||||
PKG!= which pkg || echo true
|
||||
ARCH!= uname -p
|
||||
.include "defaults.mk"
|
||||
|
||||
PLUGIN_ARCH?= ${ARCH}
|
||||
PLUGIN_PHP?= 72
|
||||
|
|
@ -180,11 +178,17 @@ install: check
|
|||
@(cd ${.CURDIR}/src; find * -type f) | while read FILE; do \
|
||||
tar -C ${.CURDIR}/src -cpf - $${FILE} | \
|
||||
tar -C ${DESTDIR}${LOCALBASE} -xpf -; \
|
||||
if [ "$${FILE%%.in}" != "$${FILE}" ]; then \
|
||||
sed -i '' ${SED_REPLACE} "${DESTDIR}${LOCALBASE}/$${FILE}"; \
|
||||
mv "${DESTDIR}${LOCALBASE}/$${FILE}" "${DESTDIR}${LOCALBASE}/$${FILE%%.in}"; \
|
||||
fi; \
|
||||
done
|
||||
@echo "${PLUGIN_PKGVERSION}" > "${DESTDIR}${LOCALBASE}/opnsense/version/${PLUGIN_NAME}"
|
||||
|
||||
plist: check
|
||||
@(cd ${.CURDIR}/src; find * -type f) | while read FILE; do \
|
||||
if [ -f "$${FILE}.in" ]; then continue; fi; \
|
||||
FILE="$${FILE%%.in}"; \
|
||||
echo ${LOCALBASE}/$${FILE}; \
|
||||
done
|
||||
@echo "${LOCALBASE}/opnsense/version/${PLUGIN_NAME}"
|
||||
|
|
|
|||
3
vendor/sunnyvalley/+POST_DEINSTALL
vendored
3
vendor/sunnyvalley/+POST_DEINSTALL
vendored
|
|
@ -1,3 +0,0 @@
|
|||
REPO_FILE=/usr/local/etc/pkg/repos/SunnyValley.conf
|
||||
|
||||
rm -f "${REPO_FILE}"
|
||||
12
vendor/sunnyvalley/+POST_INSTALL
vendored
12
vendor/sunnyvalley/+POST_INSTALL
vendored
|
|
@ -1,12 +0,0 @@
|
|||
OPNSENSE_FLAVOR=$(/usr/local/sbin/opnsense-version -f)
|
||||
REPO_FILE=/usr/local/etc/pkg/repos/SunnyValley.conf
|
||||
|
||||
case "${OPNSENSE_FLAVOR}" in
|
||||
OpenSSL|LibreSSL)
|
||||
echo "Configuring repository for ${OPNSENSE_FLAVOR} flavor"
|
||||
sed "s/%%FLAVOR%%/${OPNSENSE_FLAVOR}/g" "${REPO_FILE}".template > "${REPO_FILE}"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported OPNsense flavor (${OPNSENSE_FLAVOR}), aborting"
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
SunnyValley: {
|
||||
fingerprints: "/usr/local/etc/pkg/fingerprints/SunnyValley",
|
||||
url: "https://updates.sunnyvalley.io/opnsense/${ABI}/%%FLAVOR%%/repo",
|
||||
url: "https://updates.sunnyvalley.io/opnsense/${ABI}/%%PLUGIN_FLAVOUR%%/repo",
|
||||
signature_type: "fingerprints",
|
||||
priority: 7,
|
||||
enabled: yes
|
||||
Loading…
Reference in a new issue