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

svn at pcbsd.org svn at pcbsd.org
Mon Nov 7 08:26:33 PST 2011


Author: kris
Date: 2011-11-07 08:26:33 -0800 (Mon, 07 Nov 2011)
New Revision: 13731

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

Improve pbi-manager on FreeBSD, if user already has a /usr/src populated we can use that




Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager	2011-11-07 16:25:12 UTC (rev 13730)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager	2011-11-07 16:26:33 UTC (rev 13731)
@@ -6165,60 +6165,70 @@
 	  return
  	fi
 
-	# Make sure SVN is installed
-	which svn >/dev/null 2>/dev/null
-	if [ "$?" != "0" ] ; then
-		exit_err "Subversion is required to rebuild the chroot environment!"
-	fi
+	# Use existing sources
+	if [ -e "/usr/src/COPYRIGHT" ] ; then
+		PBI_BUILDSRC="/usr/src"
+		PBI_BUILDTARGET="${PBI_APPDIR}/.worldTarget.$$"
+		PBI_BUILDLOG="${PBI_APPDIR}/.buildWorldLog"
+		echo "" > ${PBI_BUILDLOG}
+		mkdir -p "${PBI_BUILDTARGET}"
+	
+	else
+		# Make sure SVN is installed
+		which svn >/dev/null 2>/dev/null
+		if [ "$?" != "0" ] ; then
+			exit_err "Subversion is required to rebuild the chroot environment!"
+		fi
 
-	echo "Building the PBI chroot environment... This may take a while..."
-	PBI_BUILDSRC="${PBI_APPDIR}/.tmpSRC.$$"
-	PBI_BUILDTARGET="${PBI_APPDIR}/.worldTarget.$$"
-	PBI_BUILDLOG="${PBI_APPDIR}/.buildWorldLog"
-	echo "" > ${PBI_BUILDLOG}
-	mkdir -p "${PBI_BUILDSRC}"
-	mkdir -p "${PBI_BUILDTARGET}"
+		echo "Building the PBI chroot environment... This may take a while..."
+		PBI_BUILDSRC="${PBI_APPDIR}/.tmpSRC.$$"
+		PBI_BUILDTARGET="${PBI_APPDIR}/.worldTarget.$$"
+		PBI_BUILDLOG="${PBI_APPDIR}/.buildWorldLog"
+		echo "" > ${PBI_BUILDLOG}
+		mkdir -p "${PBI_BUILDSRC}"
+		mkdir -p "${PBI_BUILDTARGET}"
 	
-	# Figure out which version of FreeBSD to checkout
-	local _osRel=`uname -r`
-	echo $_osRel | grep "RELEASE" >/dev/null 2>/dev/null
-	if [ "$?" = "0" ] ; then
-		local _osMajor=`echo $_osRel | cut -c 1-1`
-		local svnUrl="svn://svn.freebsd.org/base/releng/${_osMajor}.0"
-		echo "Using $svnUrl for sources"
-	else
-		echo $_osRel | grep "CURRENT" >/dev/null 2>/dev/null
+		# Figure out which version of FreeBSD to checkout
+		local _osRel=`uname -r`
+		echo $_osRel | grep "RELEASE" >/dev/null 2>/dev/null
 		if [ "$?" = "0" ] ; then
-		      local svnUrl="svn://svn.freebsd.org/base/head"
-		      echo "Using $svnUrl for sources"
+			local _osMajor=`echo $_osRel | cut -c 1-1`
+			local svnUrl="svn://svn.freebsd.org/base/releng/${_osMajor}.0"
+			echo "Using $svnUrl for sources"
 		else
