[PC-BSD Commits] r8010 - in pcbsd/current/src-sh/pbi-manager: . man rc.d

svn at pcbsd.org svn at pcbsd.org
Wed Nov 10 10:01:25 PST 2010


Author: kris
Date: 2010-11-10 10:01:25 -0800 (Wed, 10 Nov 2010)
New Revision: 8010

Added:
   pcbsd/current/src-sh/pbi-manager/man/pbid.1
   pcbsd/current/src-sh/pbi-manager/rc.d/pbid
Modified:
   pcbsd/current/src-sh/pbi-manager/install.sh
   pcbsd/current/src-sh/pbi-manager/pbi-manager
Log:

Added pbid command to pbi-manager, this will track hash-dir changes / merges / deletions, and make
adding / removing PBIs much faster



Modified: pcbsd/current/src-sh/pbi-manager/install.sh
===================================================================
--- pcbsd/current/src-sh/pbi-manager/install.sh	2010-11-10 15:46:42 UTC (rev 8009)
+++ pcbsd/current/src-sh/pbi-manager/install.sh	2010-11-10 18:01:25 UTC (rev 8010)
@@ -24,6 +24,7 @@
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_info
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_patch
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_update
+ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbid
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi-crashhandler
 
 # Install manpages
@@ -52,4 +53,5 @@
 # Copy the ldconfig script / pbi.conf
 #mkdir -p ${LB}/etc/rc.d >/dev/null 2>/dev/null
 #cp ${DIR}/rc.d/ldpbiconfig ${LB}/etc/rc.d/ldpbiconfig
+cp ${DIR}/rc.d/pbid ${LB}/etc/rc.d/pbid
 cp ${DIR}/etc/pbi.conf ${LB}/etc/pbi.conf

Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-10 15:46:42 UTC (rev 8009)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-10 18:01:25 UTC (rev 8010)
@@ -239,6 +239,17 @@
 	fi
 }
 
+# Parse the command line for pbid
+parse_pbid_cmdline() {
+        while [ $# -gt 0 ]; do
+                case "$1" in
+                -v)     PBI_VERBOSE="YES" 
+                        ;;
+		esac
+		shift
+	done
+}
+
 # Parse the command line for info
 parse_info_pbi_cmdline() {
         while [ $# -gt 0 ]; do
@@ -665,6 +676,7 @@
 	if [ ! -d "${PBI_DBAPPDIR}" ] ; then mkdir -p ${PBI_DBAPPDIR} >/dev/null 2>/dev/null ; fi
 	if [ ! -d "${PBI_DBKEYDIR}" ] ; then mkdir -p ${PBI_DBKEYDIR} >/dev/null 2>/dev/null ; fi
 	if [ ! -d "${PBI_DBINDEXDIR}" ] ; then mkdir -p ${PBI_DBINDEXDIR} >/dev/null 2>/dev/null ; fi
+	if [ ! -d "${PBI_DBHASHQUEUEDIR}" ] ; then mkdir -p ${PBI_DBHASHQUEUEDIR} >/dev/null 2>/dev/null ; fi
 }
 
 # Get the absolute path of a dir
@@ -695,6 +707,7 @@
 	PBI_LDCONFIGFILE="${PROGBASE}/etc/ldpbiconfig"
 	PBI_LDCONFIGRC="${PROGBASE}/etc/rc.d/ldpbiconfig"
 	PROGVERSION="1.0"
+	PBIDSLEEP="300"		# Amount of time to sleep before waking up pbid
 
 	# What dirs do we build hash-lists of
 	HASH_SEARCH_DIRS="lib kde4/lib share"
@@ -782,8 +795,10 @@
 		PBI_DBDIR="/var/db/pbi"
 	fi
 	PBI_DBAPPDIR="${PBI_DBDIR}/installed"
+	PBI_DBDIRTYFILE="${PBI_DBDIR}/.hashdirty"
+	PBI_DBHASHQUEUEDIR="${PBI_DBDIR}/.hashqueue"
+	PBI_DBINDEXDIR="${PBI_DBDIR}/index"
 	PBI_DBKEYDIR="${PBI_DBDIR}/keys"
-	PBI_DBINDEXDIR="${PBI_DBDIR}/index"
 	PBI_DISABLEHASHDIR="NO"
 	PBI_GUITOPBANNER="gui_banner.png"
 	PBI_GUISIDEBANNER="gui_sidebanner.png"
@@ -1095,9 +1110,6 @@
 	# Make sure we have good permissions on this PBI
 	patch_apply_chmod
 
-	# Update the hashdir
-	pbi_add_update_hashdir "${PBI_PATCHWRKDIR}"
-
 	# Run the install script
 	if [ -e "${PBI_PATCHWRKDIR}/.sbin/.pbi-install.sh" ] ; then
 		echo "Adding new xdg data..."
@@ -1118,6 +1130,9 @@
 		rm -rf "$PBI_EXTRACTDIR"
 	fi
 
+	# Update the hashdir
+	add_hashdir_trigger
+
 	echo "Finished patching ${_pbilow}: $PBI_PATCHTARGET -> $PBI_PATCHVERSION"
 }
 
