#!/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 .
#
script_path="$(realpath "$0")"
script_dir="${script_path%/*}"
. "${script_dir}/basic.sh" || exit 1
function main
{
if [ "$#" -lt 2 ]
then
echo "Usage: $0 (-|-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 == /
#
function make_install
{
pkgname=dict-freedict-${lang}${ext}
input "${script_dir}/sample.install"
replace "%LANG%" "$lang"
replace "%SUFFIX%" "$ext"
write "${lang}/${pkgname}.install"
}
main "$@"