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

svn at pcbsd.org svn at pcbsd.org
Mon Feb 4 09:03:42 PST 2013


Author: kris
Date: 2013-02-04 17:03:42 +0000 (Mon, 04 Feb 2013)
New Revision: 21320

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

Large update to pc-metapkgmanager, now do all PKGNG stuff, use our actual
pcbsd-meta and trueos-meta packages for installing a collection of packages



Modified: pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager
===================================================================
--- pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager	2013-02-04 17:03:24 UTC (rev 21319)
+++ pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager	2013-02-04 17:03:42 UTC (rev 21320)
@@ -28,13 +28,11 @@
 . /usr/local/share/pcbsd/scripts/functions.sh
 
 # Define some defaults
-DBDIR="/var/db/pc-metapkgmanager/pkgsets"
+DBDIR="/usr/local/share/pcbsd/metaset"
 LOGFILE="/tmp/.pc-metapkgmanager.log"
 FTP_PASSIVE_MODE="YES" ; export FTP_PASSIVE_MODE
 PACKAGESUFFIX=".txz" ; export PACKAGESUFFIX
 ARCH="`uname -m`"
-PRUNEFILE="/usr/local/share/pcbsd/metaconf/prune-files"
-OVERLAYFILE="/usr/local/share/pcbsd/metaconf/overlay.txz"
 
 # Start by sourcing /etc/profile
 # This grabs any HTTP_ / FTP_ PROXY variables
@@ -52,20 +50,11 @@
 usage: `basename $0` [options]
    
 Options:
-  add pkg1,pkg2 <loc>	 -- Add the specified list of meta-packages
-			    <loc> should be a FTP / HTTP url where pkg add
-			    can fetch packages, or an absolute path to
-			    location of pkg files on disk.
-  checkup		 -- Check for updates to pkgs
+  add pkg1,pkg2		 -- Add the specified list of meta-packages
   del pkg1,pkg2	  	 -- Delete the specified list of meta-packages
   list     	         -- List the available meta-packages
   status <pkg>    	 -- List the status of the specified meta-packages
-  update <pkg,pkg2> <loc> -- Update system packages. Can use 'all' or <pkg1,pkg2> .
-			    <loc> should be a FTP / HTTP url where pkg add
-			    can fetch packages, or an absolute path to
-			    location of pkg files on disk.
   --pkgset <pkgset>	 -- Change default pkgset we are using
-  --chroot <dir>	 -- Operate on the directory specified using chroot
 
 EOF
         exit 1
