[PC-BSD Commits] r8040 - in pcbsd/current/src-sh/pbi-manager: . man
svn at pcbsd.org
svn at pcbsd.org
Wed Nov 17 12:34:36 PST 2010
Author: kris
Date: 2010-11-17 12:34:35 -0800 (Wed, 17 Nov 2010)
New Revision: 8040
Added:
pcbsd/current/src-sh/pbi-manager/man/pbi_listrepo.1
Modified:
pcbsd/current/src-sh/pbi-manager/man/pbi_add.1
pcbsd/current/src-sh/pbi-manager/pbi-manager
Log:
Added ability to list repos, move them up and down in priority, fetch indexs automatically, and
also specify a specific repo when using pbi_add -r
Modified: pcbsd/current/src-sh/pbi-manager/man/pbi_add.1
===================================================================
--- pcbsd/current/src-sh/pbi-manager/man/pbi_add.1 2010-11-17 18:29:31 UTC (rev 8039)
+++ pcbsd/current/src-sh/pbi-manager/man/pbi_add.1 2010-11-17 20:34:35 UTC (rev 8040)
@@ -18,6 +18,7 @@
.Op Fl -no-checksig
.Op Fl -no-checksum
.Op Fl -no-hash
+.Op Fl -repo Ar repoid
.Op Fl -rArch Ar arch
.Op Fl -rVer Ar version
.Op Ar pbidir
@@ -70,6 +71,10 @@
.It Fl -no-hash
Disable using the shared-hash dir, which uses hard-links to share files
between applications which are the same.
+.It Fl -repo Ar repoid
+When using -r to fetch a remote PBI, the --repo flag may be used to pick a specific
+repo to use. If not specified, then the repos will be searched by priority until
+a PBI match is found. Repo IDs may be found with the pbi_listrepo command.
.It Fl -rArch Ar arch
When using -r to fetch and install a PBI, the machine architecture is detected
automatically. Using the -rArch <arch> flag allows you to manually specify the
Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager 2010-11-17 18:29:31 UTC (rev 8039)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager 2010-11-17 20:34:35 UTC (rev 8040)
@@ -177,6 +177,18 @@
exit_trap
}
+usage_listrepo_pbi() {
+ cat <<EOF
+usage: `basename $0` [options] [repoid]
+
+Options:
+ --down -- Move the specified repoid down in priority
+ --up -- Move the specified repoid up in priority
+
+EOF
+ exit_trap
+}
+
usage_makerepo_pbi() {
cat <<EOF
usage: `basename $0` [options] [outdir]
@@ -332,6 +344,37 @@
}
# Parse the command line for adding a new repo file
+parse_listrepo_pbi_cmdline() {
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ --up) PBI_LISTREPO_UP="YES" ;;
+ --down) PBI_LISTREPO_DOWN="YES" ;;
+ *) if [ $# -gt 1 ]; then usage_listrepo_pbi; fi
+ PBI_LISTREPO_ID="$1"
+ ;;
+ esac
+ shift
+ done
+
+ if [ "${PBI_LISTREPO_UP}" = "YES" -a "${PBI_LISTREPO_DOWN}" = "YES" ]; then
+ exit_err "Options --up and --down can't both be used at once!"
+ fi
+ if [ "${PBI_LISTREPO_UP}" = "YES" -a -z "${PBI_LISTREPO_ID}" ]; then
+ exit_err "Missing Repo ID to move up in priority."
+ fi
+ if [ "${PBI_LISTREPO_DOWN}" = "YES" -a -z "${PBI_LISTREPO_ID}" ]; then
+ exit_err "Missing Repo ID to move down in priority."
+ fi
+
+ if [ ! -z "${PBI_LISTREPO_ID}" ] ; then
+ ls ${PBI_DBREPODIR}/${PBI_LISTREPO_ID}.* >/dev/null 2>/dev/null
+ if [ "$?" != "0" ] ; then
+ exit_err "The specified repoid ${PBI_LISTREPO_ID} does not exist!"
+ fi
+ fi
+}
+
+# Parse the command line for adding a new repo file
parse_addrepo_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
@@ -469,8 +512,7 @@
;;
-l) PBI_ADD_LICDISPLAY="YES"
;;
- -o)
- if [ $# -eq 1 ]; then usage_add_pbi; fi
+ -o) if [ $# -eq 1 ]; then usage_add_pbi; fi
shift; PBI_ALTEXTRACT_DIR="$1"
;;
-r) PBI_REMOTEFETCH="YES"
@@ -490,6 +532,9 @@
--no-hash) PBI_DISABLEHASHDIR="YES" ;;
--no-checksum) PBI_SKIPCHECKSUM="YES" ;;
--no-checksig) PBI_SKIPSIGVERIFY="YES" ;;
+ --repo) if [ $# -eq 1 ]; then usage_add_pbi; fi
+ shift; PBI_ADDREPO_ID="$1"
+ ;;
*)
if [ $# -gt 1 ]; then usage_add_pbi; fi
if [ ! -e "${1}" -a -z "$PBI_REMOTEFETCH" ] ; then
@@ -505,7 +550,18 @@
# If we are doing a remote fetch / install then do it now
if [ "$PBI_REMOTEFETCH" = "YES" ] ; then
+ if [ -z "${PBI_ADDREPO_ID}" ] ; then
+ PBI_ADDREPO_ID="AUTO"
+ else
+ ls ${PBI_DBREPODIR}/${PBI_ADDREPO_ID}.* >/dev/null 2>/dev/null
+ if [ "$?" != "0" ] ; then
+ exit_err "No such repo ID: ${PBI_DELREPO_ID}"
+ fi
+ fi
+
+ # Start fetching file
pbi_add_fetch_remote
+
fi
# Load all the information about this PBI
@@ -1176,6 +1232,11 @@
else
echo "Warning: ${_md5}.ssl does not exist in the keys database."
fi
+
+ # See if we need to remove a downloaded index file
+ if [ -e "${PBI_DBINDEXDIR}/${_md5}-index" ] ; then
+ rm "${PBI_DBINDEXDIR}/${_md5}-index"
+ fi
# Make sure we renumber the repos
renumber_repos
@@ -1280,6 +1341,87 @@
rm_tmpdir
}
+# Add a new repo to the db
+pbi_listrepo_init() {
+ require_root
+ parse_listrepo_pbi_cmdline "$@"
+
+ # List the repos
+ if [ -z "$PBI_LISTREPO_ID" ] ; then
+ list_all_pbi_repo
+ else
+ if [ ! -z "${PBI_LISTREPO_UP}" ]; then
+ move_repo_up "${PBI_LISTREPO_ID}"
+ list_all_pbi_repo
+ elif [ ! -z "${PBI_LISTREPO_DOWN}" ] ; then
+ move_repo_down "${PBI_LISTREPO_ID}"
+ list_all_pbi_repo
+ else
+ listrepo_details "${PBI_LISTREPO_ID}"
+ fi
+ fi
+}
+
+# Move a repo down in priority
+move_repo_down() {
+ _rFile=`ls ${PBI_DBREPODIR}/${1}.*`
+ _uNum=`expr ${1} + 1`
+
+ case `echo ${_uNum} | wc -m | tr -d ' '` in
+ 2) _uNum="00${_uNum}" ;;
+ 3) _uNum="0${_uNum}" ;;
+ *) ;;
+ esac
+ _uFile=`ls ${PBI_DBREPODIR}/${_uNum}.* 2>/dev/null`
+ if [ -z "$_uFile" ] ; then exit_err "This repo is already at the lowest priority!" ; fi
+
+ _umd5=`echo $_uFile | cut -d '.' -f 2`
+ mv "${_uFile}" "${PBI_DBREPODIR}/${1}.${_umd5}"
+ _rmd5=`echo $_rFile | cut -d '.' -f 2`
+ mv "${_rFile}" "${PBI_DBREPODIR}/${_uNum}.${_rmd5}"
+}
+
+# Move a repo up in priority
+move_repo_up() {
+ _rFile=`ls ${PBI_DBREPODIR}/${1}.*`
+ _uNum=`expr ${1} - 1`
+
+ case `echo ${_uNum} | wc -m | tr -d ' '` in
+ 2) _uNum="00${_uNum}" ;;
+ 3) _uNum="0${_uNum}" ;;
+ *) ;;
+ esac
+ _uFile=`ls ${PBI_DBREPODIR}/${_uNum}.* 2>/dev/null`
+ if [ -z "$_uFile" ] ; then exit_err "This repo is already at the highest priority!" ; fi
+
+ _umd5=`echo $_uFile | cut -d '.' -f 2`
+ mv "${_uFile}" "${PBI_DBREPODIR}/${1}.${_umd5}"
+ _rmd5=`echo $_rFile | cut -d '.' -f 2`
+ mv "${_rFile}" "${PBI_DBREPODIR}/${_uNum}.${_rmd5}"
+}
+
+# List all PBI repos
+listrepo_details() {
+ _rFile=`ls ${PBI_DBREPODIR}/${1}.*`
+ _desc=`cat ${_rFile} | grep "Desc: " | sed "s|Desc: ||g"`
+ _url=`cat ${_rFile} | grep "URL: " | sed "s|URL: ||g"`
+ echo "Repo ID: ${1}"
+ echo "Description: ${_desc}"
+ echo "URL: ${_url}"
+}
+
+# List all PBI repos
+list_all_pbi_repo() {
+ echo "[ID] [Description]"
+ echo "-----------------------------------------------------"
+ for repo in `ls ${PBI_DBREPODIR} | sort `
+ do
+ _id=`echo $repo | cut -d '.' -f 1`
+ _desc=`cat ${PBI_DBREPODIR}/${repo} | grep "Desc: " | sed "s|Desc: ||g"`
+ echo "${_id} ${_desc}"
+ done
+}
+
# Start the patch process
pbi_patch_init() {
require_root
@@ -3032,7 +3174,11 @@
i=1
do
# Check if we have any out of date index files to update
- check_update_index "${PBI_DBINDEXDIR}/${PBI_INDEXUPFILE}"
+ for _dbIndex in `ls ${PBI_DBREPODIR}`
+ do
+ _iMd5=`echo ${_dbIndex} | cut -d '.' -f 2`
+ check_update_index "${_iMd5}"
+ done
# Check if we have a dirty hash-dir to cleanup
if [ -e "${PBI_DBDIRTYFILE}" ] ; then
@@ -3348,9 +3494,12 @@
check_update_index() {
init_tmpdir
+
+ local _repoMd5="$1"
+ local _rURL=`cat ${PBI_DBREPODIR}/*${_repoMd5} | grep URL: | sed 's|URL: ||g'`
- _pbiIndex="$1"
- _pbiIndexTime="${1}.time"
+ _pbiIndex="${PBI_DBINDEXDIR}/${_repoMd5}-index"
+ _pbiIndexTime="${_pbiIndex}.time"
_tmpPbiIndex="${PBI_TMPDIR}/.upcheck$$"
# Check if its been greater than $PBI_INDEXREFRESH hours since the last update
@@ -3374,7 +3523,7 @@
fi
# Check that the last char isn't a '/'
- _tmp=`echo ${PBI_UPDATEURL} | wc -m | tr -s ' ' | tr -d ' '`
+ _tmp=`echo ${_rURL} | wc -m | tr -s ' ' | tr -d ' '`
_tmp2=`expr $_tmp - 1`
_lastC=`echo ${_tmp} | cut -c ${_tmp2}-${_tmp}`
if [ "${_lastC}" = "/" ] ; then
@@ -3410,8 +3559,6 @@
# Init the tmpdir
init_tmpdir
- _pbiIndex="${PBI_DBINDEXDIR}/${PBI_INDEXUPFILE}"
-
# Set the vars
_upbi="${1}"
_udisp="${2}"
@@ -3419,6 +3566,7 @@
_uver="${4}"
_ufbsdver="${5}"
_uarch="${6}"
+ _urepo="${7}"
appname="`echo ${_uprog} | tr '[:lower:]' '[:upper:]'`"
@@ -3435,15 +3583,31 @@
_uver=":${_uver}:"
fi
- # Search the update index for the specified PBI
- _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`"
- PBI_UPPATCHES="`echo $_upLine | cut -d ':' -f 8`"
- PBI_UPCSUM="`echo $_upLine | cut -d ':' -f 4`"
- PBI_UPMDATE="`echo $_upLine | cut -d ':' -f 5`"
+ for _repo in `ls ${PBI_DBINDEXDIR}`
+ do
+ if [ "$_urepo" = "AUTO" ] ; then
+ _pbiIndex="${PBI_DBINDEXDIR}/${_repo}"
+ else
+ _rMd5=`ls ${PBI_DBREPODIR}/${_urepo}.* | cut -d '.' -f 2`
+ _pbiIndex="${PBI_DBINDEXDIR}/${_rMd5}-index"
+ fi
+
+ # Search the update index for the specified PBI
+ _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`"
+ PBI_UPPATCHES="`echo $_upLine | cut -d ':' -f 8`"
+ PBI_UPCSUM="`echo $_upLine | cut -d ':' -f 4`"
+ PBI_UPMDATE="`echo $_upLine | cut -d ':' -f 5`"
+
+ if [ ! -z "${PBI_UPNVER}" ] ; then break; fi
+ if [ "${_urepo}" != "AUTO" ] ; then break; fi
+
+ done
+
# If no new version
if [ -z "$PBI_UPNVER" ] ; then return 1 ; fi
@@ -3488,7 +3652,7 @@
check_pbi_update "$_rtar" "nodisplay" \
"$_rtar" "$_rVer" \
- "`uname -r`" "$_rArch"
+ "`uname -r`" "$_rArch" "${PBI_ADDREPO_ID}"
if [ "$?" != "0" ] ; then
exit_err "Could not find \"$_rtar\" in $PBI_INDEXUPFILE"
fi
@@ -4458,6 +4622,7 @@
pbi_delete) pbi_delete_init "$@" ;;
pbi_icon) pbi_icon_init "$@" ;;
pbi_info) pbi_info_init "$@" ;;
+ pbi_listrepo) pbi_listrepo_init "$@" ;;
pbi_makeport) pbi_make_init "$@" ;;
pbi_makepatch) pbi_makepatch_init "$@" ;;
pbi_makerepo) pbi_makerepo_init "$@" ;;
More information about the Commits
mailing list