build.sh
author František Kučera <franta-hg@frantovo.cz>
Sun, 18 Aug 2013 18:15:11 +0200
changeset 108 75ccf608a16e
parent 57 00aecef99f14
permissions -rwxr-xr-x
data: hacker
     1 #!/bin/bash
     2 
     3 # Free Telco Dictionary
     4 # Copyright © 2013 František Kučera (frantovo.cz)
     5 # 
     6 # This program is free software: you can redistribute it and/or modify
     7 # it under the terms of the GNU General Public License as published by
     8 # the Free Software Foundation, either version 3 of the License, or
     9 # (at your option) any later version.
    10 #
    11 # This program is distributed in the hope that it will be useful,
    12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14 # GNU General Public License for more details.
    15 #
    16 # You should have received a copy of the GNU General Public License
    17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18 
    19 
    20 # Script for generating deliverables:
    21 # packed dictionary data in StarDict format
    22 
    23 
    24 JAR="dist/dictionary-generator.jar"
    25 GENERATOR_DIR="java/dictionary-generator"
    26 WORK_DIR="free-telco-dictionary"
    27 
    28 function package() {
    29     DELIVERY_DIR="../../delivery"
    30     rm -rf $DELIVERY_DIR/$WORK_DIR
    31     java -jar $JAR $1
    32     pushd $DELIVERY_DIR
    33     (echo -n "Mercurial: "; hg identify || echo "n/a"; echo -n "XML SHA-1: "; (sha1sum "../data/dictionary.xml" | cut -d" " -f1); echo -n "Generated: "; date --rfc-3339=seconds) > $WORK_DIR/version.txt
    34     tar czf $2.tar.gz $WORK_DIR
    35     popd
    36 }
    37 
    38 pushd `dirname $0`/$GENERATOR_DIR
    39 
    40 hg status ../../data/dictionary.xml | grep -q "^M" && echo -e "\033[31mWARNING: building from data file which was not commited into Mercurial!\033[0m" || (echo -e "\033[32mINFO: building from versioned data file: `hg identify` \033[0m");
    41 xmllint --noout --schema ../../data/dictionary.xsd ../../data/dictionary.xml &> /dev/null && echo -e "\033[32mINFO: XML is valid according to XSD\033[0m" || (echo -e "\033[31mERROR: XML is invalid according to XSD\033[0m");
    42 
    43 # build the generator if needed
    44 if [ ! -f $JAR ]; then
    45     ant;
    46 fi
    47 
    48 # generate packages in multiple formats
    49 package m free-telco-dictionary.text  # plain text
    50 package h free-telco-dictionary.xhtml # rich text
    51 
    52 popd
    53