[PC-BSD Commits] r7480 - in pcbsd-projects/pbi-manager: . etc
svn at pcbsd.org
svn at pcbsd.org
Wed Sep 1 11:56:10 PDT 2010
Author: kris
Date: 2010-09-01 11:56:10 -0700 (Wed, 01 Sep 2010)
New Revision: 7480
Modified:
pcbsd-projects/pbi-manager/etc/pbi.conf
pcbsd-projects/pbi-manager/pbi-manager
Log:
Large update to pbi-manager, now it is able to use the new INDEX method of searching for updates / remote installs of PBIs with pbi_add -r. This saves a lot on bandwidth, and should greatly speed up processing when dealing with a large number of installed PBIs
Modified: pcbsd-projects/pbi-manager/etc/pbi.conf
===================================================================
--- pcbsd-projects/pbi-manager/etc/pbi.conf 2010-09-01 15:58:02 UTC (rev 7479)
+++ pcbsd-projects/pbi-manager/etc/pbi.conf 2010-09-01 18:56:10 UTC (rev 7480)
@@ -1,7 +1,7 @@
# PBI Configuration Defaults
# Default PBI Update Server
-PBI_UPDATEURL: http://update.pbidir.com
+PBI_UPDATEURL: https://update.pbidir.com/update-index.php
# Public openssl keys
PBI_PUBKEYS: /var/db/pbi-keys/pcbsd.ssl
Modified: pcbsd-projects/pbi-manager/pbi-manager
===================================================================
--- pcbsd-projects/pbi-manager/pbi-manager 2010-09-01 15:58:02 UTC (rev 7479)
+++ pcbsd-projects/pbi-manager/pbi-manager 2010-09-01 18:56:10 UTC (rev 7480)
@@ -521,6 +521,8 @@
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_INFONAME=""
PBI_INS_DESKSCRIPT="install-desktop-icons.sh"
PBI_INS_MENUSCRIPT="install-menu-icons.sh"
@@ -2267,6 +2269,9 @@
# 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_DBDIR}/${PBI_UPDATEAPP}"
check_pbi_update "$PBI_UPDATEAPP" "display" \
@@ -2290,6 +2295,74 @@
}
+# Check if we need to pull down the updated INDEX file
+check_update_index() {
+ #_ufbsdver="`uname -r`"
+ _ufbsdver="9"
+
+ # Init the tmpdir
+ init_tmpdir
+
+ # Set trigger for a fullUpdate
+ _fullUp="0"
+
+ if [ -e "${PBI_APPDIR}/${PBI_INDEXUPFILE}" -a -e "${PBI_APPDIR}/${PBI_INDEXUPTIME}" ] ; then
+ #echo "Fetching diffs to $PBI_INDEXUPFILE"
+ _svnrev=`cat ${PBI_APPDIR}/${PBI_INDEXUPTIME}`
+ # 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
+
+ _newsvnrev=`cat ${PBI_TMPDIR}/.upcheck$$ | grep '^REVISION: ' | sed 's|REVISION: ||g'`
+
+ # Get the diff file
+ cat ${PBI_TMPDIR}/.upcheck$$ | grep -v '^REVISION: ' > ${PBI_TMPDIR}/.index$$.patch
+
+ _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" > ${PBI_APPDIR}/${PBI_INDEXUPTIME}
+ fi
+ fi
+ 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
+
+ # Copy the Index File minus REVISION:
+ _svnrev=`cat ${PBI_TMPDIR}/.upcheck$$ | grep '^REVISION: ' | sed 's|REVISION: ||g'`
+ cat ${PBI_TMPDIR}/.upcheck$$ | grep -v '^REVISION: ' > ${PBI_APPDIR}/${PBI_INDEXUPFILE}
+ echo "$_svnrev" > ${PBI_APPDIR}/${PBI_INDEXUPTIME}
+ fi
+
+
+ # Uncomment to see details from update server
+ #cat ${PBI_TMPDIR}/.upcheck$$
+
+ # Bye Bye!
+ rm_tmpdir
+}
+
# Check a specific PBI for updates
check_pbi_update() {
if [ -z "${PBI_UPDATEURL}" ] ; then return ; fi
@@ -2306,35 +2379,19 @@
_uarch="${6}"
appname="`echo ${_uprog} | tr '[:lower:]' '[:upper:]'`"
- curl -o ${PBI_TMPDIR}/.upcheck$$ ${PBI_CURLPROXY} \
- -F "PBIName=${appname}" \
- -F "PBIVer=${_uprog}" \
- -F "PCBSDVER=${_ufbsdver}" \
- -F "PBIEd=2" \
- -F "OSARCH=${_uarch}" \
- "${PBI_UPDATEURL}" >/dev/null 2>/dev/null
- # Uncomment to see details from update server
- #cat ${PBI_TMPDIR}/.upcheck$$
-
PBI_UPNVER=""
- PBI_UPMIRROR1=""
- PBI_UPMIRROR2=""
- PBI_UPMIRROR3=""
PBI_UPFILE=""
PBI_UPCSUM=""
PBI_UPMDATE=""
- # Load some variables from the update check
- PBI_UPNVER="`cat ${PBI_TMPDIR}/.upcheck$$ | grep 'NewVer: ' | sed 's|NewVer: ||g'`"
- PBI_UPMIRROR1="`cat ${PBI_TMPDIR}/.upcheck$$ | grep 'Mirror1: ' | sed 's|Mirror1: ||g'`"
- PBI_UPMIRROR2="`cat ${PBI_TMPDIR}/.upcheck$$ | grep 'Mirror2: ' | sed 's|Mirror2: ||g'`"
- PBI_UPMIRROR3="`cat ${PBI_TMPDIR}/.upcheck$$ | grep 'Mirror3: ' | sed 's|Mirror3: ||g'`"
- PBI_UPFILE="`cat ${PBI_TMPDIR}/.upcheck$$ | grep 'FileLoc: ' | sed 's|FileLoc: ||g'`"
- PBI_UPCSUM="`cat ${PBI_TMPDIR}/.upcheck$$ | grep 'MD5: ' | sed 's|MD5: ||g'`"
- PBI_UPMDATE="`cat ${PBI_TMPDIR}/.upcheck$$ | grep 'MDATE: ' | sed 's|MDATE: ||g'`"
+ # Search the update index for the current PBI
+ _upLine=`grep -i -e "^$_uprog:" ${PBI_APPDIR}/${PBI_INDEXUPFILE} | grep ":$_uarch:" | grep ":current" | head -n 1`
- rm ${PBI_TMPDIR}/.upcheck$$
+ PBI_UPNVER="`echo $_upLine | cut -d ':' -f 3`"
+ PBI_UPFILE="`echo $_upLine | cut -d ':' -f 6`"
+ PBI_UPCSUM="`echo $_upLine | cut -d ':' -f 4`"
+ PBI_UPMDATE="`echo $_upLine | cut -d ':' -f 5`"
# If no new version
if [ -z "$PBI_UPNVER" ] ; then return 1 ; fi
@@ -2377,7 +2434,7 @@
"$_rtar" "-0" \
"`uname -r`" "`uname -m`"
if [ "$?" != "0" ] ; then
- exit_err "Cound not find \"$_rtar\""
+ exit_err "Could not find \"$_rtar\" in $PBI_INDEXUPFILE"
fi
# We've gotten this far, now download the updated PBI
@@ -2454,9 +2511,9 @@
do
# Do download from updater mirrors
case $_upattempt in
- 1) _furl="`echo $PBI_UPMIRROR1 | sed 's/\/*$//'`${PBI_UPFILE}" ;;
- 2) _furl="`echo $PBI_UPMIRROR2 | sed 's/\/*$//'`${PBI_UPFILE}" ;;
- 3) _furl="`echo $PBI_UPMIRROR3 | sed 's/\/*$//'`${PBI_UPFILE}" ;;
+ 1) _furl="`echo $PBI_PBIMIRROR2 | sed 's/\/*$//'`${PBI_UPFILE}" ;;
+ 2) _furl="`echo $PBI_PBIMIRROR3 | sed 's/\/*$//'`${PBI_UPFILE}" ;;
+ 3) _furl="`echo $PBI_PBIMIRROR4 | sed 's/\/*$//'`${PBI_UPFILE}" ;;
esac
echo "Downloading ${_furl}"
pbi_get_file "$_furl" "$_dl_loc"
@@ -2489,7 +2546,9 @@
if [ -e "${_lf}" ] ; then rm "$_lf" ; fi
curl -# ${PBI_CURLPROXY} -o "${_lf}" "${_rf}"
- return $?
+ _err=$?
+ echo ""
+ return $_err
}
# start processing autobuild
@@ -2813,6 +2872,14 @@
# Set the default remote mirror we are using
PBI_MIRROR="`cat ${PBI_ETCCONF} | grep 'PBI_MIRROR: ' | sed 's|PBI_MIRROR: ||g'`"
+ PBI_MIRROR2="`cat ${PBI_ETCCONF} | grep 'PBI_MIRROR2: ' | sed 's|PBI_MIRROR2: ||g'`"
+ PBI_MIRROR3="`cat ${PBI_ETCCONF} | grep 'PBI_MIRROR3: ' | sed 's|PBI_MIRROR3: ||g'`"
+ PBI_MIRROR4="`cat ${PBI_ETCCONF} | grep 'PBI_MIRROR4: ' | sed 's|PBI_MIRROR4: ||g'`"
+
+ # If no additional mirrors
+ if [ -z "$PBI_MIRROR2" ] ; then PBI_MIRROR2="$PBI_MIRROR" ; fi
+ if [ -z "$PBI_MIRROR3" ] ; then PBI_MIRROR3="$PBI_MIRROR" ; fi
+ 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'`"
More information about the Commits
mailing list