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]

[BUG] cygport-0.2.7 fails to build multiple binary packages


While tying to rebuild the gettext-0.15-1 package, I noticed that it
did not build correctly any more.

The problem is that the postinstall/preremove scripts for all but the
primary binary packages are ignored, and thus the packaging step
fails.

I have tried to correct this fault in the attached patch, but as it
was done in a bit of a rush I probably broke as much as I corrected.
Could someone familiar with cygport have a look at it, please?


Some notes on the suggested changes:

* The __prepetc() postinstall function is staring to become too large,
  so some part were split out into separate functions:

   - The __prepetc_pre_post_old() now contains the old
     postinstall/preremove scripts handling.
   - The __prepetc_profile() now contains the old
     profile scripts handling.
   - The __prep_check_pre_post() now postinstall/preremove scripts chmod.

* The __prepetc_pre_post() was added to handle postinstall/preremove
  scripts for multiple binary packages.

* The prep_gnu_info.sh script added commands to the wrong
  postinstall/preremove script, if more than one was used.
  That is it assumed that all info files were located in the primary
  package, which is not true for the gettext package.

  This was replaced with the new prep_gnu_info() function, (not sure
  if this was an imrovement or not).  This function now checks which
  package the info file belongs to and adds the command to the
  corresponding postinstall/preremove scripts.

  Unfortunately this change will probably break the
  postinstall/preremove scripts in the existing multiple binary
  packages. Coincidentally this also removes the need for the
  handcrafted postinstall/preremove scripts in the gettext package,
  so this change seems to be in line with the intent of the cygport
  goals.
    

Test Package etc:
=================

Cygcheck result:
http://www.update.uu.se/~stefanb/cygwin/bug/cygport-1/cygcheck.out

The "corrected" cygport script, and diff to the 0.2.7-1 baseline:
http://www.update.uu.se/~stefanb/cygwin/bug/cygport-1/cygport-test
http://www.update.uu.se/~stefanb/cygwin/bug/cygport-1/cygport-test.patch

A adapted version of the gettext package
(with the po-mode emacs mode included):
http://www.update.uu.se/~stefanb/cygwin/bug/cygport-1/gettext-0.15-2.tar.bz2
http://www.update.uu.se/~stefanb/cygwin/bug/cygport-1/gettext-0.15-2-src.tar.bz2


Regards
	Stefan Björnelund.


--- /usr/bin/cygport	2006-12-26 06:43:10.001000000 +0100
+++ cygport-test	2007-01-07 21:09:26.037408000 +0100
@@ -1031,20 +1031,62 @@
 	done
 }
 
