[PC-BSD Commits] r7935 - pcbsd/current/src-sh/pbi-manager
svn at pcbsd.org
svn at pcbsd.org
Thu Oct 28 12:38:41 PDT 2010
Author: kris
Date: 2010-10-28 12:38:41 -0700 (Thu, 28 Oct 2010)
New Revision: 7935
Modified:
pcbsd/current/src-sh/pbi-manager/pbi-manager
Log:
Added ability to run update checks, both -c and --check-all when regular
user to pbi_update
Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager 2010-10-28 19:05:50 UTC (rev 7934)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager 2010-10-28 19:38:41 UTC (rev 7935)
@@ -819,12 +819,16 @@
# init tmpdir
init_tmpdir() {
+ if [ -d "${PBI_TMPDIR}" ] ; then return; fi
+ if [ -z "${PBI_TMPDIR}" ] ; then return ; fi
+ if [ "${PBI_TMPDIR}" = "/" ] ; then return ; fi
if [ -e "${PBI_TMPDIR}" ] ; then rm -rf "${PBI_TMPDIR}" ; fi
mkdir -p "${PBI_TMPDIR}"
}
# rm tmpdir
rm_tmpdir() {
+ if [ -z "${PBI_TMPDIR}" -o "${PBI_TMPDIR}" = "/" ] ; then return 0; fi
if [ -e "${PBI_TMPDIR}" ] ; then rm -rf "${PBI_TMPDIR}" ; fi
}
@@ -2958,12 +2962,15 @@
# Start pbi_update processing
pbi_update_init() {
- require_root
-
parse_update_pbi_cmdline "$@"
start_update_checks
+ # Stop here if only doing update checks
+ if [ ! -z "${PBI_UPCHECK}" ]; then return 0 ; fi
+
+ require_root
+
do_pbi_update
}
@@ -3000,24 +3007,27 @@
# Check if we need to pull down the updated INDEX file
check_update_index() {
- # If not running as root, don't bother trying to update
- if [ `id -u` != "0" ] ; then return ; fi
-
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}"
+ fi
+
_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}`
+ 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}" \
@@ -3048,14 +3058,14 @@
# 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}
+ echo "$_newsvnrev" > ${_svnRevFile}
fi
fi
fi
fi
# If our index is still empty, try to grab a fresh copy just to be sure
- if [ -z "`cat ${PBI_INDEXUPFILE} 2>/dev/null | head -n 3`" ] ; then
+ if [ -z "`cat ${_pbiIndex} 2>/dev/null | head -n 3`" ] ; then
_fullUp="0"
fi
@@ -3068,9 +3078,9 @@
"${PBI_UPDATEURL}" >/dev/null 2>/dev/null
if [ "$?" = "0" ] ; then
# Copy the Index File minus REVISION:
- _svnrev=`cat ${PBI_TMPDIR}/.upcheck$$ 2>/dev/null | grep '^REVISION: ' | sed 's|REVISION: ||g'`
- cat ${PBI_TMPDIR}/.upcheck$$ 2>/dev/null | grep -v '^REVISION: ' > ${PBI_APPDIR}/${PBI_INDEXUPFILE}
- echo "$_svnrev" > ${PBI_APPDIR}/${PBI_INDEXUPTIME}
+ _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
fi
@@ -3087,6 +3097,13 @@
# 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
+
# Set the vars
_upbi="${1}"
_udisp="${2}"
@@ -3111,7 +3128,7 @@
fi
# Search the update index for the specified PBI
- _upLine=`grep -i -e "^$_uprog:" ${PBI_APPDIR}/${PBI_INDEXUPFILE} | grep ":$_uarch:" | grep "$_uver" | head -n 1`
+ _upLine=`grep -i -e "^$_uprog:" ${_pbiIndex} | grep ":$_uarch:" | grep "$_uver" | head -n 1`
PBI_UPNVER="`echo $_upLine | cut -d ':' -f 3`"
PBI_UPFILE="`echo $_upLine | cut -d ':' -f 6`"
More information about the Commits
mailing list