SPECS (DEVEL): bash-completion.spec - on demand completion install on trigg...

glen glen at pld-linux.org
Thu Apr 2 20:01:08 CEST 2009


Author: glen                         Date: Thu Apr  2 18:01:08 2009 GMT
Module: SPECS                         Tag: DEVEL
---- Log message:
- on demand completion install on triggers
- some problems with upgrade so commiting to DEVEL

---- Files affected:
SPECS:
   bash-completion.spec (1.142 -> 1.142.2.1) 

---- Diffs:

================================================================
Index: SPECS/bash-completion.spec
diff -u SPECS/bash-completion.spec:1.142 SPECS/bash-completion.spec:1.142.2.1
--- SPECS/bash-completion.spec:1.142	Thu Apr  2 19:05:25 2009
+++ SPECS/bash-completion.spec	Thu Apr  2 20:01:01 2009
@@ -1,9 +1,13 @@
 # $Revision$, $Date$
+# TODO
+# - bittorrent complete doesn't actually handle our prognames
+# - handle multiple package links (freeciv case)
+# - handle upgrade path to symlinks (see notes in install section)
 Summary:	bash-completion offers programmable completion for bash
 Summary(pl.UTF-8):	Programowalne uzupełnianie nazw dla basha
 Name:		bash-completion
 Version:	20081219
-Release:	1
+Release:	0.8
 License:	GPL
 Group:		Applications/Shells
 Source0:	ftp://distfiles.gentoo.org/pub/gentoo/distfiles/%{name}-%{version}.tar.bz2
@@ -34,26 +38,146 @@
 %patch0 -p1
 %patch1 -p1
 
+# cleanup backups after patching
+find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
+
+# packaged by subversion.spec
+rm contrib/_subversion
+
+# No package matches '*/apache2ctl'
+rm contrib/apache2ctl
+
+# No PLD package or no such binary to complete on
+rm contrib/{harbour,larch,lisp,modules,monodevelop,p4}
+
 %install
 rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_sysconfdir}/bash_completion.d,/etc/shrc.d}
-install bash_completion $RPM_BUILD_ROOT%{_sysconfdir}
-install contrib/*	$RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d
-install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/poldek
+install -d $RPM_BUILD_ROOT{%{_sysconfdir}/bash_completion.d,/etc/shrc.d,%{_datadir}/%{name}}
+
+T=$(grep -c '^%%bashcomp_trigger' %{_specdir}/%{name}.spec)
+F=$(grep -c '^%%{_datadir}/%%{name}/' %{_specdir}/%{name}.spec)
+if [ $T != $F ]; then
+	check_triggers() {
+		echo >&2 "ERROR: triggers count and packaged files mismatch"
+		for f in $(awk '/^%%bashcomp_trigger/{print $3 ? $3 : $2}' %{_specdir}/%{name}.spec); do
+			A=$(awk -vf=$f '$0 == "%%{_datadir}/%%{name}/" f {print}' %{_specdir}/%{name}.spec)
+			if [ -z "$A" ]; then
+				echo >&2 "!! $f not listed in %%files"
+			fi
+		done
+		for f in $(awk -F/ '$0 ~ "^%%{_datadir}/%%{name}/"{print $NF}' %{_specdir}/%{name}.spec); do
+			A=$(awk -vf=$f '/^%%bashcomp_trigger/ && ($3 ? $3 : $2) == f' %{_specdir}/%{name}.spec)
+			if [ -z "$A" ]; then
+				echo >&2 "!! $f has no trigger"
+			fi
+		done
+	}
+	check_triggers
+	exit 1
+fi
+
+cp -a bash_completion $RPM_BUILD_ROOT%{_sysconfdir}
+cp -a contrib/* $RPM_BUILD_ROOT%{_datadir}/%{name}
+cp -a %{SOURCE1} $RPM_BUILD_ROOT%{_datadir}/%{name}/poldek
 install %{SOURCE2} $RPM_BUILD_ROOT/etc/shrc.d
 
+%if 0
+# Take care of contrib files
+# Well, we can't do the %ghost thing as this will leave files from _previous_
+# package left around as new pkg contains the paths too and are ghost, if you
+# think a way how to overcame these, feel free to enable the ghost thing.
+
+# nevertheless, with current package state the check is ran too early meaning
+# the links aren't crated at all, so do not release this pkg if the upgrade
+# path is solved.
+for a in contrib/*; do
+	f=${a##*/}
+	ln -s %{_datadir}/%{name}/$f $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d
+	echo "%ghost %{_sysconfdir}/bash_completion.d/$f"
+done > %{name}-ghosts.list
+%endif
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %triggerpostun -- %{name} < 20050721-3.9
 sed -i -e '/^# START bash completion/,/^# END bash completion/d' /etc/bashrc
 
