[PC-BSD Commits] r19542 - in pcbsd/current: build-files/metapkgsets src-sh/pc-metapkgmanager

svn at pcbsd.org svn at pcbsd.org
Wed Sep 26 10:31:41 PDT 2012


Author: kris
Date: 2012-09-26 17:31:41 +0000 (Wed, 26 Sep 2012)
New Revision: 19542

Added:
   pcbsd/current/src-sh/pc-metapkgmanager/port-overlay/
   pcbsd/current/src-sh/pc-metapkgmanager/prune-files
Removed:
   pcbsd/current/build-files/metapkgsets/chroot-script.sh
   pcbsd/current/build-files/metapkgsets/port-overlay/
Modified:
   pcbsd/current/src-sh/pc-metapkgmanager/Makefile
   pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager
Log:

Convert pc-metapkgmanager to using "pkgng" 

Move meta-pkg port-overlay content to pc-metapkgmanager. This will
allow us to ship pristine Packages from our full repository, then
pc-metapkgmanager will apply our fixes to them. 



Modified: pcbsd/current/src-sh/pc-metapkgmanager/Makefile
===================================================================
--- pcbsd/current/src-sh/pc-metapkgmanager/Makefile	2012-09-26 17:03:44 UTC (rev 19541)
+++ pcbsd/current/src-sh/pc-metapkgmanager/Makefile	2012-09-26 17:31:41 UTC (rev 19542)
@@ -32,6 +32,9 @@
 install_scripts: first FORCE
 	@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/local/bin/ || $(MKDIR) $(INSTALL_ROOT)/usr/local/bin/ 
 	-$(INSTALL_FILE) pc-metapkgmanager $(INSTALL_ROOT)/usr/local/bin/
+	@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/local/share/pcbsd/metaconf/ || $(MKDIR) $(INSTALL_ROOT)/usr/local/share/pcbsd/metaconf/
+	-$(INSTALL_FILE) prune-files $(INSTALL_ROOT)/usr/local/share/pcbsd/metaconf/
+	tar cvJf /usr/local/share/pcbsd/metaconf/overlay.txz -C port-overlay .	
 
 uninstall_scripts:  FORCE
 	-$(DEL_FILE) -r $(INSTALL_ROOT)/usr/local/bin/pc-metapkgmanager

Modified: pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager
===================================================================
--- pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager	2012-09-26 17:03:44 UTC (rev 19541)
+++ pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager	2012-09-26 17:31:41 UTC (rev 19542)
@@ -33,6 +33,8 @@
 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
@@ -51,7 +53,7 @@
    
 Options:
   add pkg1,pkg2 <loc>	 -- Add the specified list of meta-packages
-			    <loc> should be a FTP / HTTP url where pkg_add
+			    <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
@@ -59,7 +61,7 @@
   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
+			    <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
@@ -129,22 +131,30 @@
 
 		else
 		   # Check if the package is already installed
-		   if [ -d "${_chroot}/var/db/pkg/$pkg" ] ; then
-		     echo "Skipping installed package: $pkg"
-		     echo "Skipping installed package: $pkg" >>${LOGFILE}
-		     continue
+		   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 "${MIRRORURL}"
-		      pkg_add -f "${pkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
+		      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 -f "/.mnt.$$/${pkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
+		      ${_chrootcmd} pkg add "/.mnt.$$/${pkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
 		   fi
 		fi
         done
@@ -154,20 +164,28 @@
            for pkg in $PKGLIST
            do
 	      # Check if the package is already installed
-	      if [ -d "${_chroot}/var/db/pkg/$pkg" ] ; then
-	         echo "Skipping installed package: $pkg"
-	         echo "Skipping installed package: $pkg" >>${LOGFILE}
-	         continue
+	      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 -f "${pkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
+	        pkg add "${pkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
               else
 	        echo "#!/bin/sh
 cd ${TMPDIR}
