Package: gmic
Version: 1.7.9+zart-4+b1
Severity: wishlist
Tags: patch
Dear Maintainer,
The supplied patch converts gmic's bash-completion code to the new,
dynamically-loading format and moves it from /etc/bash_completion.d
to /usr/share/bash-completion/completions. In parallel, it reduces file
size by about 33%, from 130 KB to 87 KB.
I currently use it in the 1.6.0.1 version and have succesfuly built it for
1.7.9+zart-4. The format of the bash-completion code (being generated
programaticaly by the application itself) appears fairly stable across
version changes; thus the cost to maintain the added sed expressions
in debian/rules seems manageable.
Please, consider it.
regards
Georgios Zarkadas
diff --git a/debian/rules b/debian/rules
index 254dd84..11476dc 100755
--- a/debian/rules
+++ b/debian/rules
@@ -67,6 +67,21 @@ override_dh_install:
# FIX CImg.h file name to avoid problems with cimg-dev
sed -i 's,CImg.h,gmic_CImg.h,g' debian/libgmic-dev/usr/include/gmic.h
mv debian/libgmic-dev/usr/include/CImg.h debian/libgmic-dev/usr/include/gmic_CImg.h
+ # convert bash-completion code to load dynamically and also reduce its size
+ mkdir -p debian/gmic/usr/share/bash-completion/completions
+ sed -z -e 's:/etc/bash_completion\.d/gmic:/usr/share/bash-completion/completions/gmic:' \
+ -e 's/\(_gmic\)_stdlib/\1/g' \
+ -e 's/\(\tCOMPREPLY=()\)/\t_init_completion || return\n\1/' \
+ -e 's/)\n\t\t\(COMPREPLY=\)/) \1/g' \
+ -e 's/)\n\t\t\(return 0\)\n\t\t;;/); \1;;/g' \
+ -e 's/\\\n[[:space:]]*/ /g' \
+ -e 's/\t\t"\(-[-a-zA-Z0-9_]*\)" | "\(--[-a-zA-Z0-9_]*\)")/\t\1|\2)/g' \
+ -e 's/\t\t"/\t"/g' \
+ -e 's/\n\topts="[^"]*"\n//' \
+ -e 's/\n\tcase "\${prev}" in/\n\topts=\$(echo "\$coms" | sed "s: \\([^ ]\\+\\): -\\1 --\\1:g")\n\tcase \$prev in/' \
+ debian/gmic/etc/bash_completion.d/gmic \
+ >debian/gmic/usr/share/bash-completion/completions/gmic
+ rm -r debian/gmic/etc/bash_completion.d
.PHONY: override_dh_auto_test override_dh_compress override_dh_auto_build override_dh_install