[PC-BSD Commits] r6611 - in pcbsd-projects/pbi-manager: . man

svn at pcbsd.org svn at pcbsd.org
Fri Apr 30 13:18:25 PDT 2010


Author: kris
Date: 2010-04-30 13:18:25 -0700 (Fri, 30 Apr 2010)
New Revision: 6611

Modified:
   pcbsd-projects/pbi-manager/man/pbi_add.1
   pcbsd-projects/pbi-manager/pbi-manager
Log:

Update pbi-manager, do checks if the pbi is installed / target dir exists, and prompt to
force installation



Modified: pcbsd-projects/pbi-manager/man/pbi_add.1
===================================================================
--- pcbsd-projects/pbi-manager/man/pbi_add.1	2010-04-30 14:34:07 UTC (rev 6610)
+++ pcbsd-projects/pbi-manager/man/pbi_add.1	2010-04-30 20:18:25 UTC (rev 6611)
@@ -7,6 +7,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl e
+.Op Fl f
 .Op Fl g
 .Op Fl i
 .Op Fl l
@@ -38,6 +39,8 @@
 .It Fl e
 Extract only, do not install. Will extract the archive to ~/<pbidirname>
 unless the -p prefix option is used. 
+.It Fl e
+Force installation, overwriting an already installed copy of the application
 .It Fl g
 Extract image data from header commonly used for GUI installations
 .It Fl i

Modified: pcbsd-projects/pbi-manager/pbi-manager
===================================================================
--- pcbsd-projects/pbi-manager/pbi-manager	2010-04-30 14:34:07 UTC (rev 6610)
+++ pcbsd-projects/pbi-manager/pbi-manager	2010-04-30 20:18:25 UTC (rev 6611)
@@ -30,6 +30,7 @@
 
 Options:
   -e             -- Extract Only
+  -f             -- Force install, overwriting existing installation
   -g             -- Get and show path to icon / images for gui installer
   -i             -- Display information about this PBI
   -l             -- Display LICENSE text
@@ -159,6 +160,8 @@
                 case "$1" in
                 -e)     PBI_EXTRACTONLY="YES"
                         ;;
+                -f)     PBI_FORCEADD="YES"
+                        ;;
                 -g)     PBI_ADD_GUIDISPLAY="YES" 
                         ;;
                 -i)     PBI_ADD_INFODISPLAY="YES" 
@@ -373,6 +376,7 @@
 	PBI_DELETENAME=""
 	PBI_FAKEBIN_DIR=".sbin"
 	PBI_FILENAME=""
+	PBI_FORCEADD="NO"
 	PBI_HASHLIST=".pbi-hash-list"
 	PBI_INFONAME=""
 	PBI_INS_DESKSCRIPT="install-desktop-icons.sh"
@@ -529,7 +533,7 @@
 
 # Helper function to exit after a error, and do some cleanup
 exit_err() {
-	echo "`basename ${0}`: ${1}"
+	echo -e "`basename ${0}`: ${1}"
 	rm_tmpdir
 	rm_buildfiles
 	exit 1
@@ -616,9 +620,25 @@
 	fi
 
 	check_agree_lic
+	check_existing_pbi
 	do_pbi_add
 }
 
+# Check if this PBI exists and exit if so
+check_existing_pbi() {
+	if [ "${PBI_FORCEADD}" = "YES" ] ; then return 0; fi
+	get_dbdir
+	dir="${APPDBDIR}"
+	if [ -d "$dir" ]; then
+		exit_err "${PBI_PROGNAME} ${PBI_PROGVERSION} is already installed! Use -f to force installation."
+	fi
+	if [ -e "${PBI_PROGDIRPATH}" ]; then
+		exit_err "${PBI_PROGDIRPATH} already exists! Use -f to force installation."
+	fi
+
+
+}
+
 # Check if we have a license to agree to, and if we've provided the flag to do so
 check_agree_lic() {
         open_header_tmp
@@ -897,12 +917,18 @@
 
 }
 
+# Return the dbdir for this PBI
+get_dbdir() {
+	tmp="`echo ${PBI_PROGNAME} | tr -d ' ' | tr [A-Z] [a-z]`"
+        APPDBDIR="${PBI_DBDIR}/${tmp}-${PBI_PROGVERSION}"
+}
+
 # Register this app as installed
 pbi_add_register_app() {
 	if [ ! -d "$PBI_DBDIR" ] ; then mkdir -p ${PBI_DBDIR} ; fi
         open_header_tmp
-	tmp="`echo ${PBI_PROGNAME} | tr -d ' ' | tr [A-Z] [a-z]`"
-	dir="${PBI_DBDIR}/${tmp}-${PBI_PROGVERSION}"
+	get_dbdir
+	dir="${APPDBDIR}"
 	mkdir -p "${dir}"
 	
         tar cvf - -C "${PBI_HEADER_TMPDIR}" . 2>/dev/null | tar xvf - -C "$dir" 2>/dev/null
@@ -966,9 +992,12 @@
 # Make our PBI extraction dir
 mk_pbi_extract_dir() {
 	PBI_EXTRACTDIR="${PBI_PROGDIRPATH}"
-	if [ -e "${PBI_EXTRACTDIR}" ] ; then rm -rf "${PBI_EXTRACTDIR}" ; fi
-	mkdir -p "${PBI_EXTRACTDIR}" >/dev/null 2>/dev/null
-	if [ "$?" != "0" ] ; then exit_err "Failed to create directory: ${PBI_PROGDIRPATH}" ; fi
+	if [ ! -d "${PBI_EXTRACTDIR}" ] ; then
+		mkdir -p "${PBI_EXTRACTDIR}" >/dev/null 2>/dev/null
+		if [ "$?" != "0" ] ; then 
+			exit_err "Failed to create directory: ${PBI_PROGDIRPATH}"
+		fi
+	fi
 }
 
 pbi_find_archive_header() {



More information about the Commits mailing list