summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2021-03-05 15:15:40 +0100
committerUlrich Müller <ulm@gentoo.org>2021-03-05 15:15:40 +0100
commit6206c1cfa5e7e9795d8ca60c2fcdc07a860025c1 (patch)
treee9f9aa0d3eb23aa02f2cd58de48dc7759a95e16f /keyword-generation.sh
parentUpdate package keywords. (diff)
downloadebuild-mode-6206c1cfa5e7e9795d8ca60c2fcdc07a860025c1.tar.gz
ebuild-mode-6206c1cfa5e7e9795d8ca60c2fcdc07a860025c1.tar.bz2
ebuild-mode-6206c1cfa5e7e9795d8ca60c2fcdc07a860025c1.zip
Respect ECLASSDIR in keyword-generation.sh
* keyword-generation.sh: The eclass directory can now be specified with the ECLASSDIR variable. Better error checking and reporting. * Makefile (keywords): New target. Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Diffstat (limited to 'keyword-generation.sh')
-rwxr-xr-xkeyword-generation.sh38
1 files changed, 27 insertions, 11 deletions
diff --git a/keyword-generation.sh b/keyword-generation.sh
index 2c288c5..112aaa7 100755
--- a/keyword-generation.sh
+++ b/keyword-generation.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2011-2020 Gentoo Authors
+# Copyright 2011-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2 or later
# Authors:
@@ -9,12 +9,25 @@
# Generate a raw list for app-emacs/ebuild-mode
REPO=gentoo
-TMPFILE="$(mktemp ${TMPDIR:-/tmp}/keyword-generation.XXXXXX)"
-ECLASSES=( $(portageq available_eclasses / ${REPO} | LC_ALL=C sort) )
-ECLASSFILES=( $(portageq eclass_path / ${REPO} "${ECLASSES[@]}") )
# Obsolete eclasses
OBSOLETE=""
+TMPFILE="$(mktemp ${TMPDIR:-/tmp}/keyword-generation.XXXXXX)"
+
+if [[ -n ${ECLASSDIR} ]]; then
+ echo "ECLASSDIR = ${ECLASSDIR}" >&2
+ ECLASSES=( "${ECLASSDIR}"/*.eclass )
+ # We need to strip to the basename, for correct sort order
+ ECLASSES=( "${ECLASSES[@]#"${ECLASSDIR}/"}" )
+ ECLASSES=( $(printf "%s\n" "${ECLASSES[@]%.eclass}" | LC_ALL=C sort) )
+ ECLASSFILES=( "${ECLASSES[@]/%/.eclass}" )
+ ECLASSFILES=( "${ECLASSFILES[@]/#/"${ECLASSDIR}/"}" )
+else
+ echo "No ECLASSDIR specified - using portageq eclass_path" >&2
+ ECLASSES=( $(portageq available_eclasses / ${REPO} | LC_ALL=C sort) )
+ ECLASSFILES=( $(portageq eclass_path / ${REPO} "${ECLASSES[@]}") )
+fi
+
# Arrays should have equal size
[[ ${#ECLASSES[@]} -eq ${#ECLASSFILES[@]} ]] || exit 1
@@ -29,9 +42,10 @@ has() {
for (( i = 0; i < ${#ECLASSES[@]}; i++ )); do
eclass=${ECLASSES[i]}
- has ${eclass} ${OBSOLETE} && continue
file=${ECLASSFILES[i]}
- grep -q "^# @DEAD$" "${file}" && continue
+ echo -n " ${eclass} ... " >&2
+ grep -q "^# @DEAD$" "${file}" && { echo "skip (dead)" >&2; continue; }
+ has ${eclass} ${OBSOLETE} && { echo "skip (obsolete)" >&2; continue; }
# Get list of functions defined in eclass
fn_all=$(env -i bash -c ". ${file}; declare -F" 2>/dev/null \
@@ -42,7 +56,7 @@ for (( i = 0; i < ${#ECLASSES[@]}; i++ )); do
s/^# @[^:]*:[[:space:]]*//;p};/^# @/bx}' "${file}")
functions=$(echo "${fn_all}" | grep -v '^_' | grep -Fvx "${fn_internal}")
- [[ -z ${functions} ]] && continue
+ [[ -z ${functions} ]] && { echo "warning (no functions)" >&2; continue; }
{
echo "(defvar ebuild-mode-keywords-${eclass%.eclass}"
@@ -50,9 +64,10 @@ for (( i = 0; i < ${#ECLASSES[@]}; i++ )); do
echo " font-lock-type-face))"
echo
} >>"${TMPFILE}"
+ echo "ok" >&2
done
-emacs -q --batch \
+emacs -q --no-site-file --batch \
--visit "${TMPFILE}" \
--eval "(emacs-lisp-mode)" \
--eval "(indent-region (point-min) (point-max))" \
@@ -60,9 +75,10 @@ emacs -q --batch \
(fill-indent-according-to-mode t)
(paragraph-start \"^.\"))
(fill-region (point-min) (point-max)))" \
- --eval "(save-buffer)" --kill
+ --eval "(save-buffer)" --kill || exit 1
sed -i -e "/@@KEYWORDS-BEGIN@@/,/@@KEYWORDS-END@@/{//!d}
-/@@KEYWORDS-BEGIN@@/r${TMPFILE}" ebuild-mode-keywords.el
+/@@KEYWORDS-BEGIN@@/r${TMPFILE}" ebuild-mode-keywords.el || exit 1
-rm "${TMPFILE}"
+rm -f "${TMPFILE}"
+exit