This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] cygport-0.2.9 allow multiple postinstall/preremove scripts


Forward port to latest release.

For further history and justifiation of this patch, see http://cygwin.com/ml/cygwin/2007-01/msg00112.html and follow the embedded links and threads.

--
Chuck

2007-02-05 Charles Wilson <...>

	* bin/prep_gnu_info.sh: allow cygport client to suppress
	automatic install-info (useful if: subpackages each have own
	explicit postinstall scripts, and each subpackage "owns"
	certain info files.  To activate *suppression*, set
	SUPPRESS_AUTOMATIC_INSTALLINFO to non-empty.  Default behavior
	is unchanged from current.
	* bin/cygport.in (__prepetc): allow ${C}/${PN}.postinstall
	and ${C}/${PN}.sh as synonyms for ${C}/postinstall.sh (however,
	presence of more than one of these causes error message).
	Allow ${C}/${PN}.preremove as synonym for ${C}/preremove.sh
	(but presence of both causes error message).  Allow for
	${C}/${pkg_name[${n}]}.postinstall and/or
	${C}/${pkg_name[${n}]}.preremove [n > 1].

Index: bin/cygport.in
===================================================================
RCS file: /cvsroot/cygwin-ports/cygport/bin/cygport.in,v
retrieving revision 1.53
diff -u -r1.53 cygport.in
--- bin/cygport.in	5 Feb 2007 03:28:43 -0000	1.53
+++ bin/cygport.in	5 Feb 2007 21:41:50 -0000
@@ -1044,16 +1044,63 @@
 __prepetc() {
 	local d;
 	local s;
+	local -i n=1
+	local -i count=0
 
-	for s in postinstall preremove
+	# handle some conflicts between default behavior...
+	if [ -f ${C}/${PN}.sh          ]; then count+=1 ; fi
+	if [ -f ${C}/postinstall.sh    ]; then count+=1 ; fi
+	if [ -f ${C}/${PN}.postinstall ]; then count+=1 ; fi
+        if (( $count > 1 ))
+	then
+		error "Can have only one of ${PN}.sh, ${PN}.postinstall, and postinstall.sh"
+	fi
+
+	count=0
+	if [ -f ${C}/preremove.sh    ]; then count+=1 ; fi
+	if [ -f ${C}/${PN}.preremove ]; then count+=1 ; fi
+	if (( $count > 1 ))
+	then
+		error "Can have only one of ${PN}.preremove, preremove.sh"
+	fi
+
+	# do "main" postinstall if present; guaranteed that at most
+	# only one of these three exist, thanks to checks above.
+	for f in ${PN}.sh ${PN}.postinstall postinstall.sh
+	do
+		if [ -f ${C}/${f} ]
+		then
+			dodir /etc/postinstall;
+			cat >> ${D}/etc/postinstall/${PN}.sh < ${C}/${f}
+			break
+		fi
+	done
+
+	# do "main" preremove if present; guaranteed that at most
+	# only one of these two exist, thanks to checks above.
+	for f in ${PN}.preremove preremove.sh
 	do
-		if [ -f ${C}/${s}.sh ]
+		if [ -f ${C}/${f} ]
 		then
-			dodir /etc/${s};
-			cat >> ${D}/etc/${s}/${PN}.sh < ${C}/${s}.sh;
+			dodir /etc/preremove;
+			cat >> ${D}/etc/preremove/${PN}.sh < ${C}/${f};
 		fi
 	done
 
+	# now do other postinstall/preremove scripts if present
+	while [ -n "${pkg_name[${n}]}" ]
+	do
+		for s in postinstall preremove
+		do
+			if [ -f ${C}/${pkg_name[${n}]}.${s} ]
+			then
+				dodir /etc/${s};
+				cat >> ${D}/etc/${s}/${pkg_name[${n}]}.sh < ${C}/${pkg_name[${n}]}.${s}
+			fi
+		done
+		n+=1
+	done		
+
 	if [ -f ${C}/profile.d.sh ]
 	then
 		exeinto /etc/profile.d;
Index: bin/prep_gnu_info.sh
===================================================================
RCS file: /cvsroot/cygwin-ports/cygport/bin/prep_gnu_info.sh,v
retrieving revision 1.4
diff -u -r1.4 prep_gnu_info.sh
--- bin/prep_gnu_info.sh	20 Nov 2006 05:48:58 -0000	1.4
+++ bin/prep_gnu_info.sh	5 Feb 2007 21:41:50 -0000
@@ -22,12 +22,16 @@
 	gzip -q ${infopage}
 done
 
-dodir /etc/postinstall
-for infopage in $(find ${D}/usr/share/info -type f)
-do
-	cat >> ${D}/etc/postinstall/${PN}.sh <<-_EOF
+if [ -z "${SUPPRESS_AUTOMATIC_INSTALLINFO}" ]
+then
+	dodir /etc/postinstall
+	for infopage in $(find ${D}/usr/share/info -type f)
+	do
+		cat >> ${D}/etc/postinstall/${PN}.sh <<-_EOF
 		/usr/bin/install-info --dir-file=/usr/share/info/dir --info-file=/usr/share/info/${infopage##*/}
 		
 		_EOF
-done
-echo >> ${D}/etc/postinstall/${PN}.sh
+	done
+	echo >> ${D}/etc/postinstall/${PN}.sh
+fi
+

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]