summaryrefslogtreecommitdiffhomepage
path: root/libs/uvl/root
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-01-02 19:26:37 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-01-02 19:26:37 +0000
commit052f65950cc195adc1589566ca9725de0ad83c63 (patch)
treefe273278b704a7ea6b1ce707680a1d8412d6eb00 /libs/uvl/root
parent800a2630497e1ec2c61199b3bc645d778c714529 (diff)
libs: drop uvl and uvldoc
Diffstat (limited to 'libs/uvl/root')
-rw-r--r--libs/uvl/root/lib/uci/schema/meta/schema403
-rwxr-xr-xlibs/uvl/root/usr/bin/uvl241
-rwxr-xr-xlibs/uvl/root/usr/bin/uvlc23
3 files changed, 0 insertions, 667 deletions
diff --git a/libs/uvl/root/lib/uci/schema/meta/schema b/libs/uvl/root/lib/uci/schema/meta/schema
deleted file mode 100644
index a4fed422d9..0000000000
--- a/libs/uvl/root/lib/uci/schema/meta/schema
+++ /dev/null
@@ -1,403 +0,0 @@
-# UVL - Reference-Spec
-# This is a meta scheme defining the format of uci schemes.
-# $Id$
-
-package schema
-
-#-------------------------------------------------------------------------------
-# Central package definition
-#
-# config package
-# option ...
-#-------------------------------------------------------------------------------
-
-# Section definition (schema.@package)
-config section
- option name 'package'
- option title 'Definition of uci package'
- option package 'schema'
- option required false
- option named false
- option unique true
- option dynamic false
-
-# Section title (schema.@package.title)
-config variable
- option name 'title'
- option title 'Title of the defined package'
- option section 'schema.package'
- option type 'variable'
- option datatype 'string'
- option required false
-
-# Section description (schema.@package.description)
-config variable
- option name 'description'
- option title 'Description of the defined package'
- option section 'schema.package'
- option type 'lazylist'
- option datatype 'string'
- option required false
-
-
-#-------------------------------------------------------------------------------
-# Central section definition
-#
-# config section
-# option ...
-#-------------------------------------------------------------------------------
-
-# Section definition (schema.@section)
-config section
- option name 'section'
- option title 'Definition of uci section'
- option package 'schema'
- option required false
- option named false
- option unique false
- option dynamic false
-
-# Section name (schema.@section.name)
-config variable
- option name 'name'
- option title 'Name of the defined section'
- option section 'schema.section'
- option type 'variable'
- option datatype 'string'
- option required true
-
-# Section package (schema.@section.package)
-config variable
- option name 'package'
- option title 'Parent package of the defined section'
- option section 'schema.section'
- option type 'variable'
- option datatype 'string'
- option required true
-
-# Section title (schema.@section.title)
-config variable
- option name 'title'
- option title 'Title of the defined section'
- option section 'schema.section'
- option type 'variable'
- option datatype 'string'
- option required false
-
-# Section description (schema.@section.description)
-config variable
- option name 'description'
- option title 'Description of the defined section'
- option section 'schema.section'
- option type 'lazylist'
- option datatype 'string'
- option required false
-
-# Section dependencies (schema.@section.depends)
-config variable
- option name 'depends'
- option title 'List of dependencies within and between defined sections'
- option section 'schema.section'
- option type 'lazylist'
- option datatype 'string'
- option required false
-
-# Section required flag (schema.@section.required)
-config variable
- option name 'required'
- option title 'Specify whether at least one instance of this section type must be defined in config'
- option section 'schema.section'
- option type 'variable'
- option datatype 'boolean'
- option required false
-
-# Section unique flag (schema.@section.unique)
-config variable
- option name 'unique'
- option title 'Specify whether only one instance of this section type is allowed in config'
- option section 'schema.section'
- option type 'variable'
- option datatype 'boolean'
- option required false
-
-# Section named flag (schema.@section.named)
-config variable
- option name 'named'
- option title 'Specify whether sections of this type must have a name set (are not anonymous)'
- option section 'schema.section'
- option type 'variable'
- option datatype 'boolean'
- option required false
-
-# Section dynamic flag (schema.@section.dynamic)
-config variable
- option name 'dynamic'
- option title 'Specify whether sections of this type may contain arbitary, not specified options'
- option section 'schema.section'
- option type 'variable'
- option datatype 'boolean'
- option required false
-
-
-#-------------------------------------------------------------------------------
-# Central variable definition
-#
-# config variable
-# option ...
-#-------------------------------------------------------------------------------
-
-# Variable definition (schema.@variable)
-config section
- option name 'variable'
- option title 'Definition of uci variable'
- option package 'schema'
- option required false
- option named false
- option unique false
- option dynamic false
-
-# Variable name (schema.@variable.name)
-config variable
- option name 'name'
- option title 'Name of the defined variable'
- option section 'schema.variable'
- option type 'variable'
- option datatype 'string'
- option required true
-
-# Variable section (schema.@variable.section)
-config variable
- option name 'section'
- option title 'Parent section of the defined variable'
- option section 'schema.variable'
- option type 'variable'
- option datatype 'string'
- option required true
-
-# Variable title (schema.@variable.title)
-config variable
- option name 'title'
- option title 'Title of the defined variable'
- option section 'schema.variable'
- option type 'variable'
- option datatype 'string'
- option required false
-
-# Variable description (schema.@variable.description)
-config variable
- option name 'description'
- option title 'Description of the defined variable'
- option section 'schema.variable'
- option type 'lazylist'
- option datatype 'string'
- option required false
-
-# Variable dependencies (schema.@variable.depends)
-config variable
- option name 'depends'
- option title 'List of dependencies between defined variables'
- option section 'schema.variable'
- option type 'lazylist'
- option datatype 'string'
- option required false
-
-# Variable required flag (schema.@variable.required)
-config variable
- option name 'required'
- option title 'Specify whether this variable must be set in config'
- option section 'schema.variable'
- option type 'variable'
- option datatype 'boolean'
- option required false
-
-# Variable multiple values flag (schema.@variable.multival)
-config variable
- option name 'multival'
- option title 'Specify whether this variable may contain multiple values separated by space'
- option section 'schema.variable'
- option type 'variable'
- option datatype 'boolean'
- option required false
-
-# Variable type (schema.@variable.type)
-config variable
- option name 'type'
- option title 'Type of this variable'
- option section 'schema.variable'
- option type 'enum'
- option datatype 'string'
- option required false
-
-# Plain variable type (schema.@variable.type=variable)
-config enum
- option value 'variable'
- option title 'This is a plain variable'
- option variable 'schema.variable.type'
-
-# Enum variable type (schema.@variable.type=enum)
-config enum
- option value 'enum'
- option title 'This is a enum variable'
- option variable 'schema.variable.type'
-
-# List variable type (schema.@variable.type=list)
-config enum
- option value 'list'
- option title 'This is a list variable'
- option variable 'schema.variable.type'
-
-# List-or-Option variable type (schema.@variable.type=lazylist)
-config enum
- option value 'lazylist'
- option title 'This is a list or option variable'
- option variable 'schema.variable.type'
-
-# Reference variable type (schema.@variable.type=reference)
-config enum
- option value 'reference'
- option title 'This is a reference (valueof) variable'
- option variable 'schema.variable.type'
-
-# Variable datatype (schema.@variable.datatype)
-config variable
- option name 'datatype'
- option title 'Datatype of this variable'
- option section 'schema.variable'
- option type 'variable'
- option datatype 'string'
- option required false
-
-# Variable default value (schema.@variable.default)
-config variable
- option name 'default'
- option title 'Default value of this variable'
- option section 'schema.variable'
- option type 'variable'
- option datatype 'string'
- option required false
-
-# Variable minimum length (schema.@variable.minlength)
-config variable
- option name 'minlength'
- option title 'Minimum length of this variable'
- option section 'schema.variable'
- option type 'variable'
- option datatype 'uint'
- option required false
-
-# Variable maximum length (schema.@variable.minlength)
-config variable
- option name 'maxlength'
- option title 'Maximum length of this variable'
- option section 'schema.variable'
- option type 'variable'
- option datatype 'uint'
- option required false
-
-# Variable minimum value (schema.@variable.minlength)
-config variable
- option name 'minimum'
- option title 'Minimum value of this variable'
- option section 'schema.variable'
- option type 'variable'
- option datatype 'integer'
- option required false
-
-# Variable maximum value (schema.@variable.minlength)
-config variable
- option name 'maximum'
- option title 'Maximum value of this variable'
- option section 'schema.variable'
- option type 'variable'
- option datatype 'integer'
- option required false
-
-# Variable validators (schema.@variable.validator)
-config variable
- option name 'validator'
- option title 'Datatype of this variable'
- option section 'schema.variable'
- option type 'lazylist'
- option datatype 'string'
- option required false
-
-# Variable value references (schema.@variable.valueof)
-config variable
- option name 'valueof'
- option title 'Reference to section or option to read values from'
- option section 'schema.variable'
- option type 'lazylist'
- option datatype 'string'
- option required false
-
-
-#-------------------------------------------------------------------------------
-# Central enum definition
-#
-# config enum
-# option ...
-#-------------------------------------------------------------------------------
-
-# Enum definition (schema.@enum)
-config section
- option name 'enum'
- option title 'Definition of uci enum value'
- option package 'schema'
- option required false
- option named false
- option unique false
- option dynamic false
-
-# Enum value (schema.@enum.value)
-config variable
- option name 'value'
- option title 'Value of the defined enum value'
- option section 'schema.enum'
- option type 'variable'
- option datatype 'string'
- option required true
-
-# Enum variable (schema.@enum.variable)
-config variable
- option name 'variable'
- option title 'Parent variable of the defined enum value'
- option section 'schema.enum'
- option type 'variable'
- option datatype 'string'
- option required true
-
-# Enum value title (schema.@enum.title)
-config variable
- option name 'title'
- option title 'Title of the defined enum value'
- option section 'schema.enum'
- option type 'variable'
- option datatype 'string'
- option required false
-
-# Enum value description (schema.@enum.description)
-config variable
- option name 'description'
- option title 'Description of the defined enum value'
- option section 'schema.enum'
- option type 'lazylist'
- option datatype 'string'
- option required false
-
-# Enum value dependencies (schema.@enum.depends)
-config variable
- option name 'depends'
- option title 'List of dependencies on defined variables'
- option section 'schema.enum'
- option type 'lazylist'
- option datatype 'string'
- option required false
-
-# Enum value default flag (schema.@enum.default)
-config variable
- option name 'default'
- option title 'Specify whether this value is the default value of the parent enum'
- option section 'schema.enum'
- option type 'variable'
- option datatype 'boolean'
- option required false
diff --git a/libs/uvl/root/usr/bin/uvl b/libs/uvl/root/usr/bin/uvl
deleted file mode 100755
index e5db5c304e..0000000000
--- a/libs/uvl/root/usr/bin/uvl
+++ /dev/null
@@ -1,241 +0,0 @@
-#!/usr/bin/lua
---[[
-
-UCI Validation Layer - Command Line Utility
-(c) 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-(c) 2008 Steven Barth <steven@midlink.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
-]]--
-
-require("luci.uvl")
-require("luci.util")
-
-
-function getopt( arg, options )
- options = options or ""
- local tab = {}
- local args = {}
- for k, v in ipairs(arg) do
- if v:sub(1, 2) == "--" then
- local x = v:find( "=", 1, true )
- if x then
- tab[ v:sub( 3, x-1 ) ] = v:sub( x+1 )
- else
- tab[ v:sub( 3 ) ] = true
- end
- elseif v:sub( 1, 1 ) == "-" then
- local y = 2
- local l = #v
- local jopt
- while ( y <= l ) do
- jopt = v:sub( y, y )
- if options:find( jopt, 1, true ) then
- if y < l then
- tab[ jopt ] = v:sub( y+1 )
- y = l
- else
- tab[ jopt ] = arg[ k + 1 ]
- arg[ k + 1 ] = ""
- end
- else
- tab[ jopt ] = true
- end
- y = y + 1
- end
- elseif #v > 0 then
- table.insert(args, v)
- end
- end
- return tab, args
-end
-
-function genspec(conf)
- require("luci.model.uci")
- require("luci.uvl.datatypes")
-
- local uci = luci.model.uci.cursor()
- local ok, err = uci:load(conf)
-
- if not ok then
- print("Can not load config:", err)
- os.exit(1)
- else
- local function _guess_datatype(v)
- if type(v) == "table" then v = v[1] end
-
- for _, type in ipairs({
- "boolean", "integer", "float", "ip4addr", "ip6addr",
- "macaddr", "directory", "file"
- }) do
- if luci.uvl.datatypes[type](v) then
- return type
- end
- end
- return "string"
- end
-
-
- local co = uci:get_all(conf)
- local ct = { }
- local ca = { }
- local so = { }
- local to = { }
-
- -- count section types
- for _, section in pairs(co) do
- ct[section['.type']] = ( ct[section['.type']] or 0 ) + 1
- ca[section['.type']] = section['.anonymous']
- so[section['.type']] = so[section['.type']] or { }
- to[section['.type']] = to[section['.type']] or { }
-
- for option, value in pairs(section) do
- if option:sub(1,1) ~= "." then
- so[section['.type']][option] = _guess_datatype(value)
- to[section['.type']][option] = ( type(value) == "table" and "list" or "variable" )
- end
- end
- end
-
- -- package name
- print( "package %s" % conf )
-
- -- write section schemes
- for type, count in luci.util.kspairs(ct) do
- print( "\nconfig section" )
- print( "\toption name '%s'" % type )
- print( "\toption title 'Section %s'" % type )
- print( "\toption package '%s'"% conf )
- print( "\toption named %s" % ( ca[type] and 'false' or 'true' ) )
- print( "\toption unique %s" % ( ct[type] > 1 and 'false' or ( ca[type] and 'false' or 'true' ) ) )
- print( "\toption dynamic false" )
- print( "\toption required false" )
-
- -- write option schemes
- for opt, val in luci.util.kspairs(so[type]) do
- print( "\nconfig variable" )
- print( "\toption name '%s'" % opt )
- print( "\toption title 'Option %s'" % opt )
- print( "\toption section '%s.%s'" %{ conf, type } )
- print( "\toption datatype '%s'" % so[type][opt] )
-
- if to[type][opt] ~= "variable" then
- print( "\toption type '%s'" % to[type][opt] )
- end
- end
-
- print("")
- end
-
- end
-end
-
-
-local options, arguments = getopt( arg )
-
-if #arguments ~= 2 or options.help then
- print([=[
-
-uvl - UCI Validation Layer
-$Id$
-(c) 2008 Jo-Philipp Wich, Steven Barth
-
-Usage:
- uvl --help
- uvl [--silent] [--schemedir=DIR] [--configdir=DIR] [--no-strict-sections] \
- [--no-strict-options] [--no-strict-validators] [--no-strict-lists] \
- {verify|verify-scheme|genspec} config[.section[.option]]
-
-Options:
- --help
- Display this help message.
-
- --silent
- Don't produce any output.
-
- --schemedir=DIR
- Use DIR as scheme directory.
-
- --configdir=DIR
- Use DIR as config directory.
-
- --no-strict-sections
- Don't treat sections found in config but not in scheme as error.
-
- --no-strict-options
- Don't treat options found in config but not in scheme as error.
-
- --no-strict-validators
- Don't invalidate config if an external validator fails.
-
- --no-strict-lists
- Don't invalidate lists that are stored options.
-
-Actions:
- verify
- Validate given configuration, section or option.
-
- verify-scheme
- Validate given scheme against the reference meta scheme.
-
- genspec
- Generate a scheme skeleton from given configuration.
- ]=])
- os.exit(255)
-elseif arguments[1] == "verify" or arguments[1] == "verify-scheme" then
- luci.uvl.STRICT_UNKNOWN_SECTIONS =
- ( not options['no-strict-sections'] and true or false )
- luci.uvl.STRICT_UNKNOWN_OPTIONS =
- ( not options['no-strict-options'] and true or false )
- luci.uvl.STRICT_EXTERNAL_VALIDATORS =
- ( not options['no-strict-validators'] and true or false )
- luci.uvl.STRICT_LIST_TYPE =
- ( not options['no-strict-lists'] and true or false )
-
- local uvl = luci.uvl.UVL(
- type(options.schemedir) == "string" and options.schemedir,
- type(options.configdir) == "string" and options.configdir
- )
-
- local cso = luci.util.split( arguments[2], "." )
- local ok, err
-
- if arguments[1] == "verify-scheme" then
- uvl:read_scheme( 'schema', cso[1] )
-
- local uci = uvl.uci.cursor(
- type(options.configdir) == "string"
- and options.configdir or uvl.schemedir .. '/default'
- )
-
- ok, err = uvl:validate_config( cso[1], uci:get_all(cso[1]) )
- if err then err.code = luci.uvl.errors.ERR_SCHEME end
- else
- ok, err = uvl:validate( unpack(cso) )
- end
-
- if ok then
- if not options.silent then
- print( string.format(
- '%s "%s" validates fine!',
- ( arguments[1] == "verify-scheme" and "Scheme" or
- ( #cso == 1 and "Config" or
- ( #cso == 2 and "Section" or "Option" ) ) ),
- table.concat(cso, ".")
- ) )
- end
- os.exit( 0 )
- else
- if not options.silent then print( err and err:string() or "Unknown error" ) end
- os.exit( 1 )
- end
-else
- genspec( arguments[2] )
-end
diff --git a/libs/uvl/root/usr/bin/uvlc b/libs/uvl/root/usr/bin/uvlc
deleted file mode 100755
index caaeb2af6f..0000000000
--- a/libs/uvl/root/usr/bin/uvlc
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/lua
-
-if arg[1] then
- require("luci.util")
- require("luci.uvl")
- require("nixio.fs")
-
- local uvl = luci.uvl.UVL()
- local scheme, err = uvl:get_scheme( arg[1] )
-
- if scheme then
- nixio.fs.writefile(
- "%s/bytecode/%s.lua" %{ uvl.schemedir, arg[1] },
- luci.util.get_bytecode(scheme)
- )
- elseif err then
- print("Error:", err:string())
- else
- print("Error: Can not find scheme:", arg[1])
- end
-else
- print( "Usage: uvlc <scheme>" )
-end