@@ -1564,13 +1579,20 @@
 	pbi_add_run_script
 	check_postinstall_script
 
-	pbi_add_update_hashdir "${PBI_PROGDIRPATH}"
-
 	pbi_add_register_app
 
+	# Be sure to let the pbid know we have a new hash-dir to register
+	add_hashdir_trigger
+
 	clean_remote_dl
 }
 
+add_hashdir_trigger() {
+	get_dbdir
+        _htrig="`echo ${APPDBDIR} | sed 's|${PBI_DBAPPDIR}/||g'`"
+	touch ${PBI_DBHASHQUEUEDIR}/${_htrig}
+}
+
 # Run the install script if exists
 pbi_add_run_script() {
 	insc="${PBI_PROGDIRPATH}/${PBI_FAKEBIN_DIR}/.pbi-install.sh"
@@ -1630,10 +1652,10 @@
 	fi
 
 	# Check the file sizes, if they differ we can skip diff
-	#if [ "`ls -al ${PBI_HASHDIR}/${tfile} | awk '{ print $5}'`" != "`ls -al ${file} | awk '{ print $5}'`" ] ; then
-	#	if [ "$PBI_VERBOSE" = "YES" ] ; then echo "X" ; fi
-	#	return
-	#fi
+	if [ "`ls -al ${PBI_HASHDIR}/${tfile} | awk '{ print $5}'`" != "`ls -al ${file} | awk '{ print $5}'`" ] ; then
+		if [ "$PBI_VERBOSE" = "YES" ] ; then echo "X" ; fi
+		return
+	fi
 
 	# Confirm that the files are the same
 	#diff -q "${file}" "${PBI_HASHDIR}/${tfile}" >/dev/null 2>/dev/null
@@ -2759,6 +2781,58 @@
 	fi
 }
 