@@ -73,164 +62,63 @@
 
 add_metapkgs() {
 	if [ -z "$1" ] ; then exit_err "No meta-pkg 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
+	if [ ! -e "${MPDIR}/${1}/ports-list" ] ; then exit_err "No such meta-pkg: $1" ; fi
+        local pkgName="`cat ${MPDIR}/$1/ports-list | cut -d ':' -f 1`"
+	if [ -z "$pkgName" ] ; then exit_err "No FreeBSD package specified for meta-pkg: ${1}" ; fi
+
 	_apkg=$1
+	echo "Installing Meta-Package: $_apkg ($pkgName)"
 
-        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
-	if [ "$?" = "0" ] ; then
-		loc="NET"
-	else
-		if [ ! -d "${MIRRORURL}" ] ; then exit_err "The pkg location $MIRRORURL does not exist!" ; fi
-		loc="PATH"
-	fi
-
-	echo "Package source: $loc"
-        echo "Preparing to add: $_apkg... "
-        echo "Checking for updates to old packages..."
-        updatepkgs "all" "SILENT"
-
-	echo "Installing Meta-Package: $_apkg"
-
-	# Start by building the list of packages to download
-	build_pkg_list "$_apkg" "YES"
-
-	echo "Pending package changes: $PKGCOUNT"
-
 	# If a pre-install script, run it now
 	if [ -e "${MPDIR}/${_apkg}/pre-install.sh" ] ; then
-	  if [ -z "$_chroot" ] ; then
-	    sh ${MPDIR}/${_apkg}/pre-install.sh >/dev/null 2>/dev/null
-	  else
-	    cp ${MPDIR}/${_apkg}/pre-install.sh ${_chroot}/.pre-install.sh.$$ >/dev/null 2>/dev/null
-	    chroot "$_chroot" sh /.pre-install.sh.$$ >/dev/null 2>/dev/null
-	    rm ${_chroot}/.pre-install.sh.$$
-          fi
+	  sh ${MPDIR}/${_apkg}/pre-install.sh >/dev/null 2>/dev/null
 	fi
 
-        # Download / Copy each package now
-        for pkg in $PKGLIST
-        do
-		# Start installing / downloading the packages now
-		if [ "$loc" = "NET" ] ; then
-		   echo "Downloading package: $pkg"
-		   echo "Downloading package: $pkg" >>${LOGFILE}
+        # Running from a GUI?
+  	if [ -n "$PCFETCHGUI" ] ; then
+    	  # Setup EVENT_PIPE
+    	  EVENT_PIPE="/tmp/pkgpipe.$$"
+    	  export EVENT_PIPE
+    	  rc_halt "mkfifo $EVENT_PIPE"
+    	  echo "EVENT_PIPE: $EVENT_PIPE"
 
-	           # Create the TMPDIR
-		   if [ ! -d "${_chroot}/$TMPDIR" ]; then mkdir -p "${_chroot}/$TMPDIR"; fi
+    	  # Wait for QT to open the pipe file
+    	  sleep 5
 
-		   # Download all the packages first
-		   get_file "${MIRRORURL}/${pkg}.txz" "${_chroot}/${TMPDIR}/${pkg}.txz" 3
-		   if [ $? -ne 0 ] ; then
-		      exit_err "Failed downloading: ${MIRRORURL}/${pkg}.txz"
-		   fi
+    	  # Tickle pkg update first
+    	  pkg update
+  	fi
 
-		else
-		   # Check if the package is already installed
-		   if [ -z "${_chroot}" ] ; then
-		     if pkg info -e ${pkg}; then
-		       echo "Skipping installed package: $pkg"
-		       echo "Skipping installed package: $pkg" >>${LOGFILE}
-		       continue
-		     fi
-		   else
-		     if pkg -C ${_chroot} info -e ${pkg}; then
-		       echo "Skipping installed package: $pkg"
-		       echo "Skipping installed package: $pkg" >>${LOGFILE}
-		       continue
-		     fi
-		   fi
+        # Time to run pkgng and let it install packages!
+	pkg install -yf "$pkgName"
 
-		   echo "Installing package: $pkg"
-		   echo "Installing package: $pkg" >>${LOGFILE}
-		   if [ -z "$_chroot" ] ; then
-		      cd "${MIRRORURL}"
-		      pkg add "${pkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
-		   else
-		      # Do some nullfs mounting to get our dist dir into the chroot
-		      mkdir ${_chroot}/.mnt.$$
-		      mount_nullfs "$MIRRORURL" "${_chroot}/.mnt.$$"
-		      ${_chrootcmd} pkg add "/.mnt.$$/${pkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
-		   fi
-		fi
-        done
+	# Cleanup EVENT_PIPE
+  	if [ -n "$PCFETCHGUI" ] ; then
+    	  rm $EVENT_PIPE
+  	fi
 
-	# If this is a network install, then packages are now downloaded, lets install
-	if [ "$loc" = "NET" ] ; then
-           for pkg in $PKGLIST
-           do
-	      # Check if the package is already installed
-	      if [ -z "${_chroot}" ] ; then
-	        if pkg info -e ${pkg}; then
-	           echo "Skipping installed package: $pkg"
-	           echo "Skipping installed package: $pkg" >>${LOGFILE}
-	           continue
-	        fi
-              else
-	        if pkg -C ${_chroot} info -e ${pkg}; then
-	           echo "Skipping installed package: $pkg"
-	           echo "Skipping installed package: $pkg" >>${LOGFILE}
-	           continue
-	        fi
-	      fi
-	      echo "Installing package: $pkg"
-	      echo "Installing package: $pkg" >>${LOGFILE}
-	      if [ -z "${_chroot}" ] ; then
-		cd ${TMPDIR}
-	        pkg add "${pkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
-              else
-	        echo "#!/bin/sh
-cd ${TMPDIR}
-pkg add ${pkg}.txz" > ${_chroot}/.insPkg.$$.sh
-	        chmod 755 ${_chroot}/.insPkg.$$.sh
-	        ${_chrootcmd} /.insPkg.$$.sh >>${LOGFILE} 2>>${LOGFILE}
-	        rm "${_chroot}/.insPkg.$$.sh"
-	      fi
-	      rm "${_chroot}/${TMPDIR}/${pkg}.txz"
-           done
-	fi
-
-	# Umount any nullfs stuff in chroot
-        if [ -n "${_chroot}" -a "$loc" = "PATH" ] ; then
-	   sleep 1
-	   umount -f ${_chroot}/.mnt.$$
-	   rmdir ${_chroot}/.mnt.$$
-	fi
-
 	# Make sure the program appears fully installed now, if not set error
 	stat_metapkg ${_apkg}
 	if [ "$?" != "0" ] ; then _pkgStatus=1 ; fi
 
 	# Apply our PC-BSD specific xdg menu entry files
-	if [ -z "$_chroot" ] ; then
+	if [ -e "/usr/local/bin/pc-xdgutil" ] ; then
 	  /usr/local/bin/pc-xdgutil updatemenu >>${LOGFILE} 2>>${LOGFILE}
-	elif [ -e "${_chroot}/usr/local/bin/pc-xdgutil" ] ; then
-	  chroot ${_chroot} /usr/local/bin/pc-xdgutil updatemenu >>${LOGFILE} 2>>${LOGFILE}
 	fi
 
 	# Hack to ensure that we share cursors / icons between linux / FBSD apps
-	if [ ! -h "${_chroot}/compat/linux/usr/share/icons" ] ; then
-	   rm -rf ${_chroot}/compat/linux/usr/share/icons 2>/dev/null
-	   ln -fs /usr/local/lib/X11/icons ${_chroot}/compat/linux/usr/share/icons 2>/dev/null
+	if [ ! -h "/compat/linux/usr/share/icons" ] ; then
+	   rm -rf /compat/linux/usr/share/icons 2>/dev/null
+	   ln -fs /usr/local/lib/X11/icons /compat/linux/usr/share/icons 2>/dev/null
 	fi
-	if [ ! -h "${_chroot}/compat/linux/usr/share/fonts" ] ; then
-	   rm -rf ${_chroot}/compat/linux/usr/share/fonts 2>/dev/null 
-	   ln -fs /usr/local/lib/X11/fonts ${_chroot}/compat/linux/usr/share/fonts 2>/dev/null
+	if [ ! -h "/compat/linux/usr/share/fonts" ] ; then
+	   rm -rf /compat/linux/usr/share/fonts 2>/dev/null 
+	   ln -fs /usr/local/lib/X11/fonts /compat/linux/usr/share/fonts 2>/dev/null
 	fi
 
 	# If a post-install script, run it now
 	if [ -e "${MPDIR}/${_apkg}/post-install.sh" ] ; then
-	  if [ -z "$_chroot" ] ; then
-	    sh ${MPDIR}/${_apkg}/post-install.sh >/dev/null 2>/dev/null
-	  else
-	    cp ${MPDIR}/${_apkg}/post-install.sh ${_chroot}/.post-install.sh.$$ >/dev/null 2>/dev/null
-	    chroot "$_chroot" sh /.post-install.sh.$$ >/dev/null 2>/dev/null
-	    rm ${_chroot}/.post-install.sh.$$
-          fi
+	  sh ${MPDIR}/${_apkg}/post-install.sh >/dev/null 2>/dev/null
 	fi
 
 	# Prune any port files we dont want
@@ -244,140 +132,55 @@
 # Delete specified meta-pkg, and packages which it installed that are not used elsewhere
 del_metapkgs() {
 	if [ -z "$1" ] ; then exit_err "No meta-pkg specified!" ; fi
-	if [ ! -e "${MPDIR}/${1}/pkg-list" ] ; then exit_err "No such meta-pkg: $1" ; fi
+	if [ ! -e "${MPDIR}/${1}/ports-list" ] ; then exit_err "No such meta-pkg: $1" ; fi
+        local rmPkg="`cat ${MPDIR}/$1/ports-list | cut -d ':' -f 1`"
+	if [ -z "$rmPkg" ] ; then exit_err "No FreeBSD package specified for meta-pkg: ${1}" ; fi
 	_dpkg=$1
 	kPkgs=""
 
 	echo "Removing Meta-Package: $_dpkg"
 
-	# Build a list of installed meta-pkgs
-	for i in `find ${MPDIR}/* -type d`
-	do
-		if [ ! -e "${i}/pkg-list" ] ; then continue ; fi
-		if [ "${i}" = "${MPDIR}/$_dpkg" ] ; then continue ; fi
-		found=0
-		_iList=""
-		while read pkg
-		do
-			if [ -z "$pkg" ] ; then continue ; fi
-			${_chrootcmd} pkg info -e $pkg >/dev/null 2>/dev/null
-			if [ "$?" != "0" ] ; then continue; fi
-			_iList="${_iList}${pkg}:"
-		done < ${i}/pkg-list
-		if [ "$found" = "0" ] ; then kPkgs="${kPkgs}${_iList}" ; fi
-	done
-
 	# kPkgs is our list of packages which are required by other installed meta-pkgs
 	export kPkgs
 
 	# If a pre-remove script, run it now
 	if [ -e "${MPDIR}/${_dpkg}/pre-remove.sh" ] ; then
-	  if [ -z "$_chroot" ] ; then
-	    sh ${MPDIR}/${_dpkg}/pre-remove.sh >/dev/null 2>/dev/null
-	  else
-	    cp ${MPDIR}/${_dpkg}/pre-remove.sh ${_chroot}/.pr.sh.$$ >/dev/null 2>/dev/null
-	    chroot "$_chroot" sh /.pr.sh.$$ >/dev/null 2>/dev/null
-	    rm ${_chroot}/.pr.sh.$$
-          fi
+	  sh ${MPDIR}/${_dpkg}/pre-remove.sh >/dev/null 2>/dev/null
 	fi
 
-	build_pkg_list "$_dpkg" "NO"
-	echo "Pending package changes: $PKGCOUNT"
+	# Make sure this pkg is installed
+	pkg info -e $rmPkg >/dev/null 2>/dev/null
+	if [ $? -ne 0 ] ; then 
+		echo "Already uninstalled: ${rmPkg}" 
+		echo "Already uninstalled: ${rmPkg}" >>${LOGFILE}
+		return
+	fi
 
-	# Lets remove the pkgs from this meta-pkg
-	for rmPkg in $PKGLIST
-	do
-		# Make sure this pkg is installed
-		${_chrootcmd} pkg info -e $rmPkg >/dev/null 2>/dev/null
-		if [ "$?" != "0" ] ; then 
-			echo "Already uninstalled: ${rmPkg}" 
-			echo "Already uninstalled: ${rmPkg}" >>${LOGFILE}
-			continue
-		fi
+	# confirm this package isn't required by any others
+	nbrequired=`pkg query "%?r" ${rmPkg}`
+	if [ $nbrequired -ne 0 ] ; then 
+		# Still in use, we will re-scan it at the end
+		echo "The package: ${rmPkg} is required by other packages: $nbrequired" 
+		echo "The package: ${rmPkg} is required by other packages: $nbrequired" >>${LOGFILE}
+		return
+	fi
 
-		# Check that this isnt an apart of another meta-pkg installed list
-		echo "$kPkgs" | grep -q "${rmPkg}:"
-		if [ "$?" = "0" ] ; then 
-			echo "Skipping Meta-Required: ${rmPkg}" 
-			echo "Skipping Meta-Required: ${rmPkg}" >>${LOGFILE}
-			continue
-		fi
+	# Now we use pkgng and remove it
+	echo "Removing: ${rmPkg}"
+	echo "Removing: ${rmPkg}" >>${LOGFILE}
+	pkg delete -y ${rmPkg} >>${LOGFILE} 2>>${LOGFILE}
 
-		# confirm this package isn't required by any others
-		nbrequired=`${_chrootcmd} pkg query "%?r" ${rmPkg}`
-		if [ "$nbrequired" != "0" ] ; then 
-			# Still in use, we will re-scan it at the end
-			skippedPkgs="${rmPkg} ${skippedPkgs}"
-			continue
-		fi
-
-		echo "Removing: ${rmPkg}"
-		echo "Removing: ${rmPkg}" >>${LOGFILE}
-		${_chrootcmd} pkg delete -yf ${rmPkg} >>${LOGFILE} 2>>${LOGFILE}
-
-	done
-
-	# Check if we have any packages skipped that need removing
-	recheck_skipped "$skippedPkgs"
-
 	# If the program is still fully installed, set status to error
 	stat_metapkg ${_dpkg}
-	if [ "$?" = "0" ] ; then _pkgStatus=1 ; fi
+	if [ $? -eq 0 ] ; then _pkgStatus=1 ; fi
 
 	# If a post-remove script, run it now
 	if [ -e "${MPDIR}/${_dpkg}/post-remove.sh" ] ; then
-	  if [ -z "$_chroot" ] ; then
-	    sh ${MPDIR}/${_dpkg}/post-remove.sh >/dev/null 2>/dev/null
-	  else
-	    cp ${MPDIR}/${_dpkg}/post-remove.sh ${_chroot}/.pr.sh.$$ >/dev/null 2>/dev/null
-	    chroot "$_chroot" sh /.pr.sh.$$ >/dev/null 2>/dev/null
-	    rm ${_chroot}/.pr.sh.$$
-          fi
+	  sh ${MPDIR}/${_dpkg}/post-remove.sh >/dev/null 2>/dev/null
 	fi
 
 }
 
-# Loop through skipped pkgs, until we are sure there are no more ones to remove
-recheck_skipped()
-{
-   local found=0
-   local newSkipped=""
-   for skPkg in $1
-   do
-      nbrequired=`${_chrootcmd} pkg query "%?r" ${skPkg}`
-      if [ "$?" = "0" ] ; then 
-        newSkipped="$skPkg $newSkipped"	
-        continue
-      fi
-      found=1
-      echo "Removing: ${skPkg}"
-      echo "Removing: ${skPkg}" >>${LOGFILE}
-      ${_chrootcmd} pkg delete -yf ${skPkg} >>${LOGFILE} 2>>${LOGFILE}
-   done
-
-   if [ $found -eq 1 ] ; then
-      recheck_skipped "$newSkipped"
-   else
-     # List the packages which still have things depending upon them
-     for skPkg in $newSkipped
-     do
-	echo "Skipping Required: ${skPkg}" 
-	echo "Skipping Required: ${skPkg}" >>${LOGFILE}
-     done
-   fi
-}
-
-# Check if the specified pkg doesn't have anything which requires it, and remove it if so
-check_remove_pkg() {
-        nbrequired=`${_chrootcmd} pkg query "%?r" ${1}`
-        if [ "$nbrequired" == "0" ] ; then
-		echo "Removing non-used pkg: $1" >>${LOGFILE} 2>>${LOGFILE} 
-                ${_chrootcmd} pkg delete -yf ${1} >>${LOGFILE} 2>>${LOGFILE}
-                return 0
-        fi
-        return 1
-}
-
 # Function to list available metapkgs
 list_metapkgs() {
 	if [ ! -d "${MPDIR}" ] ; then exit_err "No available meta-pkg dir" ; fi
@@ -407,9 +210,9 @@
 				echo "Desktop: NO"
 			fi
 			echo " "
-			if [ -e "${i}/pkg-list" ] ; then
+			if [ -e "${i}/ports-list" ] ; then
 				echo "Required Packages:"
-				cat ${i}/pkg-list
+				cat ${i}/ports-list | cut -d ':' -f 1
 			else
 				echo "Category Entry"
 			fi
@@ -422,28 +225,23 @@
 # Check on a meta-pkg, see if its installed, partially installed, or not. 
 stat_metapkg() {
 	if [ -z "$1" ] ; then exit_err "No meta-pkg specified!" ; fi
-	if [ ! -e "${MPDIR}/${1}/pkg-list" ] ; then exit_err "No such meta-pkg: $1" ; fi
+	if [ ! -e "${MPDIR}/${1}/ports-list" ] ; then exit_err "No such meta-pkg: $1" ; fi
+        local myPkg="`cat ${MPDIR}/$1/ports-list | cut -d ':' -f 1`"
+	if [ -z "$myPkg" ] ; then exit_err "No FreeBSD package specified for meta-pkg: ${1}" ; fi
 	_mpkg=$1
 
 	found=1
 	nfound=0
 
 	# Parse pkg db to see if pkgs are installed
-	if [ -z "$_chroot" ] ; then
-	  list=$(pkg query "%n")
-	else
-	  list=$(pkg -C ${_chroot} query "%n")
-        fi
-	while read pkg
-	do
-		if [ -z "$pkg" ] ; then continue ; fi
-		pName=${pkg%-*}
-		case $'\n'$list$'\n' in
-			*$'\n'"$pName"$'\n'*) found=0 ;;
-			*) nfound=1 ;;
-		esac
-	done < ${MPDIR}/${_mpkg}/pkg-list
+	list=$(pkg query "%n")
 
+	pName=${myPkg%-*}
+	case $'\n'$list$'\n' in
+		*$'\n'"$pName"$'\n'*) found=0 ;;
+		*) nfound=1 ;;
+ 	esac
+
 	if [ "$found" = "0" -a "$nfound" = "0" ] ; then
 		echo "The meta-pkg $_mpkg is installed"
 		return 0
