aboutsummaryrefslogtreecommitdiff
path: root/make_install.sh
blob: 579586a269063fc65594c739c28a5ad4b7a5d958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
#
# make_install.sh - script to create the .install files
#
# Copyright 2018 Einhard Leichtfuß
#
# This file is part of aur-fd-scripts
#
# aur-fd-scripts is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# aur-fd-scripts is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with aur-fd-scripts.  If not, see <https://www.gnu.org/licenses/>.
#

script_path="$(realpath "$0")"
script_dir="${script_path%/*}"
. "${script_dir}/basic.sh" || exit 1


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 [[ "$2" == 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
}


# Create the install file.
#
# requires: $lang, $ext to be set;
#           $PWD == <base directory>/<type>
#
function make_install
{
	pkgname=dict-freedict-${lang}${ext}

	input "${script_dir}/sample.install"
	replace "%LANG%" "$lang"
	replace "%SUFFIX%" "$ext"
	write "${lang}/${pkgname}.install"
}


main "$@"