diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-11-08 13:21:23 -0800 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-11-08 13:21:23 -0800 |
commit | a6845e5858e1bfec8db7545d62081212458b7588 (patch) | |
tree | d6f0cceab183c4d0e69082e6ab4ffea04bfc5977 | |
parent | bafcd6546e55b1255c5bc50abf79f0dfae8f2db6 (diff) | |
download | sgml-skel-a6845e5858e1bfec8db7545d62081212458b7588.tar.gz sgml-skel-a6845e5858e1bfec8db7545d62081212458b7588.tar.bz2 sgml-skel-a6845e5858e1bfec8db7545d62081212458b7588.zip |
add packages
-rw-r--r-- | packaging/edit-xml-catalog.sh | 127 | ||||
-rw-r--r-- | packaging/install-catalog.in | 163 | ||||
-rw-r--r-- | packaging/sgml-skel-edit-cat.diff | 35 | ||||
-rw-r--r-- | packaging/sgml-skel.spec | 6 |
4 files changed, 290 insertions, 41 deletions
diff --git a/packaging/edit-xml-catalog.sh b/packaging/edit-xml-catalog.sh new file mode 100644 index 0000000..38df58d --- /dev/null +++ b/packaging/edit-xml-catalog.sh @@ -0,0 +1,127 @@ +#!/bin/bash + +# $0 $for_root_catalog add|del +export LC_ALL=C + +usage="\ +$0 [-a|-d] [--add|--del] [-c|--catalog /etc/xml/CATALOG] CATALOG_FRAGMENT_FILE" +# TEMP=$(getopt -o ac:dghv \ +# --long add,cat:,catalog:,del,delete,group,help,verbose \ +# -n "$0" -- "$@") +# # Note the quotes around `$TEMP': they are essential! +# eval set -- "$TEMP" + +ROOTCATALOG=/etc/xml/catalog +mode=add +echo=true +while test $# -gt 0; do +# while true ; do + case "$1" in + -h|--help) echo "$usage"; exit 0 ;; + -a|--add) mode=add; shift ;; + -c|--cat*) if test $# -gt 1; then ROOTCATALOG="$2"; shift 2; + else echo "$usage"; exit 1; fi ;; + -d|--del*) mode=del; shift ;; + -g|--group) marker=group; shift ;; + -v|--verbose) verbose="-v"; echo=echo; shift ;; + --) shift ; break ;; + *) break ;; + # *) echo "Internal error!" ; exit 1 ;; + esac +done +FOR_ROOT_CAT=$1 + +[ -z "$FOR_ROOT_CAT" ] && { echo $usage; exit 1; } + +xmlcat=/usr/bin/xmlcatalog +xmllint=/usr/bin/xmllint + +for b in $xmlcat $xmllint; do + [ -x $b ] || { echo "error: $b does not exist" ; exit 1; } +done + +prep_catalog () { + local cat=$1 + [ -s $cat ] || rm -f $cat + if [ -r $cat ]; then + if grep -q '"urn:oasis:names:tc:entity:xmlns:xml:catalog"/>' $cat; then + rm -f $cat + fi + fi + if [ ! -r $cat ] ; then + $xmlcat --create | sed 's:/>:>\ +</catalog>:' >$cat + # echo Failed creating XML Catalog root $1 + fi +} + +# Check /etc/xml/catalog +prep_catalog /etc/xml/catalog + +if [ "$ROOTCATALOG" != /etc/xml/catalog ]; then + root=${ROOTCATALOG#/etc/xml/} + if ! grep -q "nextCatalog.*catalog=\"${root}\"" /etc/xml/catalog; then + sed -i "/<\/catalog>/i\\ +<nextCatalog catalog=\"${root}\"/>" /etc/xml/catalog + fi + prep_catalog "$ROOTCATALOG" +fi + +add_entry () { + { + sed '/<\/catalog>/d' $ROOTCATALOG + $xmllint --nocatalogs --format ${FOR_ROOT_CAT} \ + | awk '\ +/<\/catalog>/{next} +s == 1 {print} +/<catalog/{s=1} +END{print "</catalog>"}' + } >$ROOTCATALOG.tmp + if [ -x /bin/chmod ]; then + /bin/chmod --reference=$ROOTCATALOG $ROOTCATALOG.tmp + fi + $xmllint --nocatalogs --noout $ROOTCATALOG.tmp \ + && mv $ROOTCATALOG.tmp $ROOTCATALOG +} + +del_entry () { + pattern=$FOR_ROOT_CAT + $echo $pattern + if [ -r $ROOTCATALOG ]; then + # Either delete <group>...</group> + # or <!-- pac_start: ... -->...<!-- pac_end: ... --> + if [ "$marker" = "group" ]; then + $xmllint --nocatalogs --format $ROOTCATALOG \ + | awk "\ +/<\/group>/ && s == 1 {s=0;next} +s == 1 {next} +/<group id=\"$pattern\">/{s=1;next} +{print}" > $ROOTCATALOG.tmp + else + $xmllint --nocatalogs --format $ROOTCATALOG \ + | awk "\ +/<!-- pac_end: $pattern do not remove! -->/{s=0;next} +s == 1 {next} +/<!-- pac_start: $pattern do not remove! -->/{s=1;next} +{print}" > $ROOTCATALOG.tmp + fi + if [ -x /bin/chmod ]; then + /bin/chmod --reference=$ROOTCATALOG $ROOTCATALOG.tmp + fi + $xmllint --nocatalogs --noout $ROOTCATALOG.tmp \ + && mv $ROOTCATALOG.tmp $ROOTCATALOG + fi +} + +case "$mode" in + del) + del_entry + ;; + add) + [ -r ${FOR_ROOT_CAT} ] || { echo \"$FOR_ROOT_CAT\" does not exist; exit 1; } + add_entry + ;; + *) +esac + +exit diff --git a/packaging/install-catalog.in b/packaging/install-catalog.in new file mode 100644 index 0000000..358a48e --- /dev/null +++ b/packaging/install-catalog.in @@ -0,0 +1,163 @@ +#!/bin/sh +# Script to install a catalog in the centralized SGML catalog +# Send any comments to Eric Bischoff <eric@caldera.de> +# This program is under GPL license. See LICENSE file for details. + +# Set help message +SGML_HELP_MESSAGE="Usage: `basename $0` [<option>] <action>\n\ +where <option> is:\n\ +\040 -d|--delegate: \t\t\t Use DELEGATE instead of CATALOG\n\ +and where <action> is:\n\ +\040 -a|--add <centralized> <ordinary>: \t Declare ordinary catalog in the centralized catalog\n\ +\040 -r|--remove <centralized> <ordinary>:\t Remove ordinary catalog from the centralized catalog\n\ +\040 -h, --help: \t\t\t\t Print this help message and exit\n\ +\040 -v, --version: \t\t\t Print the version number and exit\n" + +# Set version message +SGML_VERSION_MESSAGE="sgml-common version @VERSION@ (install-catalog version 1.0)" + +# Set type of pointer +SGML_POINTER="CATALOG" + +# Set action to be performed +SGML_ACTION="" + +# Set catalogs +SGML_CENTRALIZED="" +SGML_ORDINARY="" + +# Process options +case $1 in + -d|--delegate) SGML_POINTER="DELEGATE" + shift 1 + ;; +esac + +# Process actions +case $1 in + -a|--add) SGML_ACTION="addition" + SGML_CENTRALIZED=$2 + SGML_ORDINARY=$3 + ;; + -r|--remove) if [ -z "$3" -o "$3" = "--version" ] + then + echo "install-catalog: Old syntax; doing nothing" + exit 0 + fi + SGML_ACTION="removal" + SGML_CENTRALIZED=$2 + SGML_ORDINARY=$3 + ;; + -h|--help) echo -e $SGML_HELP_MESSAGE + exit 0 + ;; + -v|--version) echo -e $SGML_VERSION_MESSAGE + exit 0 + ;; + --install) echo "install-catalog: Old syntax; doing nothing" + exit 0 + ;; + *) echo -e $SGML_HELP_MESSAGE >&2 + exit 1 + ;; +esac + +# Check that the super catalog can be created and changed and deleted +if [ ! -w /etc/sgml ] +then + echo "`basename $0`: unable to write in /etc/sgml." >&2 + exit 2 +fi +case $SGML_ACTION in + addition) + if [ -e /etc/sgml/catalog -a ! -w /etc/sgml/catalog ] + then + echo "`basename $0`: can not modify \"/etc/sgml/catalog\"." >&2 + exit 2 + fi + ;; + removal) + if [ ! -w /etc/sgml/catalog ] + then + echo "`basename $0`: can not modify \"/etc/sgml/catalog\"." >&2 + exit 2 + fi + ;; +esac + +# Check that the centralized catalog can be created, changed and deleted +if [ -z "$SGML_CENTRALIZED" ] +then + echo -e $SGML_HELP_MESSAGE >&2 + exit 1 +fi +case $SGML_ACTION in + addition) + if [ -e $SGML_CENTRALIZED -a ! -w $SGML_CENTRALIZED ] + then + echo "`basename $0`: can not modify \"$SGML_CENTRALIZED\"." >&2 + exit 2 + fi + ;; + removal) + if [ ! -w $SGML_CENTRALIZED ] + then + echo "`basename $0`: can not modify \"$SGML_CENTRALIZED\"." >&2 + exit 2 + fi + ;; +esac + +# Check that we have at least one ordinary package to process +if [ -z "$SGML_ORDINARY" ] +then + echo -e $SGML_HELP_MESSAGE >&2 + exit 1 +fi +case $SGML_ACTION in + addition) + if [ ! -s $SGML_ORDINARY ] + then + echo "`basename $0`: \"$SGML_ORDINARY\" does not exist or is empty." >&2 + exit 2 + fi + ;; +esac + +# Installation or removal of pointers +case $SGML_ACTION in + addition) + echo "`basename $0`: addition of $SGML_ORDINARY in $SGML_CENTRALIZED" + if grep -q $SGML_ORDINARY $SGML_CENTRALIZED 2>/dev/null + then + echo "Warning: $SGML_ORDINARY is already installed in the centralized catalog $SGML_CENTRALIZED" >&2 + else + echo "$SGML_POINTER $SGML_ORDINARY" >> $SGML_CENTRALIZED + fi + grep -q $SGML_CENTRALIZED /etc/sgml/catalog 2>/dev/null + if [ $? -ne 0 ] + then + echo "`basename $0`: addition of $SGML_CENTRALIZED in /etc/sgml/catalog" + echo "$SGML_POINTER $SGML_CENTRALIZED" >> /etc/sgml/catalog + fi + ;; + removal) + echo "`basename $0`: removal of $SGML_ORDINARY from $SGML_CENTRALIZED" + if grep -q $SGML_ORDINARY $SGML_CENTRALIZED 2>/dev/null + then + sed -e "\:$SGML_POINTER $SGML_ORDINARY:d" < $SGML_CENTRALIZED > ${SGML_CENTRALIZED}.new + mv ${SGML_CENTRALIZED}.new $SGML_CENTRALIZED + else + echo "Warning: $SGML_ORDINARY was not found in the centralized catalog $SGML_CENTRALIZED" >&2 + fi + if [ ! -s $SGML_CENTRALIZED ] + then + rm $SGML_CENTRALIZED + echo "`basename $0`: removal of $SGML_CENTRALIZED from /etc/sgml/catalog" + sed -e "\:$SGML_POINTER $SGML_CENTRALIZED:d" < /etc/sgml/catalog > /etc/sgml/catalog.new + mv /etc/sgml/catalog.new /etc/sgml/catalog + fi + ;; +esac + +exit 0 diff --git a/packaging/sgml-skel-edit-cat.diff b/packaging/sgml-skel-edit-cat.diff deleted file mode 100644 index ecc67fb..0000000 --- a/packaging/sgml-skel-edit-cat.diff +++ /dev/null @@ -1,35 +0,0 @@ ---- edit-xml-catalog.sh 2008-05-14 13:28:16.000000000 +0200 -+++ edit-xml-catalog.sh 2008-05-14 13:54:11.000000000 +0200 -@@ -61,10 +61,8 @@ - if [ "$ROOTCATALOG" != /etc/xml/catalog ]; then - root=${ROOTCATALOG#/etc/xml/} - if ! grep -q "nextCatalog.*catalog=\"${root}\"" /etc/xml/catalog; then -- cp /etc/xml/catalog /etc/xml/catalog.tmp -- sed "/<\/catalog>/i\\ --<nextCatalog catalog=\"${root}\"/>" \ -- /etc/xml/catalog.tmp >/etc/xml/catalog -+ sed -i "/<\/catalog>/i\\ -+<nextCatalog catalog=\"${root}\"/>" /etc/xml/catalog - fi - prep_catalog "$ROOTCATALOG" - fi -@@ -79,6 +77,9 @@ - /<catalog/{s=1} - END{print "</catalog>"}' - } >$ROOTCATALOG.tmp -+ if [ -x /bin/chmod ]; then -+ /bin/chmod --reference=$ROOTCATALOG $ROOTCATALOG.tmp -+ fi - $xmllint --nocatalogs --noout $ROOTCATALOG.tmp \ - && mv $ROOTCATALOG.tmp $ROOTCATALOG - } -@@ -104,6 +105,9 @@ - /<!-- pac_start: $pattern do not remove! -->/{s=1;next} - {print}" > $ROOTCATALOG.tmp - fi -+ if [ -x /bin/chmod ]; then -+ /bin/chmod --reference=$ROOTCATALOG $ROOTCATALOG.tmp -+ fi - $xmllint --nocatalogs --noout $ROOTCATALOG.tmp \ - && mv $ROOTCATALOG.tmp $ROOTCATALOG - fi diff --git a/packaging/sgml-skel.spec b/packaging/sgml-skel.spec index 5ced5d7..62efb5c 100644 --- a/packaging/sgml-skel.spec +++ b/packaging/sgml-skel.spec @@ -9,9 +9,6 @@ Source0: http://www.suse.de/~ke/%{name}/%{name}-%{version}.tar.bz2 # :pserver:anoncvs@sources.redhat.com:/cvs/docbook-tools Source1: docbook-tools/sgml-common/bin/install-catalog.in Source2: edit-xml-catalog.sh -Patch0: sgml-skel-regcat.diff -Patch1: sgml-skel-regcat2.diff -Patch2: sgml-skel-edit-cat.diff BuildRequires: automake BuildRequires: libxml2-tools Requires(pre): /bin/awk @@ -32,9 +29,6 @@ These scripts will help prepare and maintain parts of an SGML system. %prep %setup -q -%patch0 -p 1 -%patch1 -p 1 -# # cp -p $RPM_SOURCE_DIR/%{name}-README.SuSE . cp %{SOURCE1} . cp %{SOURCE2} . %patch2 -p 0 |