@@ -509,322 +307,7 @@
 	chmod 666 ${LOGFILE}
 }
 
-checkup_pkgs() {
-
-  _nodsp="$1"
-
-  if [ ! -e "${MPDIR}/master-pkg-index" ] ; then
-    return
-  fi
-
-  # Checkout the installed pkgs and compare to master list
-  local fPkgUp=0
-  if [ -z "${_chroot}" ] ; then
-    pkg query "%n-%v" > /tmp/.pkgList.$$
-  else
-    pkg -C ${_chroot} query "%n-%v" > /tmp/.pkgList.$$
-  fi
-  cat ${MPDIR}/master-pkg-index | cut -d ":" -f 1-2 | sed 's|:|-|g' > /tmp/.pkgList2.$$
-  diff /tmp/.pkgList.$$ /tmp/.pkgList2.$$ | grep '^<' | sed 's|< ||g' > /tmp/.dList.$$
-  rm /tmp/.pkgList.$$
-  rm /tmp/.pkgList2.$$
-  while read pLine
-  do
-    pName=`echo $pLine | rev | cut -d "-" -f 2-25 | rev`
-    pVer=`echo $pLine | rev | cut -d "-" -f 1 | rev`
-		
-    # Make sure this version isn't in our index
-    grep "^${pName}:${pVer}" ${MPDIR}/master-pkg-index >/dev/null 2>/dev/null
-    if [ $? -eq 0 ] ; then continue ; fi
-
-    # Make sure the old pkg is something we've updated, not the user manually
-    grep "^${pName}:${pVer}" ${MPDIR}/master-pkg-index-old >/dev/null 2>/dev/null
-    if [ $? -ne 0 ] ; then continue ; fi
-
-    # Get the info from master-pkg-index
-    iLine=`grep "^${pName}:" ${MPDIR}/master-pkg-index`
-    if [ -z "$iLine" ] ; then continue ; fi
-    iVer="`echo $iLine | cut -d ':' -f 2`"
-    iSiz="`echo $iLine | cut -d ':' -f 3`"
-    iFile="`echo $iLine | cut -d ':' -f 4`"
-
-    # Is this version different?
-    if [ "$pVer" = "$iVer" ] ; then continue ; fi
-
-    if [ $fPkgUp -eq 0 -a "$_nodsp" != "YES" ] ; then 
-       echo "The following package updates are available:"
-       echo ""
-       fPkgUp=1
-    fi
-
-    if [ "$_nodsp" != "YES" ] ; then
-      # Display the pkg update data
-      echo "PKGUPDATE: ${pName} ${pVer} -> ${iVer}"
-      echo "PKGUPDATEKB: ${iSiz}"
-      echo "PKGUPDATEFILE: ${iFile}"
-      echo "To update this pkg run \"${0} ${_chroottag} update ${pName} <mirror url>\""
-      echo ""
-    fi
-
-    # Save the variable of available pkg updates
-    PKGUPDATES="${PKGUPDATES}${pName}:"
-  done < /tmp/.dList.$$
-  rm /tmp/.dList.$$
-
-  # Display command to use for pkg-updating
-  if [ $fPkgUp -eq 1 -a "$_nodsp" != "YES" ] ; then 
-     echo " "
-     echo "To update all run \"${0} ${_chroottag} update all <mirror url>\""
-     echo " "
-  elif [ "$_nodsp" != "YES" ] ; then
-     echo "All packages are up to date!"
-  fi
-  return 0
-}
-
-parse_url()
-{
-   # Make sure URL ends with '/'
-   if [ "`echo $1 | rev | cut -c 1`" != "/" ] ; then
-      echo "${1}/"
-   else
-      echo "$1"
-   fi
-}
-
-use_default_mirror()
-{
-  # Get the default mirror URL
-  get_mirror >/dev/null 2>/dev/null
-  local mirrChk="$VAL"
-  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"
-  if [ -z "$PKGUPDATES" -a "$2" = "SILENT" ] ; then return; fi
-  if [ -z "$PKGUPDATES" ] ; then
-     echo "No packages need updating!"
-     exit 1
-  fi
-
-  if [ -z "$1" ] ; then
-     echo "No packages specified, use 'all' or pkg1,pkg2,pkg3"
-     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 "$pkgAddMirror"`
-
-  if [ -n "$1" -a "$1" != "all" ] ; then
-     for pkg in `echo $1 | sed 's|,| |g'`
-     do
-       echo "$PKGUPDATES" | grep -q "${pkg}:"
-       if [ $? -ne 0 ] ; then
-         echo "No update available for ${pkg}!"
-         exit 1
-       fi
-     done
-  fi
-
-  # Figure out the type of location we are installing from
-  echo $MIRRORURL | grep -e '^http://' -e '^ftp://' >/dev/null 2>/dev/null
-  if [ "$?" = "0" ] ; then
-     loc="NET"
-     PACKAGESITE="$MIRRORURL" ; export PACKAGESITE
-  else
-     if [ ! -d "${MIRRORURL}" ] ; then exit_err "The pkg location $MIRRORURL does not exist!" ; fi
-     loc="PATH"
-     cd "${MIRRORURL}"
-  fi
-
-  if [ "$loc" = "PATH" -a -n "$_chroot" ] ; then
-     # Do some nullfs mounting to get our dist dir into the chroot
-     mkdir ${_chroot}/.mnt.$$
-     mount_nullfs "$MIRRORURL" "${_chroot}/.mnt.$$"
-  fi
-
-  # Do the updates now
-  if [ "$1" = "all" ] ; then
-    # Updating all
-    get_num_pkgs "`echo $PKGUPDATES | sed 's|:| |g'`"
-    echo "Pending Meta-Package changes: $VAL"
-    echo "Pending Meta-Package changes: $VAL" >>${LOGFILE}
-    for pkg in `echo $PKGUPDATES | sed 's|:| |g'`
-    do
-      do_update "$pkg"
-    done
-  else
-    # Updating a list of pkgs
-    get_num_pkgs "$1"
-    echo "Pending Meta-Package changes: $VAL"
-    echo "Pending Meta-Package changes: $VAL" >>${LOGFILE}
-    for pkg in `echo $1 | sed 's|,| |g'`
-    do
-      do_update "$pkg"
-    done
-  fi
-
-  # Unmount any distdir
-  if [ "$loc" = "PATH" -a -n "$_chroot" ] ; then
-     umount -f ${_chroot}/.mnt.$$
-     rmdir ${_chroot}/.mnt.$$
-  fi
-
-  echo "INSTALLFINISHED: MetaPkg Updates" >${TRIGGERFILE}
-  echo "Meta-Package changes finished!"
-
-}
-
-do_update() {
-  _pU="$1"
-  # get the old pkg-name
-  oPkg=$(get_pkg_from_name $_pU sys)
-  nPkg=$(get_pkg_from_name $_pU ${MPDIR}/master-pkg-index)
-  echo "Updating package: $oPkg -> $nPkg"
-  echo "Updating package: $oPkg -> $nPkg" >> ${LOGFILE}
-
-  # Make sure the new package is fetchable
-  # Create the TMPDIR
-  if [ ! -d "${_chroot}/$TMPDIR" ]; then mkdir -p "${_chroot}/$TMPDIR"; fi
-
-  # Download all the packages first
-  get_file "${MIRRORURL}/${nPkg}.txz" "${_chroot}/${TMPDIR}/${pkg}.txz" 3
-  if [ $? -ne 0 ] ; then
-      exit_err "Failed downloading: ${MIRRORURL}/${nPkg}.txz"
-  fi
-
-  # Remove the old pkg
-  if [ -z "${_chroot}" ] ; then
-     pkg delete -yf "$oPkg" >>${LOGFILE} 2>>${LOGFILE}
-  else
-     pkg -C ${_chroot} delete -yf "$oPkg" >>${LOGFILE} 2>>${LOGFILE}
-  fi
-
-  # Start installing the packages now
-  if [ "$loc" = "NET" ] ; then
-     pkg -C ${_chroot} add "${TMPDIR}/${nPkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
-  else
-     if [ -z "$_chroot" ] ; then
-        pkg add "${nPkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
-     else
-        pkg -C ${_chroot} add -f "/.mnt.$$/${nPkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
-     fi
-  fi
-
-}
-
-get_pkg_from_name() {
-  if [ "$2" = "sys" ] ; then
-    if [ -z "${_chroot}" ] ; then
-      pkg info -qa  >/tmp/.plist.$$ 2>/dev/null
-    else
-      pkg -C ${_chroot} info -qa  >/tmp/.plist.$$ 2>/dev/null
-    fi
-  else
-    cat $2 | cut -d ':' -f 1-2 | sed 's|:|-|g' > /tmp/.plist.$$ 2>/dev/null 
-  fi
-
-  while read line
-  do
-    pName=`echo $line | rev | cut -d "-" -f 2-25 | rev`
-    if [ "$pName" != "$1" ] ; then continue; fi
-    pVer=`echo $line | rev | cut -d "-" -f 1 | rev`
-    echo "${pName}-${pVer}"
-    break
-  done < /tmp/.plist.$$
-  rm /tmp/.plist.$$ 2>/dev/null
-}
-
-get_pkg_deps()
-{
-  local tPkg="$1"
-  if [ ! -e "${DEPDIR}/${tPkg}.deps" ] ; then
-     echo "Warning: No dependancy file for ${tPkg}!"
-     return
-  fi
-  while read pkgDeps
-  do
-     echo "$pkgDeps" | grep -q "Dependency: "
-     if [ $? -ne 0 ] ; then continue ; fi
-     pkgDeps=`echo $pkgDeps | cut -d ' ' -f 2`
-
-     echo "${DEPS}" | grep -q " $pkgDeps"
-     if [ $? -eq 0 ] ; then continue ; fi
-
-     # Save this as a dependency
-     #echo "Added DEP: $pkgDeps"
-     DEPS="${DEPS} $pkgDeps"
-
-     # Drill down
-     get_pkg_deps "$pkgDeps"
-  
-  done < ${DEPDIR}/${tPkg}.deps
-  
-}
-
-build_pkg_list() 
-{
-  local _mpkg="$1"
-  local _strip="$2"
-  PKGLIST=""
-  DEPS=""
-  echo "Getting package list..."
-
-  # If we can get the full-pkglist, use it instead of figuring out deps manually
-  if [ -e "${MPDIR}/${_mpkg}/full-pkg-list" ] ; then
-     PKGCOUNT=0
-     while read line
-     do
-	if [ -z "$line" ] ; then continue ; fi
-        if [ -d "${_chroot}/var/db/pkg/$line" -a "$_strip" = "YES" ] ; then continue ; fi
-        PKGLIST="${PKGLIST} ${line}"
-        PKGCOUNT=`expr ${PKGCOUNT} + 1`
-     done < ${MPDIR}/${_mpkg}/full-pkg-list
-     return
-  fi
-
-  while read mPkg
-  do
-    if [ -z "$mPkg" ] ; then continue ; fi
-    if [ ! -e "${DEPDIR}/${mPkg}.deps" ] ; then
-       echo "Warning: No dependancy file for ${mPkg}!"
-       echo "Warning: No dependancy file for ${mPkg}!" >>${LOGFILE}
-       continue
-    fi
-    get_pkg_deps "$mPkg"
-    DEPS="$mPkg $DEPS"
-  done < ${MPDIR}/${_mpkg}/pkg-list
-
-  for pkg in $DEPS
-  do
-    echo "$pkg" >> /tmp/.pc-meta-sort.$$
-  done
-  sort /tmp/.pc-meta-sort.$$ | uniq > /tmp/.pc-meta-sort2.$$
-  mv /tmp/.pc-meta-sort2.$$ /tmp/.pc-meta-sort.$$
-
-  PKGCOUNT=0
-  while read line
-  do
-     if [ -d "${_chroot}/var/db/pkg/$line" -a "$_strip" = "YES" ] ; then continue ; fi
-     PKGLIST="${PKGLIST} ${line}"
-     PKGCOUNT=`expr ${PKGCOUNT} + 1`
-  done < /tmp/.pc-meta-sort.$$
-  rm /tmp/.pc-meta-sort.$$
-}
-
 # Unset some vars
-_chroot=""
-_chrootcmd=""
 _pkgflags=""
 PKGUPDATES=""
 
@@ -837,7 +320,6 @@
 _pkgChk="`sed -n 's/PCBSD_METAPKGSET: //p' ${PCBSD_ETCCONF} 2>/dev/null`"
 if [ -n "${_pkgChk}" ] ; then PKGSET="$_pkgChk" ; fi
 MPDIR="${DBDIR}/${PKGSET}"
-DEPDIR="${MPDIR}/pkg-deps"
 TMPDIR="/usr/local/tmp"
 
 if [ $# -eq 0 ]; then display_usage; fi
@@ -849,8 +331,6 @@
        add) parse_metapkgs "$2" "add" "$3" ; exit 0 ;;
        del) parse_metapkgs "$2" "del" ; exit 0 ;;
     status) stat_metapkg "$2" ; exit 0 ;;
-   checkup) checkup_pkgs ; exit 0 ;;
-    update) updatepkgs "${2}" "${3}" ; exit 0 ;;
   --chroot) if [ -z "$2" ] ; then display_usage ; fi  
 	    _chroot="$2" 
             if [ ! -e "${_chroot}/bin/sh" ] ; then
@@ -866,7 +346,6 @@
 	    _pkgChk="`sed -n 's/PCBSD_METAPKGSET: //p' ${PCBSD_ETCCONF} 2>/dev/null`"
 	    if [ -n "${_pkgChk}" ] ; then PKGSET="$_pkgChk" ; fi
             MPDIR="${DBDIR}/${PKGSET}"
-	    DEPDIR="${MPDIR}/pkg-deps"
 	    shift
             ;;
   --pkgset) if [ -z "$2" ] ; then display_usage ; fi  
@@ -876,7 +355,6 @@
               exit 1
             fi
             MPDIR="${DBDIR}/${PKGSET}"
-	    DEPDIR="${MPDIR}/pkg-deps"
             shift ;;
          *) if [ -z "$1" ] ; then
 	      shift



More information about the Commits mailing list