[PC-BSD Commits] r19655 - pcbsd/current/src-sh/pbi-manager

svn at pcbsd.org svn at pcbsd.org
Fri Oct 12 06:46:09 PDT 2012


Author: kris
Date: 2012-10-12 13:46:08 +0000 (Fri, 12 Oct 2012)
New Revision: 19655

Modified:
   pcbsd/current/src-sh/pbi-manager/pbi-manager
Log:

Fix up some build stuff with the new PBI queue / process system



Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager	2012-10-12 09:18:53 UTC (rev 19654)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager	2012-10-12 13:46:08 UTC (rev 19655)
@@ -5608,9 +5608,19 @@
 				activity=1
 				continue; 
 			else
-				rm ${PBI_TMPDIR}/${build}.pid
 		 		# Do the ZFS destroy here if necessary
 				check_zfs_ab_destroy "$build"
+				
+				# Run the post-build process
+				ab_post_build ${build}
+
+				# Cleanup 
+				rm ${PBI_TMPDIR}/${build}.pid
+				rm ${PBI_TMPDIR}/${build}.bPort
+				rm ${PBI_TMPDIR}/${build}.od
+				rm ${PBI_TMPDIR}/${build}.mp
+				rm ${PBI_TMPDIR}/${build}.cd
+				rm ${PBI_TMPDIR}/${build}.zmnt 2>/dev/null
 			fi
 		fi
 		if [ $done -eq 1 ] ; then continue ; fi
@@ -5888,56 +5898,60 @@
 	echo "pbi_makeport ${_flags} ${_mp}" >>${_od}/build.log
 	echo "------------------------------------------------------" >>${_od}/build.log
 	
-	# Create the build script we will run
-	cat >${PBI_TMPDIR}/${eBuilder}.sh << EOF
-#!/bin/sh
+	echo "${_od}" > "${PBI_TMPDIR}/${PBI_AB_BUILDER}.od"
+	echo "${_mp}" > "${PBI_TMPDIR}/${PBI_AB_BUILDER}.mp"
+	echo "${_cd}" > "${PBI_TMPDIR}/${PBI_AB_BUILDER}.cd"
+	pbi_makeport ${_flags} ${_mp} >>${_od}/build.log 2>>${_od}/build.log &
+  	echo "$!" > ${PBI_TMPDIR}/${eBuilder}.pid
 
-# Start the build now
-exec pbi_makeport ${_flags} ${_mp}
-if [ "$?" = "0" ] ; then
+}
 
