diff --git a/README.md b/README.md index da5517f27..39fff36df 100644 --- a/README.md +++ b/README.md @@ -159,4 +159,14 @@ the following steps. 6. Create new Pull Request 7. The team will then review, discuss and hopefully merge your changes. +### Package Maintainters +Many of the ZoneMinder configration variable default values are not configurable at build time through autotools or cmake. A new tool called *zmeditconfigdata.sh* has been added to allow package maintainers to manipulate any variable stored in ConfigData.pm without patching the source. + +For example, let's say I have created a new ZoneMinder package that contains the cambolzola javascript file. However, by default cambozola support is turned off. To fix that, add this to the pacakging script: +```bash +./zmeditconfigdata.sh ZM_OPT_CAMBOZOLA yes +``` + +Note that zmeditconfigdata.sh is intended to be called prior to running cmake or configure. + [![Analytics](https://ga-beacon.appspot.com/UA-15147273-6/ZoneMinder/README.md)](https://github.com/igrigorik/ga-beacon) diff --git a/zmeditconfigdata.sh b/zmeditconfigdata.sh new file mode 100755 index 000000000..71b73bb6e --- /dev/null +++ b/zmeditconfigdata.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# This script allows the package maintainer to change the default value +# of any variable specified in ConfigData.pm without writing a patch. +# Run this script from your build folder, before running configure or cmake. + +usage() +{ +cat < /dev/null + + if [ $? -ne 0 ]; then + echo + echo "ERROR: The script cannot find the required command \"${CMD}\"." + echo + exit 1 + fi +done + +escape() +{ +escaped="" +local temp="$(printf %q "$1")" +escaped="$(echo $temp | sed 's/\//\\\//g')" +} + +# Assign variables once they are properly escaped +escape $1 +variable=$escaped +escape $2 +default=$escaped + +# Set the path to ConfigData +if [ -n "$3" ]; then + configdata="$3/ConfigData.pm.in" +else + configdata="./scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in" +fi + +# Check to make sure we can find ConfigData +if [ ! -e "$configdata" ]; then + echo "CONFIGDATA FILE NOT FOUND: $configdata" + exit 1 +fi + +# Now that we've found ConfidData, verify the supplied variable +# is defined inside the ConfigData file. +if [ -z "$(grep $variable $configdata)" ]; then + echo "ZONEMINDER VARIABLE NOT FOUND: $variable" + exit 1 +fi + +# Update the supplied variable with the new default value. +# Don't stare too closely. You will burn your eyes out. +sed -i '/.*'${variable}'.*/{ + $!{ N + s/\(.*'${variable}'.*\n.*\)\"\(.*\)\"/\1\"'${default}'\"/ + t yes + P + D + :yes + + } + }' $configdata + +if [ "$?" != "0" ]; then + echo "SED RETURNED FAILURE" + exit 1 +fi + + +