-		      echo $_osRel | grep "STABLE" >/dev/null 2>/dev/null
-		      if [ "$?" = "0" ] ; then
-			    local _osMajor=`echo $_osRel | cut -c 1-1`
-			    local svnUrl="svn://svn.freebsd.org/base/stable/${_osMajor}"
-			    "Using $svnUrl for sources"
-		      else
-			    local svnUrl="svn://svn.freebsd.org/base/head"
-			    echo "Using $svnUrl for sources"
-			    echo "Assuming a BETA|RC or rarely used FreeBSD version. Using CURRENT!"
-		      fi
+			echo $_osRel | grep "CURRENT" >/dev/null 2>/dev/null
+			if [ "$?" = "0" ] ; then
+		    	      local svnUrl="svn://svn.freebsd.org/base/head"
+			      echo "Using $svnUrl for sources"
+			else
+		   	   echo $_osRel | grep "STABLE" >/dev/null 2>/dev/null
+			      if [ "$?" = "0" ] ; then
+				    local _osMajor=`echo $_osRel | cut -c 1-1`
+				    local svnUrl="svn://svn.freebsd.org/base/stable/${_osMajor}"
+				    "Using $svnUrl for sources"
+			      else
+			   	 local svnUrl="svn://svn.freebsd.org/base/head"
+			    	echo "Using $svnUrl for sources"
+				    echo "Assuming a BETA|RC or rarely used FreeBSD version. Using CURRENT!"
+			      fi
+			fi
 		fi
-	fi
 
-	echo "Checking out FreeBSD sources from $svnUrl"
-	svn co ${svnUrl} ${PBI_BUILDSRC} >>${PBI_BUILDLOG} 2>>${PBI_BUILDLOG}
-	if [ "$?" != "0" ] ; then
-		rm -rf "${PBI_BUILDSRC}"
-		rm -rf "${PBI_BUILDTARGET}"
-		exit_err "Subversion checkout failed! Logfile saved: ${PBI_BUILDLOG}"
-	fi
+		echo "Checking out FreeBSD sources from $svnUrl"
+		svn co ${svnUrl} ${PBI_BUILDSRC} >>${PBI_BUILDLOG} 2>>${PBI_BUILDLOG}
+		if [ "$?" != "0" ] ; then
+			rm -rf "${PBI_BUILDSRC}"
+			rm -rf "${PBI_BUILDTARGET}"
+			exit_err "Subversion checkout failed! Logfile saved: ${PBI_BUILDLOG}"
+		fi
+	fi # End of subversion checkout
 
 	echo "Running buildworld / installworld"
 	cd ${PBI_BUILDSRC}
 	make buildworld installworld distribution DESTDIR=${PBI_BUILDTARGET} >>${PBI_BUILDLOG} 2>>${PBI_BUILDLOG}
 	if [ "$?" != "0" ] ; then
 		cd
-		rm -rf "${PBI_BUILDSRC}"
+		if [ "${PBI_BUILDSRC}" != "/usr/src" ] ; then rm -rf "${PBI_BUILDSRC}"; fi
 		rm -rf "${PBI_BUILDTARGET}"
 		exit_err "Buildworld failed! Logfile saved: ${PBI_BUILDLOG}"
 	fi
@@ -6232,7 +6242,7 @@
 	tar cvjf ${PBI_CHROOTFILE} -C ${PBI_BUILDTARGET} . >>${PBI_BUILDLOG} 2>>${PBI_BUILDLOG}
 	if [ "$?" != "0" ] ; then
 		cd
-		rm -rf "${PBI_BUILDSRC}"
+		if [ "${PBI_BUILDSRC}" != "/usr/src" ] ; then rm -rf "${PBI_BUILDSRC}"; fi
 		rm -rf "${PBI_BUILDTARGET}"
 		rm -rf "${PBI_CHROOTFILE}"
 		exit_err "Making chroot environment tarball failed! Logfile saved: ${PBI_BUILDLOG}"
@@ -6240,7 +6250,7 @@
 
 	# Cleanup after ourselves
 	chflags -R noschg "${PBI_BUILDTARGET}" >/dev/null 2>/dev/null
-	rm -rf "${PBI_BUILDSRC}" >/dev/null 2>/dev/null
+	if [ "${PBI_BUILDSRC}" != "/usr/src" ] ; then rm -rf "${PBI_BUILDSRC}"; fi
 	rm -rf "${PBI_BUILDTARGET}" >/dev/null 2>/dev/null
 	rm ${PBI_BUILDLOG}
 }



More information about the Commits mailing list