+pbid_init() {
+
+	parse_pbid_cmdline "$@"
+
+	do_pbid
+}
+
+# Start the PBID daemon
+do_pbid() {
+
+	# Set verbosity 
+	_redir=""
+	if [ "${PBI_VERBOSE}" = "YES" ] ; then _redir=">/dev/null 2>/dev/null" ; fi
+
+	while
+	i=1
+	do
+		# Check if we have a dirty hash-dir to cleanup
+		if [ -e "${PBI_DBDIRTYFILE}" ] ; then
+			pbi_clean_hashdir ${_redir}
+			rm ${PBI_DBDIRTYFILE} >/dev/null 2>/dev/null
+		fi
+
+		# Check if we need to merge files into the hashdir
+		if [ ! -z `ls ${PBI_DBHASHQUEUEDIR}` ] ; then
+			for _hpbi in `ls ${PBI_DBHASHQUEUEDIR}`
+			do
+				if [ ! -e "${PBI_DBAPPDIR}/${_hpbi}/pbi_installedpath" ] ; then
+					rm ${PBI_DBHASHQUEUEDIR}/${_hpbi}
+					continue
+				fi
+
+				_hpbipath=""
+				_hpbipath=`cat ${PBI_DBAPPDIR}/${_hpbi}/pbi_installedpath`
+				if [ ! -e "${_hpbipath}/${PBI_HASHLIST}" ] ; then
+					rm ${PBI_DBHASHQUEUEDIR}/${_hpbi}
+					continue
+				fi
+
+				# Lets start this hash merge
+				pbi_add_update_hashdir "${_hpbipath}" ${_redir}
+
+			done
+
+		fi
+
+		# Done with our check, lets go back to sleep now
+		sleep ${PBIDSLEEP}
+	done
+
+}
+
 pbi_info_init() {
 	parse_info_pbi_cmdline "$@"
 	
@@ -4124,14 +4198,16 @@
 	if [ -z "$PBI_MIRROR4" ] ; then PBI_MIRROR4="$PBI_MIRROR" ; fi
 
         # Load Proxy Variables
-	PBI_PROXYURL="`cat ${PBI_ETCCONF} | grep 'PBI_PROXYURL: ' | sed 's|PBI_PROXYURL: ||g'`"
-	PBI_PROXYPORT="`cat ${PBI_ETCCONF} | grep 'PBI_PROXYPORT: ' | sed 's|PBI_PROXYPORT: ||g'`"
-	PBI_PROXYTYPE="`cat ${PBI_ETCCONF} | grep 'PBI_PROXYTYPE: ' | sed 's|PBI_PROXYTYPE: ||g'`"
-	PBI_PROXYUSER="`cat ${PBI_ETCCONF} | grep 'PBI_PROXYUSER: ' | sed 's|PBI_PROXYUSER: ||g'`"
-	PBI_PROXYPASS="`cat ${PBI_ETCCONF} | grep 'PBI_PROXYPASS: ' | sed 's|PBI_PROXYPASS: ||g'`"
+	if [ -z "$PBI_PROXYURL" -a -e "${PBI_ETCCONF}" ] ; then
+		PBI_PROXYURL="`cat ${PBI_ETCCONF} | grep 'PBI_PROXYURL: ' | sed 's|PBI_PROXYURL: ||g'`"
+		PBI_PROXYPORT="`cat ${PBI_ETCCONF} | grep 'PBI_PROXYPORT: ' | sed 's|PBI_PROXYPORT: ||g'`"
+		PBI_PROXYTYPE="`cat ${PBI_ETCCONF} | grep 'PBI_PROXYTYPE: ' | sed 's|PBI_PROXYTYPE: ||g'`"
+		PBI_PROXYUSER="`cat ${PBI_ETCCONF} | grep 'PBI_PROXYUSER: ' | sed 's|PBI_PROXYUSER: ||g'`"
+		PBI_PROXYPASS="`cat ${PBI_ETCCONF} | grep 'PBI_PROXYPASS: ' | sed 's|PBI_PROXYPASS: ||g'`"
+	fi
 
 	# If empty proxy config, check if configured for master pcbsd.conf file
-	if [ -z "$PBI_PROXYURL" ] ; then
+	if [ -z "$PBI_PROXYURL" -a -e "${PCBSD_ETCCONF}" ] ; then
 		PBI_PROXYURL="`cat ${PCBSD_ETCCONF} | grep 'PCBSD_PROXYURL: ' | sed 's|PCBSD_PROXYURL: ||g'`"
 		PBI_PROXYPORT="`cat ${PCBSD_ETCCONF} | grep 'PCBSD_PROXYPORT: ' | sed 's|PCBSD_PROXYPORT: ||g'`"
 		PBI_PROXYTYPE="`cat ${PCBSD_ETCCONF} | grep 'PCBSD_PROXYTYPE: ' | sed 's|PCBSD_PROXYTYPE: ||g'`"
@@ -4192,6 +4268,7 @@
    pbi_patch) pbi_patch_init "$@" ;;
    pbi_update) pbi_update_init "$@" ;;
    pbi-crashhandler) pbi_crash_init "$@" ;;
+   pbid) pbid_init "$@" ;;
    *) echo "Error: Called with invalid basename!" ; exit_trap ;;
 esac
 


Property changes on: pcbsd/current/src-sh/pbi-manager/rc.d/pbid
___________________________________________________________________
Added: svn:executable
   + *



More information about the Commits mailing list