[maemo-commits] [maemo-commits] r15729 - in projects/haf/trunk: . confml-helper confml-helper/debian
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Jul 2 13:37:55 EEST 2008
- Previous message: [maemo-commits] r15728 - projects/haf/tags/osso-af-startup
- Next message: [maemo-commits] r15730 - in projects/haf/trunk: . osso-af-startup-settings-template osso-af-startup-settings-template/confml osso-af-startup-settings-template/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: marivoll Date: 2008-07-02 13:37:53 +0300 (Wed, 02 Jul 2008) New Revision: 15729 Added: projects/haf/trunk/confml-helper/ projects/haf/trunk/confml-helper/AUTHORS projects/haf/trunk/confml-helper/ChangeLog projects/haf/trunk/confml-helper/Makefile.am projects/haf/trunk/confml-helper/NEWS projects/haf/trunk/confml-helper/README projects/haf/trunk/confml-helper/autogen.sh projects/haf/trunk/confml-helper/configure.ac projects/haf/trunk/confml-helper/confml-changelog projects/haf/trunk/confml-helper/confml-control projects/haf/trunk/confml-helper/confml-copyfiles projects/haf/trunk/confml-helper/confml-get projects/haf/trunk/confml-helper/confml-getxml projects/haf/trunk/confml-helper/confml-instantiate projects/haf/trunk/confml-helper/confml-stylesheet projects/haf/trunk/confml-helper/confml-stylesheet.py projects/haf/trunk/confml-helper/confml-substitute projects/haf/trunk/confml-helper/confml-uninstantiate projects/haf/trunk/confml-helper/debian/ projects/haf/trunk/confml-helper/debian/changelog projects/haf/trunk/confml-helper/debian/compat projects/haf/trunk/confml-helper/debian/control projects/haf/trunk/confml-helper/debian/rules Log: Added. Added: projects/haf/trunk/confml-helper/AUTHORS =================================================================== --- projects/haf/trunk/confml-helper/AUTHORS 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/AUTHORS 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1 @@ +Marius Vollmer <marius.vollmer at nokia.com> Added: projects/haf/trunk/confml-helper/ChangeLog =================================================================== --- projects/haf/trunk/confml-helper/ChangeLog 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/ChangeLog 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,5 @@ +2008-06-17 Marius Vollmer <marius.vollmer at nokia.com> + + * Started. + + Added: projects/haf/trunk/confml-helper/Makefile.am =================================================================== --- projects/haf/trunk/confml-helper/Makefile.am 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/Makefile.am 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,8 @@ +bin_SCRIPTS = confml-get \ + confml-getxml \ + confml-changelog \ + confml-substitute \ + confml-instantiate \ + confml-uninstantiate + +EXTRA_DIST = $(bin_SCRIPTS) Added: projects/haf/trunk/confml-helper/NEWS =================================================================== --- projects/haf/trunk/confml-helper/NEWS 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/NEWS 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1 @@ +Everyting is new! Added: projects/haf/trunk/confml-helper/README =================================================================== --- projects/haf/trunk/confml-helper/README 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/README 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,44 @@ +confml-helper -- a suite of utilities for instantiating source package + templates from ConfML files + +The following two tools are for instantiating and uninstantiating +templates. They set up the environment expected by the rest of the +utilities and run the confml/instantiate script of the template. Run +them in the top-level directory of the source tree. + + - confml-instantiate CONFML-FILE + + Instantiate the template for the given ConfML value file. + + - confml-uninstantiate + + Revert a instantiated template back to being just a template. + +The rest is for use in confml/instantiate. + + - confml-get SETTING + + Retrieve the value of SETTING as a plain string. + + - confml-getxml SETTING + + Retrieve the value of SETTING as a XML document. + + - confml-substitute + + For each file named like "FILE.template", write a new file "FILE". + Each occurrence of "@SETTING@" (upper case) in "FOO.template" is + replaced with the result of calling "confml-get setting" (lower case) + in "FILE". + + - confml-copyfiles + + Does something appropriate for resource files that need to be copied + into the source tree from the outside. + + - confml-changelog + + Adjust debian/changelog as appropriate. First, all entries added by + previous invokations of confml-changelog are removed. Then, a new + entry added describing the instantiation, if this is indeed a + instantiation (and not a uninstantiation). Added: projects/haf/trunk/confml-helper/autogen.sh =================================================================== --- projects/haf/trunk/confml-helper/autogen.sh 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/autogen.sh 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,2 @@ +#! /bin/sh +autoreconf --force --install Property changes on: projects/haf/trunk/confml-helper/autogen.sh ___________________________________________________________________ Name: svn:executable + * Added: projects/haf/trunk/confml-helper/configure.ac =================================================================== --- projects/haf/trunk/confml-helper/configure.ac 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/configure.ac 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,9 @@ +AC_INIT(confml-helper, 0) +AC_CONFIG_SRCDIR([README]) +AM_INIT_AUTOMAKE + +AC_PROG_INSTALL + +AC_CONFIG_FILES([Makefile]) + +AC_OUTPUT Added: projects/haf/trunk/confml-helper/confml-changelog =================================================================== --- projects/haf/trunk/confml-helper/confml-changelog 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/confml-changelog 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,52 @@ +#! /bin/sh + +grep_field () { + f=$1 + grep ^$f: | sed "s/^$f:[ ]*//" +} + +grep_control () { + grep_field $1 <debian/control +} + +grep_changelog () { + dpkg-parsechangelog | grep_field $1 +} + +# kill all previously added entries +awk <debian/changelog >debian/changelog.tmp ' + BEGIN { ignore=1 } + /^.*-template/ { ignore=0 } + { if (!ignore) print } ' \ +&& mv debian/changelog.tmp debian/changelog + +if [ -n "$CONFML_INPUT" ]; then + + if [ -z "$CONFML_VARIANT" ]; then + echo >&2 "CONFML_VARIANT not set" + exit 1 + fi + if [ -z "$CONFML_VERSION" ]; then + echo >&2 "CONFML_VERSION not set" + exit 1 + fi + if [ -z "$CONFML_MAINTAINER" ]; then + echo >&2 "CONFML_MAINTAINER not set" + exit 1 + fi + + package=`grep_control Source` + version=`grep_changelog Version` + now=`date -R` + + # add new entry + cat <<EOF - debian/changelog >debian/changelog.tmp +$package ($version+$CONFML_VERSION) unstable; urgency=low + + * Instantiated for $CONFML_VARIANT. + + -- $CONFML_MAINTAINER $now + +EOF + mv debian/changelog.tmp debian/changelog +fi Property changes on: projects/haf/trunk/confml-helper/confml-changelog ___________________________________________________________________ Name: svn:executable + * Added: projects/haf/trunk/confml-helper/confml-control =================================================================== --- projects/haf/trunk/confml-helper/confml-control 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/confml-control 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# vim:set sts=4 sw=4 et: + +import sys +import os + +def main(): + + #print "Usage: "+sys.argv[0]+" [<debiancontrol>] " + variant_suffix = 'example' + + e = os.getenv('VARIANT_SUFFIX') + if e is not None: + variant_suffix = e + + if len(sys.argv) > 1: + ctrl = sys.argv[1] + '.template' + else: + ctrl = 'debian/control.template' + + ofname = ctrl[:-9] + print "outputting to: " + ofname + + f = open(ctrl, 'r') + of = open(ofname, 'w') + + for line in f.readlines(): + of.write(line.replace('@VARIANT_SUFFIX@', variant_suffix)) + + f.close() + of.close() + +if __name__ == "__main__": + main() Property changes on: projects/haf/trunk/confml-helper/confml-control ___________________________________________________________________ Name: svn:executable + * Added: projects/haf/trunk/confml-helper/confml-copyfiles =================================================================== --- projects/haf/trunk/confml-helper/confml-copyfiles 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/confml-copyfiles 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# vim:set sts=4 sw=4 et: + +import sys +import shutil +import os + +try: + from lxml import etree + #print "running with lxml.etree" +except ImportError: + try: + # Python 2.5 + import xml.etree.cElementTree as etree + #print "running with cElementTree on Python 2.5+" + except ImportError: + try: + # Python 2.5 + import xml.etree.ElementTree as etree + #print "running with ElementTree on Python 2.5+" + except ImportError: + try: + # normal cElementTree install + import cElementTree as etree + #print "running with cElementTree" + except ImportError: + try: + # normal ElementTree install + import elementtree.ElementTree as etree + #print "running with ElementTree" + except ImportError: + #print "Failed to import ElementTree from any known place" + sys.exit() + + +def main(): + + if len(sys.argv) < 3: + print "Usage: "+sys.argv[0]+" <confml> <settingref> <destination>" + sys.exit(1) + + f = open(sys.argv[1], 'r') + confml = etree.parse(f) + f.close() + + xpath = sys.argv[2] + + nspath = '/confml:configuration/confml:data' + if not xpath.startswith('/'): + nspath += '/' + + for part in xpath.split('/'): + if len(part) > 0 and part.find('*') < 0: + nspath += 'confml:' + nspath += part + '/' + + if nspath.endswith('/'): + nspath = nspath[:-1] + + print "xpath is: " + nspath + srcs = confml.xpath(nspath, namespaces={'confml': 'http://www.s60.com/xml/confml/1'}) + for src in srcs: + shutil.copy(os.path.join(os.path.dirname(sys.argv[1]), src.text), sys.argv[3]) + +if __name__ == "__main__": + main() Property changes on: projects/haf/trunk/confml-helper/confml-copyfiles ___________________________________________________________________ Name: svn:executable + * Added: projects/haf/trunk/confml-helper/confml-get =================================================================== --- projects/haf/trunk/confml-helper/confml-get 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/confml-get 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,8 @@ +#! /bin/sh + +feature="$CONFML_FEATURE" +input="$CONFML_INPUT" + +setting="$1" + +xmlstarlet sel -T -N confml=http://www.s60.com/xml/confml/1 -t -c confml:configuration/confml:data/confml:$feature/confml:$setting "$input" Property changes on: projects/haf/trunk/confml-helper/confml-get ___________________________________________________________________ Name: svn:executable + * Added: projects/haf/trunk/confml-helper/confml-getxml =================================================================== --- projects/haf/trunk/confml-helper/confml-getxml 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/confml-getxml 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,8 @@ +#! /bin/sh + +feature="$CONFML_FEATURE" +input="$CONFML_INPUT" + +setting="$1" + +xmlstarlet sel -N confml=http://www.s60.com/xml/confml/1 -t -v confml:configuration/confml:data/confml:$feature/confml:$setting "$input" Property changes on: projects/haf/trunk/confml-helper/confml-getxml ___________________________________________________________________ Name: svn:executable + * Added: projects/haf/trunk/confml-helper/confml-instantiate =================================================================== --- projects/haf/trunk/confml-helper/confml-instantiate 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/confml-instantiate 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,28 @@ +#! /bin/sh + +# Usage: confml-instantiate file.confml + +# XXX - how do we figure out name, version and maintainer from the +# confml file? + +export CONFML_INPUT="$1" + +get_meta () { + xmlstarlet sel -T -N confml=http://www.s60.com/xml/confml/1 -t -c confml:configuration/confml:meta/confml:$1 "$CONFML_INPUT" +} + +get_template_name () { + grep '^[^ ]*-template' debian/changelog | head -1 | sed -e 's/-template.*//' +} + +export CONFML_FEATURE=`get_template_name` +export CONFML_VARIANT=`get_meta id` +export CONFML_VERSION=`get_meta version` +export CONFML_MAINTAINER=`get_meta owner` + +if [ -x confml/instantiate ]; then + confml/instantiate +else + confml-substitute + confml-changelog +fi Property changes on: projects/haf/trunk/confml-helper/confml-instantiate ___________________________________________________________________ Name: svn:executable + * Added: projects/haf/trunk/confml-helper/confml-stylesheet =================================================================== --- projects/haf/trunk/confml-helper/confml-stylesheet 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/confml-stylesheet 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ $# -lt 2 ]; then + echo "Usage: $0 <XMLsource> <XSLT>" + exit 1 +fi + +xsltproc $2 $1 Property changes on: projects/haf/trunk/confml-helper/confml-stylesheet ___________________________________________________________________ Name: svn:executable + * Added: projects/haf/trunk/confml-helper/confml-stylesheet.py =================================================================== --- projects/haf/trunk/confml-helper/confml-stylesheet.py 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/confml-stylesheet.py 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# vim:set sts=4 sw=4 et: + +import sys + +try: + from lxml import etree + #print "running with lxml.etree" +except ImportError: + try: + # Python 2.5 + import xml.etree.cElementTree as etree + #print "running with cElementTree on Python 2.5+" + except ImportError: + try: + # Python 2.5 + import xml.etree.ElementTree as etree + #print "running with ElementTree on Python 2.5+" + except ImportError: + try: + # normal cElementTree install + import cElementTree as etree + #print "running with cElementTree" + except ImportError: + try: + # normal ElementTree install + import elementtree.ElementTree as etree + #print "running with ElementTree" + except ImportError: + #print "Failed to import ElementTree from any known place" + sys.exit() + + +def main(): + + if len(sys.argv) < 3: + print "Usage: "+sys.argv[0]+" <XMLsrc> <XSLT>" + sys.exit(1) + + f = open(sys.argv[1], 'r') + confml = etree.parse(f) + f.close() + + f = open(sys.argv[2], 'r') + xslt_doc = etree.parse(f) + f.close() + #transform = etree.XSLT(xslt_doc) + #result = transform(confml) + result = confml.xslt(xslt_doc) + root = result.getroot() + if root is not None: + print etree.tostring(root, pretty_print=True) + else: + print str(result) + +if __name__ == "__main__": + main() Property changes on: projects/haf/trunk/confml-helper/confml-stylesheet.py ___________________________________________________________________ Name: svn:executable + * Added: projects/haf/trunk/confml-helper/confml-substitute =================================================================== --- projects/haf/trunk/confml-helper/confml-substitute 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/confml-substitute 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,84 @@ +#! /bin/sh + +set -e + +require_var () { + val=`eval 'echo $'"$1"` + if [ -z "$val" ]; then + echo >&2 "$1 not set" + exit 1 + fi +} + +if [ -z "$CONFML_INPUT" ]; then + CONFML_VARIANT=template + CONFML_VERSION=UNKNOWN +else + require_var CONFML_FEATURE + require_var CONFML_VARIANT + require_var CONFML_VERSION +fi +require_var CONFML_MAINTAINER + +confml_add_substitution () { + # pattern value + sedexpr="$sedexpr -e 's/$1/$2/g'" + echo >&2 $1: $2 +} + +confml_substitute_file () { + # file... + for file in "$@"; do + eval sed $sedexpr <$file.template >$file + done +} + +confml_parameter () { + # name... + for name in "$@"; do + upper=`echo $name | tr a-z A-Z` + pattern="@$upper@" + value=`confml-get $name` + + if [ -z "$value" ]; then + echo >&2 "No value for setting '$CONFML_FEATURE/$name' in $CONFML_INPUT" + exit 1 + fi + + confml_add_substitution $pattern "$value" + done +} + +select_by_prefix () { + grep "^$1" | sed -e "s,^$1,," +} + +confml_all_paramters () { + if [ -z "$CONFML_INPUT" ]; then + echo "" + else + xmlstarlet el -u "$CONFML_INPUT" \ + | select_by_prefix configuration/data/$CONFML_FEATURE/ + fi +} + +confml_init_substitution () { + sedexpr="" + confml_add_substitution @VARIANT@ $CONFML_VARIANT + confml_add_substitution @VARIANT_VERSION@ $CONFML_VERSION + confml_add_substitution @VARIANT_MAINTAINER@ "$CONFML_MAINTAINER" +} + +confml_init_substitution + +params=`confml_all_paramters` +for p in $params; do + confml_parameter $p +done + +files=`find . -name '*.template'` +for ft in $files; do + f=`echo $ft | sed -e 's/.template//'` + echo file: $f + confml_substitute_file $f +done Property changes on: projects/haf/trunk/confml-helper/confml-substitute ___________________________________________________________________ Name: svn:executable + * Added: projects/haf/trunk/confml-helper/confml-uninstantiate =================================================================== --- projects/haf/trunk/confml-helper/confml-uninstantiate 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/confml-uninstantiate 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,45 @@ +#! /bin/sh + +# Usage: confml-complete + +export CONFML_INPUT="" + +grep_field () { + f=$1 + grep ^$f: | sed "s/^$f:[ ]*//" +} + +offset=0 + +grep_changelog () { + dpkg-parsechangelog --offset $offset --count 1 | grep_field $1 +} + +find_template_offset () { + offset=0 + while true; do + source=`grep_changelog Source` + if [ -z "$source" ]; then + echo >&2 "No *-template entry found in debian/changelog" + exit 1 + fi + if echo $source | grep -q -- '-template$'; then + break + fi + offset=`expr $offset + 1` + done +} + +find_template_offset + +export CONFML_FEATURE=`grep_changelog Source | sed -e 's/-template$//'` +export CONFML_VARIANT="template" +export CONFML_VERSION="" +export CONFML_MAINTAINER=`grep_changelog Maintainer` + +if [ -x confml/instantiate ]; then + confml/instantiate +else + confml-substitute + confml-changelog +fi Property changes on: projects/haf/trunk/confml-helper/confml-uninstantiate ___________________________________________________________________ Name: svn:executable + * Added: projects/haf/trunk/confml-helper/debian/changelog =================================================================== --- projects/haf/trunk/confml-helper/debian/changelog 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/debian/changelog 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,6 @@ +confml-helper (0~unreleased) unstable; urgency=low + + * New. + + -- Marius Vollmer <marius.vollmer at nokia.com> Tue, 17 Jun 2008 13:42:57 +0300 + Added: projects/haf/trunk/confml-helper/debian/compat =================================================================== --- projects/haf/trunk/confml-helper/debian/compat 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/debian/compat 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1 @@ +4 Added: projects/haf/trunk/confml-helper/debian/control =================================================================== --- projects/haf/trunk/confml-helper/debian/control 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/debian/control 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,11 @@ +Source: confml-helper +Section: misc +Priority: optional +Maintainer: Marius Vollmer <marius.vollmer at nokia.com> +Build-Depends-Indep: debhelper +Standards-Version: 3.5.10 + +Package: confml-helper +Architecture: all +Depends: xmlstarlet +Description: Utilities for instantiation source package templates Added: projects/haf/trunk/confml-helper/debian/rules =================================================================== --- projects/haf/trunk/confml-helper/debian/rules 2008-07-01 14:52:40 UTC (rev 15728) +++ projects/haf/trunk/confml-helper/debian/rules 2008-07-02 10:37:53 UTC (rev 15729) @@ -0,0 +1,61 @@ +#!/usr/bin/make -f + +config.status: + if [ ! -x configure ]; then ./autogen.sh; fi + dh_testdir + CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" ./configure --prefix=/usr --sysconfdir=/etc --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --disable-static + +build: config.status + dh_testdir + $(MAKE) + +clean: config.status + dh_testdir + dh_testroot + $(MAKE) clean + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + $(MAKE) install DESTDIR=$(CURDIR)/debian/confml-helper + +binary-indep: install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs +# dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit +# dh_installcron +# dh_installinfo +# dh_installman +# dh_link +# dh_strip +# dh_compress + dh_fixperms +# dh_perl +# dh_python +# dh_makeshlibs + dh_installdeb +# dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary-arch: install + dh_testdir + +binary: binary-indep binary-arch + + +.PHONY: binary binary-arch binary-indep clean \ No newline at end of file Property changes on: projects/haf/trunk/confml-helper/debian/rules ___________________________________________________________________ Name: svn:executable + *
- Previous message: [maemo-commits] r15728 - projects/haf/tags/osso-af-startup
- Next message: [maemo-commits] r15730 - in projects/haf/trunk: . osso-af-startup-settings-template osso-af-startup-settings-template/confml osso-af-startup-settings-template/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]