[PC-BSD Commits] r21888 - in pcbsd/current/src-sh: libsh pc-metapkgmanager port-files

svn at pcbsd.org svn at pcbsd.org
Sat Mar 16 21:32:03 PDT 2013


Author: kris
Date: 2013-03-17 04:32:03 +0000 (Sun, 17 Mar 2013)
New Revision: 21888

Modified:
   pcbsd/current/src-sh/libsh/functions.sh
   pcbsd/current/src-sh/pc-metapkgmanager/Makefile
   pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager
   pcbsd/current/src-sh/port-files/pkg-plist
Log:

Add a new CLI command:

pc-pkg

This command has no specific flags. It is just a small wrapper around
the "pkg" command, with some specific functionality.

1st, it will intercept the "install" or "upgrade" flags, and use our integrated
aria2 downloader to grab the packages from the mirrors. Then it will run the pkg
command with the flags provided and let it do its thing. 

2nd, it will cleanup after itself




Modified: pcbsd/current/src-sh/libsh/functions.sh
===================================================================
--- pcbsd/current/src-sh/libsh/functions.sh	2013-03-17 03:43:51 UTC (rev 21887)
+++ pcbsd/current/src-sh/libsh/functions.sh	2013-03-17 04:32:03 UTC (rev 21888)
@@ -40,6 +40,7 @@
   if [ -z "$PKG_CACHEDIR" ] ; then
      exit_err "Failed getting PKG_CACHEDIR"
   fi
+  export PKG_CACHEDIR
 
   cat /usr/local/etc/pkg.conf | grep -q "^packagesite:"
   if [ $? -eq 0 ] ; then
@@ -52,6 +53,7 @@
 
   for i in $pkgList
   do
+    if [ -e "${PKG_CACHEDIR}/All/${i}" ] ; then rm ${PKG_CACHEDIR}/All/${i} ; fi
     get_file_from_mirrors "/${pkgUrl}/All/${i}" "${PKG_CACHEDIR}/All/${i}"
     if [ $? -ne 0 ] ; then
       exit_err "Failed downloading: /${pkgUrl}/All/${i}"

Modified: pcbsd/current/src-sh/pc-metapkgmanager/Makefile
===================================================================
--- pcbsd/current/src-sh/pc-metapkgmanager/Makefile	2013-03-17 03:43:51 UTC (rev 21887)
+++ pcbsd/current/src-sh/pc-metapkgmanager/Makefile	2013-03-17 04:32:03 UTC (rev 21888)
@@ -35,6 +35,7 @@
 	@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/local/share/pcbsd/ || $(MKDIR) $(INSTALL_ROOT)/usr/local/share/pcbsd/
 	@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/local/share/pcbsd/metaset/ || rm -rf /usr/local/share/pcbsd/metaset
 	cp -r metaset /usr/local/share/pcbsd/metaset
+	cd /usr/local/bin/ && ln -f pc-metapkgmanager pc-pkg
 
 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	2013-03-17 03:43:51 UTC (rev 21887)
+++ pcbsd/current/src-sh/pc-metapkgmanager/pc-metapkgmanager	2013-03-17 04:32:03 UTC (rev 21888)
@@ -293,6 +293,65 @@
 	chmod 666 ${LOGFILE}
 }
 
+intercept_pkg_dl()
+{
+   local count=0;
+   fullopts="$@"
+   op="$1"
+   
+   # Make sure we insert some flags we need
+   while [ $# -gt 0 ]; do
+     if [ $count -gt 0 ] ; then
+        # If we are already using -n, we can skip downloading anything
+	if [ "$1" = "-n" ] ; then
+           pkg $fullopts
+           exit $?
+	fi
+        flags="$flags $1"
+     else
+        flags="-L -n"
+     fi
+     count=`expr $count + 1`
+     shift
+   done
+
+   # Lets pre-download all packages
+   download_cache_packages "pkg $op $flags"
+
+   # Time to run pkgng and let it do its thing
+   pkg $fullopts 
+   result=$?
+
+   # Nobody likes a litter bug
+   if [ -d "${PKG_CACHEDIR}/All" ] ; then
+      echo -e "Cleaning up cache files..\c"
+      rm -rf "${PKG_CACHEDIR}/All"
+      echo -e "Done"
+   fi
+   
+   exit $result
+}
+
+# Parse the flags we are sending over to pkg
+# will intercept the install / upgrade flags
+# and use our internal function to download
+# in a much faster method ;)
+do_pc-pkg()
+{
+   case $1 in
+ install|upgrade) intercept_pkg_dl ${@} ;;
+               *) pkg ${@} 
+                  exit $?
+                  ;;
+   esac 
+}
+
+# Are we running in pc-pkg mode?
+if [ `basename $0` = "pc-pkg" ] ; then
+   do_pc-pkg $@
+   exit 0
+fi
+
 # Unset some vars
 _pkgflags=""
 PKGUPDATES=""
@@ -300,7 +359,6 @@
 # The default PKGSET
 PKGSET="pcbsd"
 
-
 # Check if we have a different dataset specified in pcbsd.conf
 PCBSD_ETCCONF="/usr/local/etc/pcbsd.conf"
 _pkgChk="`sed -n 's/PCBSD_METAPKGSET: //p' ${PCBSD_ETCCONF} 2>/dev/null`"

Modified: pcbsd/current/src-sh/port-files/pkg-plist
===================================================================
--- pcbsd/current/src-sh/port-files/pkg-plist	2013-03-17 03:43:51 UTC (rev 21887)
+++ pcbsd/current/src-sh/port-files/pkg-plist	2013-03-17 04:32:03 UTC (rev 21888)
@@ -1,4 +1,5 @@
 bin/pc-metapkgmanager
+bin/pc-pkg
 bin/warden
 bin/pc-extractoverlay
 bin/pc-updatemanager



More information about the Commits mailing list