+# Usage: bashcomp_trigger PACKAGENAME [SCRIPTNAME]
+%define bashcomp_trigger() \
+%triggerin -- %1\
+set -x;\
+if [ ! -e %{_sysconfdir}/bash_completion.d/%{?2}%{!?2:%1} ] ; then\
+	ln -s %{_datadir}/%{name}/%{?2}%{!?2:%1} %{_sysconfdir}/bash_completion.d\
+fi\
+%triggerun -- %1\
+set -x;\
+[ $2 -gt 0 ] || rm -f %{_sysconfdir}/bash_completion.d/%{?2}%{!?2:%1}\
+%{nil}
+
+%bashcomp_trigger bitkeeper
+%bashcomp_trigger BitTorrent bittorrent
+%bashcomp_trigger cksfv
+%bashcomp_trigger clisp
+%bashcomp_trigger dsniff
+%bashcomp_trigger freeciv-client,freeciv-server freeciv
+%bashcomp_trigger gcc-ada gnatmake
+%bashcomp_trigger gcl
+%bashcomp_trigger gkrellm
+%bashcomp_trigger gnupg2 gpg2
+%bashcomp_trigger lilypond
+%bashcomp_trigger mailman
+%bashcomp_trigger mcrypt
+%bashcomp_trigger mercurial hg
+%bashcomp_trigger mtx
+%bashcomp_trigger openssh-clients ssh
+%bashcomp_trigger poldek
+%bashcomp_trigger povray
+%bashcomp_trigger QtDBus qdbus
+%bashcomp_trigger ruby-modules ri
+%bashcomp_trigger sbcl
+%bashcomp_trigger sitecopy
+%bashcomp_trigger snownews
+%bashcomp_trigger svk
+%bashcomp_trigger unace
+%bashcomp_trigger unixODBC isql
+%bashcomp_trigger unrar
+
 %files
 %defattr(644,root,root,755)
 %doc README TODO debian/changelog debian/copyright
-%{_sysconfdir}/bash_completion
-%{_sysconfdir}/bash_completion.d
 /etc/shrc.d/%{name}.sh
+%{_sysconfdir}/bash_completion
+%dir %{_sysconfdir}/bash_completion.d
+%dir %{_datadir}/%{name}
+# we list all files to be sure we have all of them handled by triggers
+%{_datadir}/%{name}/bitkeeper
+%{_datadir}/%{name}/bittorrent
+%{_datadir}/%{name}/cksfv
+%{_datadir}/%{name}/clisp
+%{_datadir}/%{name}/dsniff
+%{_datadir}/%{name}/freeciv
+%{_datadir}/%{name}/gcl
+%{_datadir}/%{name}/gkrellm
+%{_datadir}/%{name}/gnatmake
+%{_datadir}/%{name}/gpg2
+%{_datadir}/%{name}/hg
+%{_datadir}/%{name}/isql
+%{_datadir}/%{name}/lilypond
+%{_datadir}/%{name}/mailman
+%{_datadir}/%{name}/mcrypt
+%{_datadir}/%{name}/mtx
+%{_datadir}/%{name}/poldek
+%{_datadir}/%{name}/povray
+%{_datadir}/%{name}/qdbus
+%{_datadir}/%{name}/ri
+%{_datadir}/%{name}/sbcl
+%{_datadir}/%{name}/sitecopy
+%{_datadir}/%{name}/snownews
+%{_datadir}/%{name}/ssh
+%{_datadir}/%{name}/svk
+%{_datadir}/%{name}/unace
+%{_datadir}/%{name}/unrar
 
 %define date	%(echo `LC_ALL="C" date +"%a %b %d %Y"`)
 %changelog
@@ -61,6 +185,10 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.142.2.1  2009/04/02 18:01:01  glen
+- on demand completion install on triggers
+- some problems with upgrade so commiting to DEVEL
+
 Revision 1.142  2009/04/02 17:05:25  glen
 - remove rpmpkgs.txt completely
 
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SPECS/bash-completion.spec?r1=1.142&r2=1.142.2.1&f=u



More information about the pld-cvs-commit mailing list