diff --git a/Makefile b/Makefile index cf5e140..1dcc38d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ STEPS= base kernel ports core iso memstick nano \ - regress clean release skim checkout + regress clean release skim checkout plugins .PHONY: ${STEPS} PAGER?= less @@ -21,6 +21,7 @@ SETTINGS?= latest _VERSION!= date '+%Y%m%d%H%M' VERSION?= ${_VERSION} PORTSREFDIR?= /usr/freebsd-ports +PLUGINSDIR?= /usr/plugins TOOLSDIR?= /usr/tools PORTSDIR?= /usr/ports COREDIR?= /usr/core @@ -29,7 +30,7 @@ SRCDIR?= /usr/src # A couple of meta-targets for easy use: source: base kernel -packages: ports core +packages: ports core plugins sets: source packages images: iso memstick nano everything: sets images @@ -51,6 +52,6 @@ ${TARGET}: ${_TARGET} ${STEP}: @cd build && sh ./${.TARGET}.sh \ -f ${FLAVOUR} -n ${NAME} -v ${VERSION} -s ${SETTINGS} \ - -S ${SRCDIR} -P ${PORTSDIR} -T ${TOOLSDIR} \ + -S ${SRCDIR} -P ${PORTSDIR} -p ${PLUGINSDIR} -T ${TOOLSDIR} \ -C ${COREDIR} -R ${PORTSREFDIR} ${${STEP}_ARGS} .endfor diff --git a/README.md b/README.md index da82e4d..1a8b2ea 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ About the OPNsense tools ======================== -In conjunction with src.git, ports.git and core.git they create -sets, packages and images for the OPNsense project. The license +In conjunction with src.git, ports.git, core.git and plugins.git they +create sets, packages and images for the OPNsense project. The license is a standard BSD 2-Clause as reproduced here for your convenience: Copyright (c) 2014-2015 Franco Fichtner @@ -45,6 +45,7 @@ src): # pkg install git # cd /usr # rm -rf src ports + # git clone https://github.com/opnsense/plugins # git clone https://github.com/opnsense/ports # git clone https://github.com/opnsense/tools # git clone https://github.com/opnsense/core @@ -96,6 +97,10 @@ Wrap up our core as a package: # make core +Build additional plugins if needed: + + # make plugins + A cdrom live image is created using: # make iso diff --git a/build/checkout.sh b/build/checkout.sh index 04dad7f..efe6cde 100644 --- a/build/checkout.sh +++ b/build/checkout.sh @@ -29,7 +29,7 @@ set -e . ./common.sh && $(${SCRUB_ARGS}) -for GITDIR in ${SRCDIR} ${PORTSDIR} ${COREDIR}; do +for GITDIR in ${SRCDIR} ${PORTSDIR} ${COREDIR} ${PLUGINS}; do echo ">>> Updating ${GITDIR}:" git_update ${GITDIR} ${1} done diff --git a/build/common.sh b/build/common.sh index f9138d9..19f71dd 100644 --- a/build/common.sh +++ b/build/common.sh @@ -36,7 +36,7 @@ usage() exit 1 } -while getopts C:f:n:P:R:S:s:T:v: OPT; do +while getopts C:f:n:P:p:R:S:s:T:v: OPT; do case ${OPT} in C) export COREDIR=${OPTARG} @@ -54,6 +54,10 @@ while getopts C:f:n:P:R:S:s:T:v: OPT; do export PORTSDIR=${OPTARG} SCRUB_ARGS=${SCRUB_ARGS};shift;shift ;; + p) + export PLUGINSDIR=${OPTARG} + SCRUB_ARGS=${SCRUB_ARGS};shift;shift + ;; R) export PORTSREFDIR=${OPTARG} SCRUB_ARGS=${SCRUB_ARGS};shift;shift @@ -85,6 +89,7 @@ if [ -z "${PRODUCT_NAME}" -o \ -z "${PRODUCT_VERSION}" -o \ -z "${PRODUCT_SETTINGS}" -o \ -z "${TOOLSDIR}" -o \ + -z "${PLUGINSDIR}" -o \ -z "${PORTSDIR}" -o \ -z "${PORTSREFDIR}" -o \ -z "${COREDIR}" -o \ @@ -381,7 +386,7 @@ setup_stage() { echo ">>> Setting up stage in ${1}" - local MOUNTDIRS="/dev /usr/src /usr/ports /usr/core" + local MOUNTDIRS="/dev ${SRCDIR} ${PORTSDIR} ${COREDIR} ${PLUGINSDIR}" # might have been a chroot for DIR in ${MOUNTDIRS}; do diff --git a/build/plugins.sh b/build/plugins.sh new file mode 100644 index 0000000..8eadee1 --- /dev/null +++ b/build/plugins.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +# 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. + +set -e + +. ./common.sh && $(${SCRUB_ARGS}) + +setup_stage ${STAGEDIR} +setup_base ${STAGEDIR} +setup_clone ${STAGEDIR} ${PLUGINSDIR} +extract_packages ${STAGEDIR} +install_packages ${STAGEDIR} + +PLUGINS=$(make -C ${PLUGINSDIR} list) + +for PLUGIN in ${PLUGINS}; do + chroot ${STAGEDIR} /bin/sh -es << EOF +# clear the internal staging area +rm -rf ${STAGEDIR} +mkdir ${STAGEDIR} + +make -C ${PLUGINSDIR}/${PLUGIN} DESTDIR=${STAGEDIR} manifest > ${STAGEDIR}/+MANIFEST +make -C ${PLUGINSDIR}/${PLUGIN} DESTDIR=${STAGEDIR} install > ${STAGEDIR}/plist + +echo -n ">>> Creating custom package for plugin ${PLUGIN}... " +pkg create -m ${STAGEDIR} -r ${STAGEDIR} -p ${STAGEDIR}/plist -o ${PACKAGESDIR}/All +echo "done" +EOF +done + +bundle_packages ${STAGEDIR}