[PC-BSD Commits] r6873 - in pcbsd-projects/pbi-manager: . man
svn at pcbsd.org
svn at pcbsd.org
Mon Jun 7 11:29:48 PDT 2010
Author: kris
Date: 2010-06-07 11:29:48 -0700 (Mon, 07 Jun 2010)
New Revision: 6873
Modified:
pcbsd-projects/pbi-manager/man/pbi_add.1
pcbsd-projects/pbi-manager/pbi-manager
Log:
Added support for "pbi_add -r" which will automatically talk to the update
server, find the specified application, download and install it.
Modified: pcbsd-projects/pbi-manager/man/pbi_add.1
===================================================================
--- pcbsd-projects/pbi-manager/man/pbi_add.1 2010-06-07 16:05:17 UTC (rev 6872)
+++ pcbsd-projects/pbi-manager/man/pbi_add.1 2010-06-07 18:29:48 UTC (rev 6873)
@@ -12,6 +12,7 @@
.Op Fl i
.Op Fl l
.Op Fl p Ar prefix
+.Op Fl r
.Op Fl v
.Op Fl -checkscript
.Op Fl -licagree
@@ -51,6 +52,9 @@
.It Fl p Ar prefix
Specify the prefix to install the PBI into, otherwise the default the pbi
was created with will be used.
+.It Fl r
+Remote fetch the installation file from the update server. The system architecture
+and version will be automatically determined to fetch the correct file.
.It Fl v
Enable verbose output
.It Fl -checkscript
Modified: pcbsd-projects/pbi-manager/pbi-manager
===================================================================
--- pcbsd-projects/pbi-manager/pbi-manager 2010-06-07 16:05:17 UTC (rev 6872)
+++ pcbsd-projects/pbi-manager/pbi-manager 2010-06-07 18:29:48 UTC (rev 6873)
@@ -35,6 +35,7 @@
-i -- Display information about this PBI
-l -- Display LICENSE text
-p prefix -- Install to different prefix
+ -r -- Remote fetch installation file from update server
-v -- Enable verbose output
--checkscript -- Display any custom install / removal scripts
--licagree -- Agree to LICENSE terms for installation
@@ -205,6 +206,8 @@
if [ $# -eq 1 ]; then usage_add_pbi; fi
shift; PBI_ALTPREFIX_DIR="$1"
;;
+ -r) PBI_REMOTEFETCH="YES"
+ ;;
-v) PBI_VERBOSE="YES"
;;
--checkscript) PBI_CHECKSCRIPTS="YES" ;;
@@ -214,7 +217,7 @@
--no-checksig) PBI_SKIPSIGVERIFY="YES" ;;
*)
if [ $# -gt 1 ]; then usage_add_pbi; fi
- if [ ! -e "${1}" ] ; then
+ if [ ! -e "${1}" -a -z "$PBI_REMOTEFETCH" ] ; then
exit_err "PBI file not found: (${1})"
fi
PBI_FILENAME="$1"
@@ -225,6 +228,11 @@
if [ -z "${PBI_FILENAME}" ]; then usage_add_pbi ; fi
+ # If we are doing a remote fetch / install then do it now
+ if [ "$PBI_REMOTEFETCH" = "YES" ] ; then
+ pbi_add_fetch_remote
+ fi
+
# Load all the information about this PBI
load_info_from_header
@@ -516,6 +524,7 @@
PBI_INS_PATHSCRIPT="install-pathlinks.sh"
PBI_LICAGREE="NO"
PBI_LICENSEFILE="LICENSE"
+ PBI_REMOTEFETCH=""
PBI_RESOURCE_DIR="resources"
PBI_SS_ICON="__PBI_ICON__"
PBI_SS_ARCHIVE="__PBI_ARCHIVE__"
@@ -678,9 +687,18 @@
rm_tmpdir
rm_buildfiles
clean_wrkdirprefix
+ clean_remote_dl
exit 1
}
+# Check if we need to delete a remotely dl'd file
+clean_remote_dl() {
+ # If this was a remote fetch, remove dl'd file
+ if [ "$PBI_REMOTEFETCH" = "YES" -a ! -z "$PBI_FILENAME" ]; then
+ rm "$PBI_FILENAME" >/dev/null 2>/dev/null
+ fi
+}
+
# Set port make options from config
set_make_options() {
@@ -768,6 +786,7 @@
check_pbi_license_display
if [ "$PBI_ADD_GUIDISPLAY" = "YES" -o "$PBI_ADD_INFODISPLAY" = "YES" -o "$PBI_CHECKSCRIPTS" = "YES" -o "${PBI_ADD_LICDISPLAY}" = "YES" ]
then
+ clean_remote_dl
exit 0
fi
@@ -998,6 +1017,8 @@
pbi_add_update_hashdir
pbi_add_register_app
+
+ clean_remote_dl
}
# Run the install script if exists
@@ -1160,15 +1181,15 @@
# Check if we have valid signatures, and return "0" if success, "1" if failure
check_valid_sigs() {
_sf="${1}/pbi_archivesum ${1}/${MOD_PREINS} ${1}/${MOD_POSTINS} ${1}/${MOD_PREREM}"
- for i in $_sf
+ for _ts in $_sf
do
- for j in ${PBI_PUBKEYS}
+ for _pk in ${PBI_PUBKEYS}
do
good="false"
openssl dgst -sha1 \
- -verify ${j} \
- -signature ${i}.sha1 \
- ${i} >/dev/null 2>/dev/null
+ -verify ${_pk} \
+ -signature ${_ts}.sha1 \
+ ${_ts} >/dev/null 2>/dev/null
if [ "$?" = "0" ] ; then
good="true" ; break
fi
@@ -2183,13 +2204,19 @@
init_tmpdir
if [ "${PBI_UPCHECK}" = "YES" ] ; then
- check_pbi_update "${PBI_UPDATEAPP}" "display"
+ load_info_from_dir "${PBI_DBDIR}/${PBI_UPDATEAPP}"
+ check_pbi_update "$PBI_UPDATEAPP" "display" \
+ "$PBI_PROGNAME" "$PBI_PROGVERSION" \
+ "$PBI_FBSDVER" "$PBI_APPARCH"
else
# Loop and check all PBIs for updates
for i in `ls ${PBI_DBDIR}/ 2>/dev/null`
do
if [ -e "${PBI_DBDIR}/${i}/pbi_name" ] ; then
- check_pbi_update "$i" "display"
+ load_info_from_dir "${PBI_DBDIR}/${i}"
+ check_pbi_update "$i" "display" \
+ "$PBI_PROGNAME" "$PBI_PROGVERSION" \
+ "$PBI_FBSDVER" "$PBI_APPARCH"
fi
done
fi
@@ -2201,21 +2228,26 @@
# Check a specific PBI for updates
check_pbi_update() {
+ if [ -z "${PBI_UPDATEURL}" ] ; then return ; fi
# Init the tmpdir
init_tmpdir
+ # Set the vars
_upbi="${1}"
- load_info_from_dir "${PBI_DBDIR}/${_upbi}"
- if [ -z "${PBI_UPDATEURL}" ] ; then return ; fi
+ _udisp="${2}"
+ _uprog="${3}"
+ _uver="${4}"
+ _ufbsdver="${5}"
+ _uarch="${6}"
- appname="`echo ${PBI_PROGNAME} | tr '[:lower:]' '[:upper:]'`"
+ appname="`echo ${_uprog} | tr '[:lower:]' '[:upper:]'`"
curl -o ${PBI_TMPDIR}/.upcheck$$ ${PBI_CURLPROXY} \
-F "PBIName=${appname}" \
- -F "PBIVer=${PBI_PROGVERSION}" \
- -F "PCBSDVER=${PBI_FBSDVER}" \
+ -F "PBIVer=${_uprog}" \
+ -F "PCBSDVER=${_ufbsdver}" \
-F "PBIEd=2" \
- -F "OSARCH=${PBI_APPARCH}" \
+ -F "OSARCH=${_uarch}" \
"${PBI_UPDATEURL}" >/dev/null 2>/dev/null
# Uncomment to see details from update server
@@ -2244,7 +2276,7 @@
if [ -z "$PBI_UPNVER" ] ; then return 1 ; fi
# If this is a load only, don't display details
- if [ "$2" != "display" ] ; then return 0 ; fi
+ if [ "$_udisp" != "display" ] ; then return 0 ; fi
if [ "$PBI_UPNVER" != "$PBI_PROGVERSION" ] ; then
echo "${_upbi} - Available: ${PBI_UPNVER}"
@@ -2272,12 +2304,35 @@
fi
}
+# Attempt to download a PBI from the update server for "pbi_add -r"
+pbi_add_fetch_remote() {
+ # Set the target program we want to download
+ _rtar="$PBI_FILENAME"
+
+ check_pbi_update "$_rtar" "nodisplay" \
+ "$_rtar" "-0" \
+ "`uname -r`" "`uname -m`"
+ if [ "$?" != "0" ] ; then
+ exit_err "Cound not find \"$_rtar\""
+ fi
+
+ # We've gotten this far, now download the updated PBI
+ pbi_update_dl
+
+ # Now overwrite the PBI_FILENAME and let us proceed to regular install
+ PBI_FILENAME="$PBI_UPDLFILE"
+
+}
+
# Update the targed PBI
start_pbi_updateapp() {
_upact="${1}"
# Check for update to this app, and exit or return if not available
- check_pbi_update "${PBI_UPDATEAPP}" "nodisplay"
+ load_info_from_dir "${PBI_DBDIR}/${PBI_UPDATEAPP}"
+ check_pbi_update "$PBI_UPDATEAPP" "nodisplay" \
+ "$PBI_PROGNAME" "$PBI_PROGVERSION" \
+ "$PBI_FBSDVER" "$PBI_APPARCH"
if [ "$?" != "0" ] ; then
if [ "$_upact" = "single" ] ; then
exit_err "$PBI_UPDATEAPP - no update available!"
@@ -2285,7 +2340,6 @@
return 1
fi
fi
-
# We've gotten this far, now download the updated PBI
pbi_update_dl
More information about the Commits
mailing list