-pkg_add -f ${pkg}.txz" > ${_chroot}/.insPkg.$$.sh
+pkg add ${pkg}.txz" > ${_chroot}/.insPkg.$$.sh
 	        chmod 755 ${_chroot}/.insPkg.$$.sh
 	        ${_chrootcmd} /.insPkg.$$.sh >>${LOGFILE} 2>>${LOGFILE}
 	        rm "${_chroot}/.insPkg.$$.sh"
@@ -215,6 +233,12 @@
           fi
 	fi
 
+	# Prune any port files we dont want
+	do_prune
+
+	# Extract custom files
+	extract_overlay
+
 	echo "Finished Meta-Package: $_apkg"
 	
 }
@@ -237,7 +261,7 @@
 		_iList=""
 		while read pkg
 		do
-			${_chrootcmd} pkg_info $pkg >/dev/null 2>/dev/null
+			${_chrootcmd} pkg info -e $pkg >/dev/null 2>/dev/null
 			if [ "$?" != "0" ] ; then continue; fi
 			_iList="${_iList}${pkg}:"
 		done < ${i}/pkg-list
@@ -265,7 +289,7 @@
 	for rmPkg in $PKGLIST
 	do
 		# Make sure this pkg is installed
-		${_chrootcmd} pkg_info $rmPkg >/dev/null 2>/dev/null
+		${_chrootcmd} pkg info -e $rmPkg >/dev/null 2>/dev/null
 		if [ "$?" != "0" ] ; then 
 			echo "Already uninstalled: ${rmPkg}" 
 			echo "Already uninstalled: ${rmPkg}" >>${LOGFILE}
@@ -281,8 +305,8 @@
 		fi
 
 		# confirm this package isn't required by any others
-		${_chrootcmd} pkg_info -R ${rmPkg} 2>/dev/null | grep -q "Required by:"
-		if [ "$?" = "0" ] ; then 
+		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
@@ -290,7 +314,7 @@
 
 		echo "Removing: ${rmPkg}"
 		echo "Removing: ${rmPkg}" >>${LOGFILE}
-		${_chrootcmd} pkg_delete -f ${rmPkg} >>${LOGFILE} 2>>${LOGFILE}
+		${_chrootcmd} pkg delete -yf ${rmPkg} >>${LOGFILE} 2>>${LOGFILE}
 
 	done
 
@@ -321,7 +345,7 @@
    local newSkipped=""
    for skPkg in $1
    do
-      ${_chrootcmd} pkg_info -R ${skPkg} 2>/dev/null | grep -q "Required by:"
+      nbrequired=`${_chrootcmd} pkg query "%?r" ${skPkg}`
       if [ "$?" = "0" ] ; then 
         newSkipped="$skPkg $newSkipped"	
         continue
@@ -329,7 +353,7 @@
       found=1
       echo "Removing: ${skPkg}"
       echo "Removing: ${skPkg}" >>${LOGFILE}
-      ${_chrootcmd} pkg_delete -f ${skPkg} >>${LOGFILE} 2>>${LOGFILE}
+      ${_chrootcmd} pkg delete -yf ${skPkg} >>${LOGFILE} 2>>${LOGFILE}
    done
 
    if [ $found -eq 1 ] ; then
