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

svn at pcbsd.org svn at pcbsd.org
Tue Nov 30 07:47:59 PST 2010


Author: kris
Date: 2010-11-30 07:47:59 -0800 (Tue, 30 Nov 2010)
New Revision: 8087

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

Sanitize some of the chroot build locations so that input / output files appear in consistent places



Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-30 14:02:20 UTC (rev 8086)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-30 15:47:59 UTC (rev 8087)
@@ -890,7 +890,9 @@
                 --mkdebug)	MKDEBUG="YES"
                         ;;
                 -o)	if [ $# -eq 1 ]; then usage_make_pbi; fi
-                        shift; PBI_CREATE_OUTDIR="$1"
+                        shift
+			get_abspath "$1"
+			PBI_CREATE_OUTDIR="$_ABSPATH"
                         ;;
                 -p)	if [ $# -eq 1 ]; then usage_make_pbi; fi
                         if [ ! -z "${PBI_MAKEPREFIX}" ]; then usage_make_pbi; fi
@@ -903,16 +905,26 @@
                         ;;
                  *)
                         if [ $# -gt 1 ]; then usage_make_pbi; fi
-                        if [ ! -d "${PORTSDIR}/${1}" ] ; then
-				exit_err "No port (${PORTSDIR}/${1})"
-                        fi
                         PBI_MAKEPORT="$1"
                         ;;
                 esac
                 shift
         done
 
-	# Source the confi file
+	# Override some locations if working in chroot environment
+	if [ "`basename $0`" = "pbi_makeport_chroot" ] ; then 
+		if [ ! -z "${PBI_CONFDIR}" ] ; then PBI_CONFDIR="/pbimodule" ; fi
+		if [ ! -z "${PBI_SSLPRIVKEY}" ] ; then PBI_SSLPRIVKEY="/privkey.pem" ; fi
+		if [ ! -z "${PBI_CREATE_OUTDIR}" ] ; then PBI_CREATE_OUTDIR="/pbiout" ; fi
+		if [ ! -z "${PORTSDIR}" ] ; then PORTSDIR="/usr/ports" ; fi
+	fi
+
+	# Make sure this port exists
+	if [ ! -d "${PORTSDIR}/${PBI_MAKEPORT}" ] ; then
+		exit_err "No port (${PORTSDIR}/${PBI_MAKEPORT})"
+	fi
+
+	# Source the config file
 	if [ ! -z "${PBI_CONFDIR}" ]; then load_pbi_conffile ; fi
 
         if [ -z "${PBI_MAKEPORT}" ]; then
@@ -4636,8 +4648,8 @@
 		chroot "${PBI_CHROOTDIR}" "/usr/local/sbin/pbi_makeport_chroot" "$@"
 		_err=$?
 		if [ "$_err" = "0" ] ; then
-			mv ${PBI_CHROOTDIR}${PBI_CREATE_OUTDIR}/*.pbi ${PBI_CREATE_OUTDIR}/
-			mv ${PBI_CHROOTDIR}${PBI_CREATE_OUTDIR}/*.sha256 ${PBI_CREATE_OUTDIR}/
+			mv ${PBI_CHROOTDIR}/pbiout/*.pbi ${PBI_CREATE_OUTDIR}/
+			mv ${PBI_CHROOTDIR}/pbiout/*.sha256 ${PBI_CREATE_OUTDIR}/
 		fi
 
 		# Lets cleanup the chroot environment
@@ -4728,7 +4740,7 @@
 
 	# Now copy over the pbi_* scripts
 	mkdir ${PBI_CHROOTDIR}/usr/local/sbin
-	cp /usr/local/sbin/pbi_* ${PBI_CHROOTDIR}/usr/local/sbin
+	cp ${PROGBASE}/sbin/pbi_* ${PBI_CHROOTDIR}/usr/local/sbin
 	cp ${PBI_CHROOTDIR}/usr/local/sbin/pbi_makeport ${PBI_CHROOTDIR}/usr/local/sbin/pbi_makeport_chroot
 	chmod 755 ${PBI_CHROOTDIR}/usr/local/sbin/pbi_*
 
@@ -4737,20 +4749,21 @@
 	
 	# Copy over the confdir as well
 	if [ ! -z "${PBI_CONFDIR}" ] ; then
-		local _cDir=`dirname "${PBI_CONFDIR}"`
-		mkdir -p "${PBI_CHROOTDIR}${_cDir}"
-		echo "Copying ${PBI_CONFDIR} -> ${PBI_CHROOTDIR}${PBI_CONFDIR}"
-	 	cp -r "${PBI_CONFDIR}" "${PBI_CHROOTDIR}${PBI_CONFDIR}"
+		mkdir -p "${PBI_CHROOTDIR}/pbimodule"
+		echo "Copying ${PBI_CONFDIR} -> ${PBI_CHROOTDIR}/pbimodule"
+	 	tar cvf - -C "${PBI_CONFDIR}" . 2>/dev/null | tar xvf - -C "${PBI_CHROOTDIR}/pbimodule" 2>/dev/null
 	fi
 
 	# Copy over the ssl priv key if used
 	if [ ! -z "$PBI_SSLPRIVKEY" ] ; then
-		local _sDir=`dirname "${PBI_SSLPRIVKEY}"`
-		mkdir -p "${PBI_CHROOTDIR}${_sDir}"
-	 	cp "${PBI_SSLPRIVKEY}" "${PBI_CHROOTDIR}${PBI_SSLPRIVKEY}"
+	 	cp "${PBI_SSLPRIVKEY}" "${PBI_CHROOTDIR}/privkey.pem"
+		chmod 600 "${PBI_CHROOTDIR}/privkey.pem"
 	fi
 
 	# Start devfs in the chroot
+	if [ ! -d "${PBI_CHROOTDIR}/dev" ] ; then
+		mkdir ${PBI_CHROOTDIR}/dev
+	fi
 	mount -t devfs devfs ${PBI_CHROOTDIR}/dev
 
 	# Make sure the outgoing dir exists



More information about the Commits mailing list