aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinhard Leichtfuß <alguien@respiranto.de>2018-03-31 00:58:43 +0200
committerEinhard Leichtfuß <alguien@respiranto.de>2018-03-31 00:58:43 +0200
commite3bfbb28e8cd30c71d1d1cce0649ed7d448312f0 (patch)
tree73d7516525bc515b5935eca34135cb03b050353b
parentbbc3e4cfa5c02ad3ff8dcd3b7a95e568ac434c6f (diff)
Add support for dict-freedict-* in make_install
Furthermore: - Move $langs[] to basic.sh in order to be able to use it in make_install. - Add -f to rm in cleanup() in order to prevent unforeseen errors, that don't matter.
-rw-r--r--basic.sh10
-rwxr-xr-xmake_install.sh58
-rwxr-xr-xupdate.sh8
3 files changed, 54 insertions, 22 deletions
diff --git a/basic.sh b/basic.sh
index 65b44e5..6e90dbc 100644
--- a/basic.sh
+++ b/basic.sh
@@ -1,5 +1,13 @@
#!/bin/bash
+typeset -a langs
+langs=(
+ fra-deu deu-fra
+ deu-eng eng-deu
+ fra-eng eng-fra
+ spa-eng eng-spa
+ )
+
function init
{
tmp_d="$(mktemp -d)"
@@ -9,7 +17,7 @@ function init
function cleanup
{
- rm -r "$tmp_d"
+ rm -rf "$tmp_d"
}
trap cleanup EXIT
diff --git a/make_install.sh b/make_install.sh
index a24837f..88e35dd 100755
--- a/make_install.sh
+++ b/make_install.sh
@@ -1,15 +1,47 @@
#!/bin/bash
-if [ "$#" -lt 1 ]
-then
- echo "Usage: $0 xy-zw [base_dir]" >&2
- exit 1
-elif [ "$#" -gt 1 ]
-then
- cd "$2" || exit 1
-fi
-
-lang=$1
-pkgname=dict-freedict-${lang}
-
-sed "s/%LANG%/${lang}/g" sample.install > ${pkgname}/${pkgname}.install
+. basic.sh
+
+function main
+{
+ if [ "$#" -lt 2 ]
+ then
+ echo "Usage: $0 <base_dir> <type> (<xy>-<zw>|-a)" >&2
+ exit 1
+ elif [ "$#" -gt 2 ]
+ then
+ cd "${1}/${2}" || exit 1
+ fi
+
+ if [[ "$1" == src ]]
+ then
+ ext=
+ else
+ ext="-${2}"
+ fi
+
+ init
+
+ if [[ "$3" == "-a" ]]
+ then
+ for lang in ${langs[@]}
+ do
+ make_install
+ done
+ else
+ lang=$3
+ make_install
+ fi
+}
+
+function make_install
+{
+ pkgname=dict-freedict-${lang}${ext}
+
+ cp ../sample.install "$tmp"
+ replace "%LANG%" "$lang"
+ replace "%SUFFIX%" "$ext"
+ mv "$tmp" ${pkgname}/${pkgname}.install
+}
+
+main "$@"
diff --git a/update.sh b/update.sh
index 6f2edde..6cf91e2 100755
--- a/update.sh
+++ b/update.sh
@@ -1,14 +1,6 @@
#!/bin/bash
# usage: $0 dir [-u xyz-uvw|-ua|-uaf]
-typeset -a langs
-langs=(
- fra-deu deu-fra
- deu-eng eng-deu
- fra-eng eng-fra
- spa-eng eng-spa
- )
-
typeset -A long
long[fra]=French
long[deu]=German