-# creates and installs postinstall, preremove, and profile.d scripts
-__prepetc() {
+# creates and installs postinstall, preremove scripts
+__prepetc_pre_post_old() {
 	local d;
 	local s;
+	local -i n=0;
+
+	__step "Installing postinstall, preremove scripts. Old style."
 
+	# Old style
 	for s in postinstall preremove
 	do
 		if [ -f ${C}/${s}.sh ]
 		then
+			echo "        /etc/${s}/${PN}.sh";
 			dodir /etc/${s};
 			cat >> ${D}/etc/${s}/${PN}.sh < ${C}/${s}.sh;
 		fi
 	done
+}
+
+
+# creates and installs postinstall, preremove scripts
+__prepetc_pre_post() {
+	local d;
+	local s;
+	local -i n=0;
+
+	__step "Installing postinstall, preremove scripts."
+
+	# New style
+	for s in postinstall preremove
+	do
+		n=0;
+		while defined pkg_name[${n}]
+		do
+			if [ -f ${C}/${pkg_name[${n}]}.${s} ]
+			then
+				echo "        /etc/${s}/${pkg_name[${n}]}.sh from ${C}/${pkg_name[${n}]}.${s}";
+				dodir /etc/${s};
+				cat >> ${D}/etc/${s}/${pkg_name[${n}]}.sh < ${C}/${pkg_name[${n}]}.${s};
+			fi
+			n+=1;
+		done
+	done
+}
+
+
+
+# creates and installs postinstall, preremove, and profile.d scripts
+__prepetc_profile() {
+	local d;
+	local -i n=0;
 
+	__step "Installing profile scripts."
+
+	# Old stype, Single package:
 	if [ -f ${C}/profile.d.sh ]
 	then
 		exeinto /etc/profile.d;
@@ -1057,6 +1099,159 @@
 		newexe ${C}/profile.d.csh ${PN}.csh;
 	fi
 
+	# New style, multiple packages
+	n=0;
+	while defined pkg_name[${n}]
+	do
+		if [ -f ${C}/${pkg_name[${n}]}.profile.d.sh ]
+		then
+			exeinto /etc/profile.d;
+			newexe ${C}/${pkg_name[${n}]}.profile.d.sh ${PN}.sh;
+		fi
+
+		if [ -f ${C}/${pkg_name[${n}]}.profile.d.csh ]
+		then
+			exeinto /etc/profile.d;
+			newexe ${C}/${pkg_name[${n}]}.profile.d.csh ${PN}.csh;
+		fi
+
+		n+=1;
+	done
+}
+
+# Postinstall commands for GNU info pages
+prep_gnu_info() {
+	local infopage
+	local sinfopage
+	local -i n=0
+	set -e
+
+	rm -f ${D}/usr/share/info/dir
+
+	__step "Compressing info pages:"
+
+	for infopage in $(find ${D}/usr/share/info -type f ! -name '*.gz' ! -name '*.bz2')
+	do
+		echo "        ${infopage##*/}"
+		gzip -q9 ${infopage}
+	done
+
+	# Add preremove and postinstall to the correct package!
+	__step "Adding info commands to postinstall, preremove scripts:"
+	dodir /etc/postinstall
+	dodir /etc/preremove
+	for infopage in $(find ${D}/usr/share/info -type f)
+	do
+		# Find the correct package
+		sinfopage="${infopage##*/}"
+		#echo "In=/usr/share/info/${infopage##*/}"
+		n=0;
+		while defined pkg_name[${n}]
+		do
+			if egrep -q "usr/share/info/${sinfopage%%.gz}" ${C}/${pkg_name[${n}]}.list
+			then
+				echo "	${infopage##*/} --> PKG: ${pkg_name[${n}]}"
+				cat >> ${D}/etc/postinstall/${pkg_name[${n}]}.sh <<-_EOF
+					echo Foo
+					/usr/bin/install-info --dir-file=/usr/share/info/dir --info-file=/usr/share/info/${infopage##*/}
+					
+					_EOF
+
+				cat >> ${D}/etc/preremove/${pkg_name[${n}]}.sh <<-_EOF
+					echo Foo
+					/usr/bin/install-info --delete --dir-file=/usr/share/info/dir --info-file=/usr/share/info/${infopage##*/}
+					
+					_EOF
+
+				n=9999
+			else
+				n+=1
+			fi
+		done
+		# If the file is not in a package file list, then add it to the default package...
+		if [ "$n" != "9999" ]
+		then
+			warning "Info page not included in pakage list: /usr/share/info/${infopage##*/}"
+			cat >> ${D}/etc/postinstall/${PN}.sh <<-_EOF
+dd				echo Bar
+				/usr/bin/install-info --dir-file=/usr/share/info/dir --info-file=/usr/share/info/${infopage##*/}
+				_EOF
+			cat >> ${D}/etc/preremove/${PN}.sh <<-_EOF
+				echo Bar
+				/usr/bin/install-info --delete --dir-file=/usr/share/info/dir --info-file=/usr/share/info/${infopage##*/}
+				_EOF
+		fi
+	done
+
+	# Add a trailing line
+	n=0;
+	while defined pkg_name[${n}]
+	do
+		if [ -f ${D}/etc/postinstall/${pkg_name[${n}]}.sh ]
+		then
+			echo >> ${D}/etc/postinstall/${pkg_name[${n}]}.sh
+		fi
+		n+=1
+	done
+}
+
+
+# Checking preremove postinstallPostinstall commands for GNU info pages
+prep_check_pre_post() {
+	local s
+	local -i n=0
+	set -e
+
+	rm -f ${D}/usr/share/info/dir
+
+	__step "Checking preremove postinstall."
+
+	# Makesure that the scripts are executable.
+	for d in /etc/postinstall /etc/preremove
+	do
+		if [ -d ${D}${d} ]
+		then
+			find ${D}${d} -type f -exec chmod 0755 '{}' +;
+		fi
+	done
+
+	# OK, this is backwards. Suggest a rewrite.
+	# It would be better to iterate over the files, verifying that is is included in the corrosponding package list.
+	n=0;
+	while defined pkg_name[${n}]
+	do
+		for s in postinstall preremove
+		do
+			if [ -f ${D}/etc/${s}/${pkg_name[${n}]}.sh ]
+			then
+				if grep -q "etc/${s}/${pkg_name[${n}]}.sh" ${C}/${pkg_name[${n}]}.list
+				then
+					: #echo "	OK: etc/${s}/${pkg_name[${n}]}.sh" ${C}/${pkg_name[${n}]}.list
+				else
+					warning "Adding "etc/${s}/${pkg_name[${n}]}.sh to ${C}/${pkg_name[${n}]}.list"
+					echo "etc/${s}/${pkg_name[${n}]}.sh" >>${C}/${pkg_name[${n}]}.list"
+				fi
+			fi
+		done
+		n+=1
+	done
+}
+
+
+
+# creates and installs postinstall, preremove, and profile.d scripts
+__prepetc() {
+	local d;
+	local s;
+
+	__prepetc_pre_post_old
+	__prepetc_pre_post
+
+	__prepetc_profile
+
+	__step "Generating misc configuration data."
+
+
 	# System fonts
 	if [ -d ${D}/usr/share/fonts ]
 	then
@@ -1066,7 +1261,7 @@
 	# GNU info pages
 	if [ -d ${D}/usr/share/info ]
 	then
-		prep_gnu_info.sh || error "GNU info postinstall failed"
+		prep_gnu_info || error "GNU info postinstall failed"
 	fi
 
 	# GTK+ 2.x modules
@@ -1099,13 +1294,7 @@
 		prep_freedesktop_mime.sh || error "Shared Mime Info postinstall failed"
 	fi
 
-	for d in /etc/postinstall /etc/preremove
-	do
-		if [ -d ${D}${d} ]
-		then
-			find ${D}${d} -type f -exec chmod 0755 '{}' +;
-		fi
-	done
+	prep_check_pre_post
 }
 
 __prepman() {
@@ -1113,7 +1302,7 @@
 
 	if [ -d ${D}/usr/share/man ]
 	then
-		echo "Compressing man pages:";
+		__step "Compressing man pages:";
 
 		for manpage in $(find ${D}/usr/share/man -type f ! -name '*.gz' ! -name '*.bz2')
 		do
@@ -1128,7 +1317,7 @@
 
 	cd ${D};
 
-	echo "Stripping executables:";
+	__step "Stripping executables:";
 
 	# Ruby and Apache2 modules should be *.so, nothing else!!!
 	for exe in $(find * -type f -name '*.dll' -o -name '*.exe' -o -name '*.so')

--
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]