-	echo "$PBI_PROGVERSION" > "${_od}/pbi-version"
-	echo "OK" > "${_od}/pbi-result"
+ab_post_build() 
+{
+	local build=$1
+	_od="`cat ${PBI_TMPDIR}/${build}.od`"
+	_mp="`cat ${PBI_TMPDIR}/${build}.mp`"
+	_cd="`cat ${PBI_TMPDIR}/${build}.cd`"
+	sleep 1
 
-	# Save the mdate file
-	date "+%Y%m%d %H%M%S" >${_od}/pbi-mdate
+	if [ -e "${PBI_TMPDIR}/${build}.result" ] ; then
+		echo "$PBI_PROGVERSION" > "${_od}/pbi-version"
+		echo "OK" > "${_od}/pbi-result"
 
-	if [ -n "${PBI_AB_HELPS}" ] ; then
-		${PBI_AB_HELPS} "OK" "${_od}"
-	fi
+		# Save the mdate file
+		date "+%Y%m%d %H%M%S" >${_od}/pbi-mdate
 
-	# Copy over a description file
-	if [ -e "${PORTSDIR}/${_mp}/pkg-descr" ] ; then
-		cp "${PORTSDIR}/${_mp}/pkg-descr" "${_od}/pbi-descr"
-	fi
-	if [ -e "${_cd}/pbi-descr" ] ; then
-		cp "${_cd}/pbi-descr" "${_od}/pbi-descr"
-	fi
+		if [ -n "${PBI_AB_HELPS}" ] ; then
+			${PBI_AB_HELPS} "OK" "${_od}"
+		fi
 
-	# Generate patch files to the new version of this PBI
-	if [ "$PBI_AB_GENPATCH" = "YES" -a -d "${_od}/archived" ] ; then
-		gen_pbi_patches "${_od}" "${_od}/archived" >>${_od}/build.log 2>>${_od}/build.log
-	fi
+		# Copy over a description file
+		if [ -e "${PORTSDIR}/${_mp}/pkg-descr" ] ; then
+			cp "${PORTSDIR}/${_mp}/pkg-descr" "${_od}/pbi-descr"
+		fi
+		if [ -e "${PBI_AB_CONFDIR}/${_cd}/pbi-descr" ] ; then
+			cp "${PBI_AB_CONFDIR}/${_cd}/pbi-descr" "${_od}/pbi-descr"
+		fi
 
-	rm "${_od}/build.log.bz2" >/dev/null 2>/dev/null
-	bzip2 "${_od}/build.log"
+		# Check if we need to rebuild patches
+		if [ "$PBI_AB_GENPATCH" = "YES" -a -d "${_od}/archived" ] ; then
+			echo "===> Generating patches for [$build]"
+			gen_pbi_patches "${_od}" "${_od}/archived"
+		fi
 
-else
-	# Save the md5sum of the ports directory
-	tar cvf - -C "${PORTSDIR}/${_mp}" . 2>/dev/null | md5 -q >${_od}/.failed-csum
+		rm "${_od}/build.log.bz2" >/dev/null 2>/dev/null
+		bzip2 "${_od}/build.log"
 
-	echo "Failed" > "${_od}/pbi-result"
-	if [ -n "${PBI_AB_HELPS}" ] ; then
-		${PBI_AB_HELPS} "FAILED" "${_od}"
+	else
+		# Save the md5sum of the ports directory
+		tar cvf - -C "${PORTSDIR}/${_mp}" . 2>/dev/null | md5 -q >${_od}/.failed-csum
+
+		echo "Failed" > "${_od}/pbi-result"
+		if [ -n "${PBI_AB_HELPS}" ] ; then
+			${PBI_AB_HELPS} "FAILED" "${_od}"
+		fi
 	fi
-fi
-EOF
 
-  chmod 755 ${PBI_TMPDIR}/${eBuilder}.sh
-  (${PBI_TMPDIR}/${eBuilder}.sh >>${_od}/build.log 2>>${_od}/build.log) &
-  echo "$!" > ${PBI_TMPDIR}/${eBuilder}.pid
-  return
-
 }
 
 # Function which begins to generate patch files from archived PBIs to current
@@ -5967,8 +5981,8 @@
 	do
 		# Make sure we don't try to make a patch of identical files
 	  	if [ "`basename $_oPBI`" != "`basename $_curPBI`" ] ; then	
-			echo "Building pbp patch of ${_oPBI} -> ${_curPBI}"
-			pbi_makepatch $_mpflags "$_oPBI" "$_curPBI" 
+			#echo "Building pbp patch of ${_oPBI} -> ${_curPBI}"
+			pbi_makepatch $_mpflags "$_oPBI" "$_curPBI" 2>/dev/null
 			if [ "$?" != "0" ] ; then
 				echo "pbi_makepatch: Failed creating patchfile for $_oPBI -> $_curPBI"
 			fi
@@ -6533,6 +6547,11 @@
 	# Got this far, lets exit with success
 	rm_buildfiles
 	rm_tmpdir
+
+	# If running as an auto-build, show that we were successful
+	if [ -n "$PBI_AB_TMPDIR" ] ; then
+        	echo "0" > ${PBI_AB_TMPDIR}/${PBI_AB_BUILDER}.result
+	fi
 	exit 0
 }
 
@@ -7117,8 +7136,10 @@
 	      bNum=`basename $j | cut -d '.' -f 1 `
 	      if pgrep -qF "${j}" >/dev/null 2>&1; then 
 	         echo "===>Cleaning up processes [$bNum]"
-		 pkill -9 -P `cat ${j}`
- 		 sleep 4 
+		 pkill -9 -P "`cat ${j}`"
+		 sleep 10 
+		 pkill -9 -F ${j}
+ 		 sleep 10 
 		 # Do the ZFS destroy here, since running zfs destroy concurrently as we cleanup can cause a panic
 		 check_zfs_ab_destroy "$bNum"
 	      fi



More information about the Commits mailing list