[PC-BSD Commits] r8020 - in pcbsd/current/src-sh/pbi-manager: . port-files

svn at pcbsd.org svn at pcbsd.org
Thu Nov 11 12:59:30 PST 2010


Author: kris
Date: 2010-11-11 12:59:30 -0800 (Thu, 11 Nov 2010)
New Revision: 8020

Modified:
   pcbsd/current/src-sh/pbi-manager/pbi-manager
   pcbsd/current/src-sh/pbi-manager/port-files/Makefile
Log:

Enhance pbi-manager, now we'll auto-update the index every 24 hours, or whatever the tunable is set
to, also get rid of "curl" and use "fetch" for all remote stuff



Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-11 19:09:03 UTC (rev 8019)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-11 20:59:30 UTC (rev 8020)
@@ -742,8 +742,9 @@
 	PBI_FILENAME=""
 	PBI_FORCEADD="NO"
 	PBI_HASHLIST=".pbi-hash-list"
-	PBI_INDEXUPFILE="pbi-index-`uname -r | cut -c 1`"
-	PBI_INDEXUPTIME="pbi-index-`uname -r | cut -c 1`.time"
+	PBI_INDEXREFRESH="24" # Hours to wait until we re-download PBI indexes
+	#PBI_INDEXUPFILE="pbi-index-`uname -r | cut -c 1`"
+	PBI_INDEXUPFILE="pbi-index-9"
 	PBI_INFONAME=""
 	PBI_INS_DESKSCRIPT="install-desktop-icons.sh"
 	PBI_INS_MENUSCRIPT="install-menu-icons.sh"
@@ -2805,6 +2806,9 @@
 	while
 	i=1
 	do
+		# Check if we have any out of date index files to update
+		check_update_index "${PBI_DBINDEXDIR}/${PBI_INDEXUPFILE}"
+
 		# Check if we have a dirty hash-dir to cleanup
 		if [ -e "${PBI_DBDIRTYFILE}" ] ; then
 			init_tmpdir
@@ -2862,8 +2866,6 @@
 
 	# If we are listing available PBIs via the index file
 	if [ "$PBI_INFOINDEX" = "YES" ] ; then
-		# See if we need to update the PBI index file
-		check_update_index
 		
 		# List the available PBIs from the index
 		do_index_listing
