summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sturmlechner <andreas.sturmlechner@gmail.com>2016-07-13 23:56:02 +0200
committerJohannes Huber <johu@gentoo.org>2016-07-14 08:54:11 +0200
commit4807f16b028a94326972428907a97cd12a018730 (patch)
tree8aaedaf7a207f9fa74fde55aa1e6f1d7b7d08968 /eclass/kde5.eclass
parentkde5-functions.eclass: Add KDEBASE=kdel10n and kde_l10n2lingua() (diff)
downloadgentoo-4807f16b028a94326972428907a97cd12a018730.tar.gz
gentoo-4807f16b028a94326972428907a97cd12a018730.tar.bz2
gentoo-4807f16b028a94326972428907a97cd12a018730.zip
kde5.eclass: Add KDEBASE=kdel10n and helper functions
Signed-off-by: Johannes Huber <johu@gentoo.org>
Diffstat (limited to 'eclass/kde5.eclass')
-rw-r--r--eclass/kde5.eclass90
1 files changed, 90 insertions, 0 deletions
diff --git a/eclass/kde5.eclass b/eclass/kde5.eclass
index 72657f433549..c095aae27a80 100644
--- a/eclass/kde5.eclass
+++ b/eclass/kde5.eclass
@@ -99,6 +99,16 @@ else
: ${KDE_TEST:=false}
fi
+# @ECLASS-VARIABLE: KDE_L10N
+# @DESCRIPTION:
+# This is an array of translations this ebuild supports. These translations
+# are automatically added to IUSE.
+if [[ ${KDEBASE} = kdel10n ]]; then
+ if [[ -n ${KDE_L10N} ]]; then
+ IUSE="${IUSE} $(printf 'l10n_%s ' ${KDE_L10N[@]})"
+ fi
+fi
+
# @ECLASS-VARIABLE: KDE_PUNT_BOGUS_DEPS
# @DESCRIPTION:
# If set to "false", do nothing.
@@ -115,6 +125,8 @@ fi
if [[ ${KDEBASE} = kdevelop ]]; then
HOMEPAGE="https://www.kdevelop.org/"
+elif [[ ${KDEBASE} = kdel10n ]]; then
+ HOMEPAGE="http://l10n.kde.org"
else
HOMEPAGE="https://www.kde.org/"
fi
@@ -279,6 +291,21 @@ _calculate_src_uri() {
esac
;;
esac
+
+ if [[ ${KDEBASE} = kdel10n ]] ; then
+ local uri_base="${SRC_URI/${PN}-${PV}.tar.xz/}kde-l10n/kde-l10n"
+ SRC_URI=""
+ for my_l10n in ${KDE_L10N[@]} ; do
+ case ${my_l10n} in
+ sr | sr-ijekavsk | sr-Latn-ijekavsk | sr-Latn)
+ SRC_URI="${SRC_URI} l10n_${my_l10n}? ( ${uri_base}-sr-${PV}.tar.xz )"
+ ;;
+ *)
+ SRC_URI="${SRC_URI} l10n_${my_l10n}? ( ${uri_base}-$(kde_l10n2lingua ${my_l10n})-${PV}.tar.xz )"
+ ;;
+ esac
+ done
+ fi
}
# Determine fetch location for live sources
@@ -358,6 +385,14 @@ kde5_src_unpack() {
git-r3_src_unpack
;;
esac
+ elif [[ ${KDEBASE} = kdel10n ]]; then
+ mkdir -p "${S}" || die "Failed to create source dir ${S}"
+ cd "${S}"
+ for my_tar in ${A}; do
+ tar -xpf "${DISTDIR}/${my_tar}" --xz \
+ "${my_tar/.tar.xz/}/CMakeLists.txt" "${my_tar/.tar.xz/}/5" 2> /dev/null ||
+ elog "${my_tar}: tar extract command failed at least partially - continuing"
+ done
else
default
fi
@@ -369,6 +404,32 @@ kde5_src_unpack() {
kde5_src_prepare() {
debug-print-function ${FUNCNAME} "$@"
+ if [[ ${KDEBASE} = kdel10n ]]; then
+ # move known variant subdirs to root dir, currently sr@*
+ use_if_iuse l10n_sr-ijekavsk && _l10n_variant_subdir2root sr-ijekavsk sr
+ use_if_iuse l10n_sr-Latn-ijekavsk && _l10n_variant_subdir2root sr-Latn-ijekavsk sr
+ use_if_iuse l10n_sr-Latn && _l10n_variant_subdir2root sr-Latn sr
+ if use_if_iuse l10n_sr; then
+ rm -rf kde-l10n-sr-${PV}/5/sr/sr@* || die "Failed to cleanup L10N=sr"
+ _l10n_variant_subdir_buster sr
+ elif [[ -d kde-l10n-sr-${PV} ]]; then
+ # having any variant selected means parent lingua will be unpacked as well
+ rm -r kde-l10n-sr-${PV} || die "Failed to remove sr parent lingua"
+ fi
+
+ # add all l10n directories to cmake
+ cat <<-EOF > CMakeLists.txt || die
+project(${PN})
+cmake_minimum_required(VERSION 2.8.12)
+$(printf "add_subdirectory( %s )\n" \
+ `find . -mindepth 1 -maxdepth 1 -type d | sed -e "s:^\./::"`)
+EOF
+
+ # drop KDE4-based part
+ find -maxdepth 2 -type f -name CMakeLists.txt -exec \
+ sed -i -e "/add_subdirectory(4)/ s/^/#DONT/" {} + || die
+ fi
+
cmake-utils_src_prepare
# only build examples when required
@@ -577,4 +638,33 @@ kde5_pkg_postrm() {
xdg_pkg_postrm
}
+_l10n_variant_subdir2root() {
+ local lingua=$(kde_l10n2lingua ${1})
+ local src=kde-l10n-${2}-${PV}
+ local dest=kde-l10n-${lingua}-${PV}/5
+
+ # create variant rootdir structure from parent lingua and adapt it
+ mkdir -p ${dest} || die "Failed to create ${dest}"
+ mv ${src}/5/${2}/${lingua} ${dest}/${lingua} || die "Failed to create ${dest}/${lingua}"
+ cp -f ${src}/CMakeLists.txt kde-l10n-${lingua}-${PV} || die "Failed to prepare L10N=${1} subdir"
+ echo "add_subdirectory(${lingua})" > ${dest}/CMakeLists.txt ||
+ die "Failed to prepare ${dest}/CMakeLists.txt"
+ cp -f ${src}/5/${2}/CMakeLists.txt ${dest}/${lingua} ||
+ die "Failed to create ${dest}/${lingua}/CMakeLists.txt"
+ sed -e "s/${2}/${lingua}/" -i ${dest}/${lingua}/CMakeLists.txt ||
+ die "Failed to prepare ${dest}/${lingua}/CMakeLists.txt"
+
+ _l10n_variant_subdir_buster ${1}
+}
+
+_l10n_variant_subdir_buster() {
+ local dir=kde-l10n-$(kde_l10n2lingua ${1})-${PV}/5/$(kde_l10n2lingua ${1})
+
+ sed -e "/^add_subdirectory(/d" -i ${dir}/CMakeLists.txt || die "Failed to cleanup ${dir} subdir"
+
+ for subdir in $(find ${dir} -mindepth 1 -maxdepth 1 -type d | sed -e "s:^\./::"); do
+ echo "add_subdirectory(${subdir##*/})" >> ${dir}/CMakeLists.txt
+ done
+}
+
fi