@@ -346,10 +370,10 @@
 
 # Check if the specified pkg doesn't have anything which requires it, and remove it if so
 check_remove_pkg() {
-        ${_chrootcmd} pkg_info -R "${1}" | grep "Required" >/dev/null 2>/dev/null
-        if [ "$?" != "0" ] ; then
+        nbrequired=`${_chrootcmd} pkg query "%?r" ${1}`
+        if [ "$nbrequired" == "0" ] ; then
 		echo "Removing non-used pkg: $1" >>${LOGFILE} 2>>${LOGFILE} 
-                ${_chrootcmd} pkg_delete -f ${1} >>${LOGFILE} 2>>${LOGFILE}
+                ${_chrootcmd} pkg delete -yf ${1} >>${LOGFILE} 2>>${LOGFILE}
                 return 0
         fi
         return 1
@@ -405,20 +429,19 @@
 	found=1
 	nfound=0
 
-	# Now query pkg_info to confirm each pkg is installed
+	# 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
-		# See if the pkg is installed, without worrying about
-		# version numbers. This means a meta-pkg shows as
-		# installed even if the user manually updated
-    		pName=`echo $pkg | rev | cut -d "-" -f 2-25 | rev`
-		ls -d ${_chroot}/var/db/pkg/${pName}-* >/dev/null 2>/dev/null
-		if [ $? -eq 0 ] ; then
-			found=0
-		else
-			nfound=1
-		fi
-		
+		pName=${pkg%-*}
+		case $'\n'$list$'\n' in
+			*$'\n'"$pName"$'\n'*) found=0 ;;
+			*) nfound=1 ;;
+		esac
 	done < ${MPDIR}/${_mpkg}/pkg-list
 
 	if [ "$found" = "0" -a "$nfound" = "0" ] ; then
@@ -496,7 +519,11 @@
 
   # Checkout the installed pkgs and compare to master list
   local fPkgUp=0
-  ls ${_chroot}/var/db/pkg > /tmp/.pkgList.$$
+  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.$$
@@ -677,17 +704,20 @@
   fi
 
   # Remove the old pkg
-  #echo "${_chrootcmd} pkg_delete -f $oPkg"
-  ${_chrootcmd} pkg_delete -f "$oPkg" >>${LOGFILE} 2>>${LOGFILE}
+  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
-     ${_chrootcmd} pkg_add -f "${TMPDIR}/${nPkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
+     pkg -C ${_chroot} add "${TMPDIR}/${nPkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
   else
      if [ -z "$_chroot" ] ; then
-        pkg_add -f "${nPkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
+        pkg add "${nPkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
      else
-        ${_chrootcmd} pkg_add -f "/.mnt.$$/${nPkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
+        pkg -C ${_chroot} add -f "/.mnt.$$/${nPkg}.txz" >>${LOGFILE} 2>>${LOGFILE}
      fi
   fi
 
@@ -695,7 +725,11 @@
 
 get_pkg_from_name() {
   if [ "$2" = "sys" ] ; then
-    ${_chrootcmd} pkg_info | cut -d ' ' -f 1 >/tmp/.plist.$$ 2>/dev/null
+    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
@@ -773,6 +807,35 @@
   rm /tmp/.pc-meta-sort.$$
 }
 
+do_prune()
+{
+  if [ ! -e "$PRUNEFILE" ] ; then return; fi
+
+  while read pLine
+  do
+     echo $pLine | grep -q "^#"
+     if [ $? -eq 0 ] ; then continue ; fi
+	
+     ls ${_chroot}/$pLine >/dev/null 2>/dev/null
+     if [ $? -eq 0 ] ; then
+	echo "Pruning: $pLine"
+        rm ${_chroot}/${pLine}
+     fi
+  done <${PRUNEFILE}
+}
+
+extract_overlay()
+{
+  if [ ! -e "$OVERLAYFILE" ] ; then return; fi
+  echo -e "Extracting overlay data...\c"
+  if [ -z "${_chroot}" ] ; then
+     tar xvpf ${OVERLAYFILE} -C / >/dev/null 2>/dev/null
+  else
+     tar xvpf ${OVERLAYFILE} -C ${_chroot} >/dev/null 2>/dev/null
+  fi
+  echo "Done!"
+}
+
 # Unset some vars
 _chroot=""
 _chrootcmd=""
@@ -804,7 +867,7 @@
     update) updatepkgs "${2}" "${3}" ; exit 0 ;;
   --chroot) if [ -z "$2" ] ; then display_usage ; fi  
 	    _chroot="$2" 
-            if [ ! -e "${_chroot}/usr/sbin/pkg_add" ] ; then
+            if [ ! -e "${_chroot}/bin/sh" ] ; then
               echo "Invalid chroot dir: ${_chroot}"
               exit 1
 	    fi



More information about the Commits mailing list