@@ -2896,12 +2898,12 @@
 do_index_listing()
 {
 	# Make sure we have a master index
-	if [ ! -e "${PBI_APPDIR}/${PBI_INDEXUPFILE}" ] ; then return ; fi
+	if [ ! -e "${PBI_DBINDEXDIR}/${PBI_INDEXUPFILE}" ] ; then return ; fi
 
 	echo "Current and available PBIs from master INDEX. * = current"
 	echo "------------------------------------------------------"
 
-	sort "${PBI_APPDIR}/${PBI_INDEXUPFILE}" | while read _iLine
+	sort "${PBI_DBINDEXDIR}/${PBI_INDEXUPFILE}" | while read _iLine
 	do
 	        PBI_UPNAME="`echo $_iLine | cut -d ':' -f 1`"
 	        PBI_UPARCH="`echo $_iLine | cut -d ':' -f 2`"
@@ -3097,9 +3099,6 @@
 	# Open up the tmpdir
 	init_tmpdir
 
-	# See if we need to update the PBI index file
-	check_update_index
-
 	if [ "${PBI_UPCHECK}" = "YES" ] ; then
 		load_info_from_dir "${PBI_DBAPPDIR}/${PBI_UPDATEAPP}"
 		check_pbi_update "$PBI_UPDATEAPP" "display" \
@@ -3125,85 +3124,58 @@
 
 	init_tmpdir
 
-	# If not running as root then override PBI_INDEXUPFILE
-	if [ `id -u` != "0" ] ; then 
-		_pbiIndex="${PBI_TMPDIR}/tmp-index"
-		_svnRevFile="${PBI_TMPDIR}/${PBI_INDEXUPTIME}"
-	else
-		_pbiIndex="${PBI_APPDIR}/${PBI_INDEXUPFILE}"
-		_svnRevFile="${PBI_APPDIR}/${PBI_INDEXUPTIME}"
+	_pbiIndex="$1"
+	_pbiIndexTime="${1}.time"
+	_tmpPbiIndex="${PBI_TMPDIR}/.upcheck$$"
+		
+	# Check if its been greater than $PBI_INDEXREFRESH hours since the last update
+	if [ -e "${_pbiIndexTime}" ] ; then
+		_curTime=`date +%s`
+		_oTime=`cat ${_pbiIndexTime}`
+		_trigTime=`expr ${PBI_INDEXREFRESH} \* 60 \* 60`
+		expr $_curTime - $_oTime >/dev/null 2>/dev/null
+		if [ "$?" = "0" ] ; then
+			_passed=`expr $_curTime - $_oTime`
+			if [ "$_passed" -lt "$_trigTime" ] ; then
+				return;
+			fi
+		fi
+		
 	fi
 
-	_ufbsdver="`uname -r`"
-	#_ufbsdver="9"
+	echo "Updating index ${_pbiIndex}: `date`" >> ${_pbid_log}
+	if [ "${PBI_VERBOSE}" = "YES" ] ; then
+		echo "Updating index ${_pbiIndex}"
+	fi
 
-	# Set trigger for a fullUpdate
-	_fullUp="0"
+	# Check that the last char isn't a '/'
+	_tmp=`echo ${PBI_UPDATEURL} | wc -m | tr -s ' ' | tr -d ' '`
+	_tmp2=`expr $_tmp - 1`
+	_lastC=`echo ${_tmp} | cut -c ${_tmp2}-${_tmp}`
+	if [ "${_lastC}" = "/" ] ; then
+		_upURL="`echo ${PBI_UPDATEURL} | sed 's|\(.*\).|\1|'`"
+	else
+		_upURL="${PBI_UPDATEURL}"
+	fi
 
-	if [ -e "${_pbiIndex}" -a ! -z "${_svnRevFile}" ] ; then
-		#echo "Fetching diffs to $_pbiIndex"
-		#echo "$_svnrev"
-		_svnrev=`cat ${_svnRevFile}`
-		# Try to get a diff of the file
-		curl --insecure -o ${PBI_TMPDIR}/.upcheck$$ ${PBI_CURLPROXY} \
-			-F "SYSVER=${_ufbsdver}" \
-			-F "SVNREV=${_svnrev}" \
-			"${PBI_UPDATEURL}" >/dev/null 2>/dev/null 
-		if [ "$?" != "0" ]; then
-			_fullUp="0" 
-		else
-			# Good download, so lets try applying the patch
-			_newsvnrev=`cat ${PBI_TMPDIR}/.upcheck$$ 2>/dev/null | grep '^REVISION: ' | sed 's|REVISION: ||g'`
-
-			# Get the diff file
-			cat ${PBI_TMPDIR}/.upcheck$$ 2>/dev/null | grep -v '^REVISION: ' > ${PBI_TMPDIR}/.index$$.patch 2>/dev/null
-
-			_diff=`cat ${PBI_TMPDIR}/.index$$.patch`
-			if [ "$_diff" = "CURRENT" ] ; then
-				_fullUp="1" 
-			elif [ -z "$_diff" ] ; then
-				_fullUp="0" 
-			else
-				# Try to apply the diff now
-				cd ${PBI_APPDIR}
-				patch ${PBI_INDEXUPFILE} ${PBI_TMPDIR}/.index$$.patch >/dev/null 2>/dev/null
-				_err="$?"
-				rm ${PBI_INDEXUPFILE}.orig* 2>/dev/null
-				rm ${PBI_INDEXUPFILE}.rej* 2>/dev/null
-
-				# If we had a good patch apply, then we can skip the full download
-				if [ "$_err" = "0" ] ; then 
-					_fullUp="1" 
-					echo "$_newsvnrev" > ${_svnRevFile}
-				fi
-			fi
-		fi 
+	fetch -o "${_tmpPbiIndex}.bz2" "${_upURL}/${PBI_INDEXUPFILE}.bz2" >/dev/null 2>/dev/null
+	if [ "$?" != "0" ] ; then
+		return
 	fi
-	
-	# If our index is still empty, try to grab a fresh copy just to be sure
-	if [ -z "`cat ${_pbiIndex} 2>/dev/null | head -n 3`" ] ; then
-		_fullUp="0"
-	fi
 
-	# We need to do a full download of the index
-	if [ "$_fullUp" = "0" ] ; then
-		#echo "Fetching new $PBI_INDEXUPFILE"
-		# Checkout the entire INDEX file
-		curl --insecure -o ${PBI_TMPDIR}/.upcheck$$ ${PBI_CURLPROXY} \
-			-F "SYSVER=${_ufbsdver}" \
-			"${PBI_UPDATEURL}" >/dev/null 2>/dev/null 
-		if [ "$?" = "0" ] ; then
-			# Copy the Index File minus REVISION:
-			_newrev=`cat ${PBI_TMPDIR}/.upcheck$$ 2>/dev/null | grep '^REVISION: ' | sed 's|REVISION: ||g'`
-			cat ${PBI_TMPDIR}/.upcheck$$ 2>/dev/null | grep -v '^REVISION: ' > ${_pbiIndex}
-			echo "$_newrev" > ${_svnRevFile}
-		fi
+	bzip2 -d "${_tmpPbiIndex}.bz2" >/dev/null 2>/dev/null
+	if [ "$?" != "0" ] ; then
+		return
 	fi
 
+	# Move the uncompressed file, and save the timestamp
+	mv "${_tmpPbiIndex}" "${_pbiIndex}" >/dev/null 2>/dev/null
+	date +%s > ${_pbiIndexTime}
 
-	# Uncomment to see details from update server
-	#cat ${PBI_TMPDIR}/.upcheck$$
-
+	echo "Finished updating index ${_pbiIndex}: `date`" >> ${_pbid_log}
+	if [ "${PBI_VERBOSE}" = "YES" ] ; then
+		echo "Finished updating index ${_pbiIndex}"
+	fi
 }
 
 # Check a specific PBI for updates
