build.sh
author František Kučera <franta-hg@frantovo.cz>
Wed, 14 Aug 2013 00:37:34 +0200
changeset 65 9cf1760bff49
parent 57 00aecef99f14
permissions -rwxr-xr-x
data: line breaks
franta-hg@23
     1
#!/bin/bash
franta-hg@23
     2
franta-hg@23
     3
# Free Telco Dictionary
franta-hg@23
     4
# Copyright © 2013 František Kučera (frantovo.cz)
franta-hg@23
     5
# 
franta-hg@23
     6
# This program is free software: you can redistribute it and/or modify
franta-hg@23
     7
# it under the terms of the GNU General Public License as published by
franta-hg@23
     8
# the Free Software Foundation, either version 3 of the License, or
franta-hg@23
     9
# (at your option) any later version.
franta-hg@23
    10
#
franta-hg@23
    11
# This program is distributed in the hope that it will be useful,
franta-hg@23
    12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
franta-hg@23
    13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
franta-hg@23
    14
# GNU General Public License for more details.
franta-hg@23
    15
#
franta-hg@23
    16
# You should have received a copy of the GNU General Public License
franta-hg@23
    17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
franta-hg@23
    18
franta-hg@23
    19
franta-hg@23
    20
# Script for generating deliverables:
franta-hg@23
    21
# packed dictionary data in StarDict format
franta-hg@23
    22
franta-hg@23
    23
franta-hg@23
    24
JAR="dist/dictionary-generator.jar"
franta-hg@23
    25
GENERATOR_DIR="java/dictionary-generator"
franta-hg@23
    26
WORK_DIR="free-telco-dictionary"
franta-hg@23
    27
franta-hg@23
    28
function package() {
franta-hg@23
    29
    DELIVERY_DIR="../../delivery"
franta-hg@23
    30
    rm -rf $DELIVERY_DIR/$WORK_DIR
franta-hg@23
    31
    java -jar $JAR $1
franta-hg@23
    32
    pushd $DELIVERY_DIR
franta-hg@32
    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
franta-hg@23
    34
    tar czf $2.tar.gz $WORK_DIR
franta-hg@23
    35
    popd
franta-hg@23
    36
}
franta-hg@23
    37
franta-hg@23
    38
pushd `dirname $0`/$GENERATOR_DIR
franta-hg@23
    39
franta-hg@31
    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");
franta-hg@57
    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");
franta-hg@29
    42
franta-hg@23
    43
# build the generator if needed
franta-hg@23
    44
if [ ! -f $JAR ]; then
franta-hg@23
    45
    ant;
franta-hg@23
    46
fi
franta-hg@23
    47
franta-hg@23
    48
# generate packages in multiple formats
franta-hg@23
    49
package m free-telco-dictionary.text  # plain text
franta-hg@23
    50
package h free-telco-dictionary.xhtml # rich text
franta-hg@23
    51
franta-hg@23
    52
popd
franta-hg@23
    53