root/trunk/midgard/tools/yamp/yamp
| Revision 6885, 6.8 kB (checked in by philipp, 6 years ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | #!/bin/sh |
| 2 | ########################################################################## |
| 3 | # Build-Script for Midgard Packages |
| 4 | # --------------------------------- |
| 5 | # Author: Torben Nehmer, Linksystem Muenchen <t.nehmer@buero.link-m.de> |
| 6 | # $Id$ |
| 7 | # |
| 8 | # |
| 9 | # This Script is used to export Midgard snippets from a Development |
| 10 | # Database and to create the distribution Packages. |
| 11 | # |
| 12 | # SYNTAX: |
| 13 | # build configfile command |
| 14 | # |
| 15 | # COMMANDS: |
| 16 | # xml: Builds the .xml.gz's. |
| 17 | # package: Builds midhoo-release.tar.gz |
| 18 | # all: Launches xml, cvs and package per default, can be customized |
| 19 | # in ALL_COMANDS |
| 20 | # |
| 21 | # cvs: Lauches a cvs commit after updateing the XML Files |
| 22 | # clean: Clean up the source tree including any package files. |
| 23 | # This should leave only the cvs files. |
| 24 | # |
| 25 | # CVS support: The Makefile requires that cvs requires no argument |
| 26 | # to access the repository. Ensure that the environment is |
| 27 | # correct. |
| 28 | # |
| 29 | # Naming conventions - for a package <package> these files will be used: |
| 30 | # <package>.xml is the XML File in the repository. Will be generated |
| 31 | # out of the <package>.xml.gz export from repligard. |
| 32 | # <package>.conf is the Config File in the repository. This file has to |
| 33 | # make repligard export the desired xml.gz File. |
| 34 | # |
| 35 | # The Package command uses the xml Files specified above and the |
| 36 | # files in OTHER_FILES to create a PACKAGE_NAME-VERSION.tar.bz2 |
| 37 | # |
| 38 | # These Parameters are now all defined in the config file. See Example. |
| 39 | # |
| 40 | # LICENCE: |
| 41 | # |
| 42 | # (C) Torben Nehmer, Linksystem Muenchen <t.nehmer@buero.link-m.de> 2001 |
| 43 | # |
| 44 | # This library is free software; you can redistribute it and/or |
| 45 | # modify it under the terms of the GNU Library General Public |
| 46 | # License as published by the Free Software Foundation; either |
| 47 | # version 2 of the License, or (at your option) any later version. |
| 48 | # |
| 49 | # This library is distributed in the hope that it will be useful, |
| 50 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 51 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 52 | # Library General Public License for more details. |
| 53 | # |
| 54 | # If you do not have access to a copy of the GNU Library General Public |
| 55 | # License already, write to the Free Software Foundation, Inc., 59 Temple |
| 56 | # Place - Suite 330, Boston, MA 02111-1307, USA. |
| 57 | # |
| 58 | ########################################################################## |
| 59 | # INTERNAL CONFIGURATION VARIABLES |
| 60 | # |
| 61 | # The Version is used to keep the config file versions in sync. |
| 62 | YAMP_VERSION="1.0.1" |
| 63 | YAMP_CONFIG_VERSION=1 |
| 64 | |
| 65 | # Load Library Components |
| 66 | INSERT_LOGIN_PL="/usr/local/bin/insert_login.pl" |
| 67 | |
| 68 | # Set this paths to represent the state on your system |
| 69 | BZIP2="bzip2" |
| 70 | GZIP="gzip" |
| 71 | BUNZIP2="bunzip2" |
| 72 | GUNZIP="gunzip" |
| 73 | TAR="tar" |
| 74 | |
| 75 | ########################################################################## |
| 76 | # HELPER FUNCTION insert_login |
| 77 | # |
| 78 | # Calls external Perl Script insert_login.pl to insert the login |
| 79 | # information for a specified user. |
| 80 | # |
| 81 | # example: insert_login xmlfile guid user password |
| 82 | # |
| 83 | insert_login () { |
| 84 | if [ $# != 4 ]; then |
| 85 | echo "YAMP $YAMP_VERSION ERROR:" |
| 86 | echo "Usage: insert_login guid user password" |
| 87 | exit 127; |
| 88 | fi |
| 89 | if [ ! -f $INSERT_LOGIN_PL ]; then |
| 90 | echo "YAMP $YAMP_VERSION ERROR:" |
| 91 | echo "insert_login: $INSERT_LOGIN_PL not found!" |
| 92 | exit 127; |
| 93 | fi |
| 94 | if [ ! -f $1 ]; then |
| 95 | echo "YAMP $YAMP_VERSION ERROR:" |
| 96 | echo "insert_login: $1 does not exist!" |
| 97 | echo "We are in: " `pwd` |
| 98 | exit 4; |
| 99 | fi |
| 100 | |
| 101 | cat $1 | $INSERT_LOGIN_PL $2 $3 $4 > $1.new |
| 102 | mv -f $1.new $1 |
| 103 | } |
| 104 | |
| 105 | ########################################################################## |
| 106 | # HELPER FUNCTION extract |
| 107 | # |
| 108 | # Default operation to process an xml.gz File: |
| 109 | # - Extract it |
| 110 | # - Insert CVS Header after the first line |
| 111 | # |
| 112 | # example: Use "extract somefile.xml" to process somefile.xml.gz |
| 113 | # You have to omit the gz extension! |
| 114 | # |
| 115 | # Don't bother with the really scary sed replacement. It just inserts |
| 116 | # the CVS Id Tag into the file. Since CVS does not know selective |
| 117 | # keyword expansion I had to find a way to prevent this expansion. |
| 118 | # |
| 119 | extract() { |
| 120 | if [ $# != 1 ]; then |
| 121 | echo "YAMP $YAMP_VERSION ERROR:" |
| 122 | echo "Usage: extract-default {xml-gz file without the .gz extension}" |
| 123 | exit 127 |
| 124 | fi |
| 125 | |
| 126 | rm -f $1 |
| 127 | gunzip -c $1.gz | sed 's/<Database/<!-- \$I --><Database/' | sed 's/ --><Database /d\$ -->\ |
| 128 | <Database /' > $1 |
| 129 | |
| 130 | rm -f $1.gz |
| 131 | |
| 132 | # call customizer |
| 133 | extractcustomop $1 |
| 134 | } |
| 135 | |
| 136 | ########################################################################## |
| 137 | # HELPER FUNCTION help |
| 138 | # |
| 139 | # Prints the help message |
| 140 | # |
| 141 | # Currently disabled: |
| 142 | # cvs : Lauches a cvs commit after updateing the XML Files |
| 143 | # |
| 144 | help() { |
| 145 | cat << EOF |
| 146 | Yet Another Midgard Package Tool, Version $YAMP_VERSION |
| 147 | (C) Torben Nehmer, Linksystem Muenchen <t.nehmer@buero.link-m.de> 2001 |
| 148 | |
| 149 | SYNTAX: yamp configfile command |
| 150 | |
| 151 | COMMANDS: |
| 152 | xml : Builds the .xml.gz files. |
| 153 | package: Builds midhoo-release.tar.gz |
| 154 | all : Launches xml, cvs and package per default, can be customized |
| 155 | in ALL_COMANDS |
| 156 | |
| 157 | clean : Clean up the source tree including any package files. |
| 158 | This should leave only the cvs files. |
| 159 | EOF |
| 160 | } |
| 161 | |
| 162 | |
| 163 | ################ |
| 164 | ### BEGIN Skript |
| 165 | ################ |
| 166 | |
| 167 | ################ |
| 168 | # Error Checking |
| 169 | # |
| 170 | |
| 171 | if [ $# != 2 ]; then |
| 172 | help |
| 173 | exit 1 |
| 174 | fi |
| 175 | |
| 176 | if [ ! -f $1 ]; then |
| 177 | echo "YAMP $YAMP_VERSION ERROR:" |
| 178 | echo Configuration file does not exist! |
| 179 | exit 2 |
| 180 | fi |
| 181 | |
| 182 | # Source Config File |
| 183 | . $1 |
| 184 | |
| 185 | if [ $CONFIG_VERSION != $YAMP_CONFIG_VERSION ]; then |
| 186 | echo "YAMP $YAMP_VERSION ERROR:" |
| 187 | echo "Configuration file Version incorrect"; |
| 188 | exit 3 |
| 189 | fi |
| 190 | |
| 191 | |
| 192 | |
| 193 | case "$2" in |
| 194 | |
| 195 | ########################################################################## |
| 196 | # COMMAND xml |
| 197 | # |
| 198 | # Creates/Updates the .xml files |
| 199 | # |
| 200 | xml) |
| 201 | for i in $PACKAGES |
| 202 | do |
| 203 | $REPLIGARD $REPLIGARD_PARAM $REPLIGARD_CONFIG $i.conf -e $i.xml.gz |
| 204 | extract $i.xml |
| 205 | done |
| 206 | ;; |
| 207 | |
| 208 | |
| 209 | ########################################################################## |
| 210 | # COMMAND package |
| 211 | # |
| 212 | # Creates the Package from the current tree. |
| 213 | # |
| 214 | package) |
| 215 | mkdir $PACKAGE_NAME-$VERSION |
| 216 | for i in $PACKAGES |
| 217 | do |
| 218 | $GZIP -c $i.xml > $PACKAGE_NAME-$VERSION/$i.xml.gz |
| 219 | done |
| 220 | for i in $OTHER_FILES |
| 221 | do |
| 222 | cp $i $PACKAGE_NAME-$VERSION |
| 223 | done |
| 224 | $TAR -cvjf $PACKAGE_NAME-$VERSION.tar.bz2 $PACKAGE_NAME-$VERSION |
| 225 | rm -rf $PACKAGE_NAME-$VERSION |
| 226 | ;; |
| 227 | |
| 228 | |
| 229 | ########################################################################## |
| 230 | # COMMAND all |
| 231 | # |
| 232 | # Builds everything, as defined in ALL_COMMANDS |
| 233 | # |
| 234 | all) |
| 235 | for i in $ALL_COMMANDS |
| 236 | do |
| 237 | $0 $1 $i |
| 238 | done |
| 239 | ;; |
| 240 | |
| 241 | |
| 242 | ########################################################################## |
| 243 | # COMMAND cvs |
| 244 | # |
| 245 | # Do a commit |
| 246 | # |
| 247 | # cvs) |
| 248 | # $CVS commit |
| 249 | # ...Not yet implemented... |
| 250 | # ;; |
| 251 | |
| 252 | |
| 253 | ########################################################################## |
| 254 | # COMMAND clean |
| 255 | # |
| 256 | # Cleans up the repository from build-scrap. Shouldn't happen though, |
| 257 | # because the other commands clean up after they've run. Just to be |
| 258 | # complete. |
| 259 | # |
| 260 | clean) |
| 261 | for i in $PACKAGES |
| 262 | do |
| 263 | rm -f $i.xml.gz $i.xml |
| 264 | done |
| 265 | rm -rf $PACKAGE_NAME-$VERSION* |
| 266 | ;; |
| 267 | |
| 268 | |
| 269 | ########################################################################## |
| 270 | # COMMAND Help Message |
| 271 | # |
| 272 | # Prints the help message in case of error. |
| 273 | # |
| 274 | *) |
| 275 | help |
| 276 | return 1 |
| 277 | ;; |
| 278 | esac |
Note: See TracBrowser for help on using the browser.