@@ -3213,12 +3185,7 @@
 	# Init the tmpdir
 	init_tmpdir
 
-	# If not running as root then override PBI_INDEXUPFILE
-	if [ `id -u` != "0" ] ; then 
-		_pbiIndex="${PBI_TMPDIR}/tmp-index"
-	else
-		_pbiIndex="${PBI_APPDIR}/${PBI_INDEXUPFILE}"
-	fi
+	_pbiIndex="${PBI_DBINDEXDIR}/${PBI_INDEXUPFILE}"
 
 	# Set the vars
 	_upbi="${1}"
@@ -3286,9 +3253,6 @@
 	# Set the target program we want to download
 	_rtar="$PBI_FILENAME"
 
-	# See if we need to update the PBI index file
-	check_update_index
-
 	# Check if the user overrode the arch / versions we want to install
 	_rArch=`uname -m`
 	if [ ! -z "$PBI_ADD_ALTARCH" ] ; then _rArch=$PBI_ADD_ALTARCH ; fi
@@ -3454,13 +3418,13 @@
 	return 0
 }
 
-# Function to download a file from remote using curl
+# Function to download a file from remote using fetch
 pbi_get_file() {
 	_rf="${1}"
 	_lf="${2}"
 	if [ -e "${_lf}" ] ; then rm "$_lf" ; fi
 
-	curl -# ${PBI_CURLPROXY} -o "${_lf}" "${_rf}"
+	fetch -o "${_lf}" "${_rf}"
 	_err=$?
 	echo ""
 	return $_err
@@ -4234,25 +4198,21 @@
 	fi
 
 
-        # Create the PBI_CURLPROXY variable based upon proxy information supplied
+        # Create the PROXY variables based upon proxy information supplied
 	if [ ! -z "$PBI_PROXYURL" ] ; then
-		if [ "$PBI_PROXYTYPE" = "SOCKS5" ] ; then
-		  	PBI_CURLPROXY="--proxy-anyauth --socks5 ${PBI_PROXYURL}"
+		if [ ! -z "$PBI_PROXYPORT" ] ; then
+			HTTP_PROXY="${PBI_PROXYURL}:${PBI_PROXYPORT}"
+			export HTTP_PROXY
 		else
-		  	PBI_CURLPROXY="--proxy-anyauth --proxy ${PBI_PROXYURL}"
+			HTTP_PROXY="${PBI_PROXYURL}"
+			export HTTP_PROXY
 		fi
-		if [ ! -z "$PBI_PROXYPORT" ] ; then
-			PBI_CURLPROXY="${PBI_CURLPROXY}:${PBI_PROXYPORT}"
-		fi
 		if [ !-z "$PBI_PROXYUSER" ] ; then
 			if [ ! -z "$PBI_PROXYPASS" ] ; then
-				PBI_CURLPROXY="${PBI_CURLPROXY} --proxy-user ${PBI_PROXYUSER}:${PBI_PROXYPASS}"
-			else
-				PBI_CURLPROXY="${PBI_CURLPROXY} --proxy-user ${PBI_PROXYUSER}"
+				HTTP_PROXY_AUTH="basic:*:${PBI_PROXYUSER}:${PBI_PROXYPASS}"
+				export HTTP_PROXY_AUTH
 			fi
 		fi
-	else
-		PBI_CURLPROXY=""
 	fi
 }
 

Modified: pcbsd/current/src-sh/pbi-manager/port-files/Makefile
===================================================================
--- pcbsd/current/src-sh/pbi-manager/port-files/Makefile	2010-11-11 19:09:03 UTC (rev 8019)
+++ pcbsd/current/src-sh/pbi-manager/port-files/Makefile	2010-11-11 20:59:30 UTC (rev 8020)
@@ -14,14 +14,13 @@
 MAINTAINER=	kmoore at FreeBSD.org
 COMMENT=	Push Button Installer package creator
 
-RUN_DEPENDS=    curl:${PORTSDIR}/ftp/curl \
-		xdg-desktop-icon:${PORTSDIR}/devel/xdg-utils
+RUN_DEPENDS=	xdg-desktop-icon:${PORTSDIR}/devel/xdg-utils
 
 USE_BZIP2=	yes
 NO_BUILD=	yes
 
 MAN1=		pbi_autobuild.1 pbi_add.1 pbi_create.1 pbi_delete.1 \
-		pbi_icon.1 pbi_info.1 \
+		pbi_icon.1 pbi_info.1 pbid.1 \
 		pbi_patch.1 pbi_makeport.1 pbi_makepatch.1 pbi.conf.1
 
 do-install:



More information about the Commits mailing list