[PC-BSD Commits] r17363 - pcbsd/current/src-sh/pc-metapkgmanager

svn at pcbsd.org svn at pcbsd.org
Thu Jun 21 07:23:21 PDT 2012


Author: kris
Date: 2012-06-21 14:23:20 +0000 (Thu, 21 Jun 2012)
New Revision: 17363

Modified:
   pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager
Log:

Improve the pc-metapkgmanager. If the user doesn't provide a URL for packages
we will now try to use the default mirror path.



Modified: pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager
===================================================================
--- pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager	2012-06-21 13:38:56 UTC (rev 17362)
+++ pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager	2012-06-21 14:23:20 UTC (rev 17363)
@@ -59,11 +59,12 @@
 
 add_metapkgs() {
 	if [ -z "$1" ] ; then exit_err "No meta-pkg specified!" ; fi
-	if [ -z "$2" ] ; then exit_err "No pkg location specified!" ; fi
+	local pkgAddMirror="$2"
+	if [ -z "$pkgAddMirror" ] ; then pkgAddMirror=`use_default_mirror` ; fi
 	if [ ! -e "${MPDIR}/${1}/pkg-list" ] ; then exit_err "No such meta-pkg: $1" ; fi
 	_apkg=$1
 
-        MIRRORURL=`parse_url "$2"`
+        MIRRORURL=`parse_url "$pkgAddMirror"`
 
 	# Figure out the type of location we are installing from
 	echo $MIRRORURL | grep -e '^http://' -e '^ftp://' >/dev/null 2>/dev/null
@@ -490,6 +491,19 @@
    fi
 }
 
+use_default_mirror()
+{
+  # Get the default mirror URL
+  PCBSD_ETCCONF="/usr/local/etc/pcbsd.conf"
+  local mirrChk="`sed -n 's/PCBSD_MIRROR: //p' ${PCBSD_ETCCONF} 2>/dev/null`"
+  local pcVer="`pbreg get /PC-BSD/Version 2>/dev/null`"
+  local pcArch="`uname -m`"
+  if [ -z "${mirrChk}" -o -z "${pcVer}" -o -z "$pcArch" ] ; then 
+	exit_err "No mirror specified, and could not get default!"
+  fi
+  echo "${mirrChk}/${pcVer}/${pcArch}/netinstall/metapackages/${PKGSET}/packages/"
+}
+
 updatepkgs() {
   # Check for updates to the pkgs quietly
   checkup_pkgs "YES"
@@ -503,8 +517,11 @@
      exit 1
   fi
 
+  local pkgAddMirror="$2"
+  if [ -z "$pkgAddMirror" ] ; then pkgAddMirror=`use_default_mirror` ; fi
+
   # Make sure the URL is correctly formatted
-  MIRRORURL=`parse_url "$2"`
+  MIRRORURL=`parse_url "$pkgAddMirror"`
 
   if [ -n "$1" -a "$1" != "all" ] ; then
      for pkg in `echo $1 | sed 's|,| |g'`



More information about the Commits mailing list