SPECS (DEVEL): bash-completion.spec - handles files to ghost conversion via...

glen glen at pld-linux.org
Thu Apr 2 20:43:41 CEST 2009


Author: glen                         Date: Thu Apr  2 18:43:41 2009 GMT
Module: SPECS                         Tag: DEVEL
---- Log message:
- handles files to ghost conversion via trigger

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

---- Diffs:

================================================================
Index: SPECS/bash-completion.spec
diff -u SPECS/bash-completion.spec:1.142.2.1 SPECS/bash-completion.spec:1.142.2.2
--- SPECS/bash-completion.spec:1.142.2.1	Thu Apr  2 20:01:01 2009
+++ SPECS/bash-completion.spec	Thu Apr  2 20:43:35 2009
@@ -7,7 +7,7 @@
 Summary(pl.UTF-8):	Programowalne uzupełnianie nazw dla basha
 Name:		bash-completion
 Version:	20081219
-Release:	0.8
+Release:	0.12
 License:	GPL
 Group:		Applications/Shells
 Source0:	ftp://distfiles.gentoo.org/pub/gentoo/distfiles/%{name}-%{version}.tar.bz2
@@ -37,6 +37,7 @@
 %setup -q -n %{name}
 %patch0 -p1
 %patch1 -p1
+cp -a %{SOURCE1} contrib/poldek
 
 # cleanup backups after patching
 find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
@@ -78,24 +79,14 @@
 
 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
+done > %{name}-ghost.list
 
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -103,12 +94,32 @@
 %triggerpostun -- %{name} < 20050721-3.9
 sed -i -e '/^# START bash completion/,/^# END bash completion/d' /etc/bashrc
 
+%triggerpostun -- %{name} < 20081219-0.1
+# No rpm in vservers
+if [ -x /bin/rpm ]; then
+	# This ugly trigger is here because we package same pathnames as ghost
+	# meaning the files will lay around from previous package version.
+
+	# get files which are ghost for us
+	files=$(rpm -ql %{name}-%{version}-%{release} | grep %{_sysconfdir}/bash_completion.d/)
+
+	# this is to get old pkg NVR, actually gives list of files that are
+	# packaged by other versions than this installed one, which is ok even for
+	# multiple bash-completion pkgs being installed.
+	oldpkg=$(rpm -qf $(echo "$files") 2>/dev/null | grep -v 'is not' | sort -u | grep -v %{name}-%{version}-%{release})
+	for a in $(rpm -ql $oldpkg | grep %{_sysconfdir}/bash_completion.d/); do
+		# remove files from old package (which are ghost in new pkg),
+		# if not already converted to symlink
+		[ -L $a ] || rm -f $a
+	done
+fi
+
 # 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\
+if [ ! -L %{_sysconfdir}/bash_completion.d/%{?2}%{!?2:%1} ] ; then\
+	ln -fs %{_datadir}/%{name}/%{?2}%{!?2:%1} %{_sysconfdir}/bash_completion.d\
 fi\
 %triggerun -- %1\
 set -x;\
@@ -143,7 +154,7 @@
 %bashcomp_trigger unixODBC isql
 %bashcomp_trigger unrar
 
-%files
+%files -f %{name}-ghost.list
 %defattr(644,root,root,755)
 %doc README TODO debian/changelog debian/copyright
 /etc/shrc.d/%{name}.sh
@@ -185,6 +196,9 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.142.2.2  2009/04/02 18:43:35  glen
+- handles files to ghost conversion via trigger
+
 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
================================================================

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



More information about the pld-cvs-commit mailing list