[PC-BSD Commits] r7554 - in pcbsd/current/src-qt4/pbi-manager: . man

svn at pcbsd.org svn at pcbsd.org
Tue Sep 14 08:06:31 PDT 2010


Author: kris
Date: 2010-09-14 08:06:30 -0700 (Tue, 14 Sep 2010)
New Revision: 7554

Modified:
   pcbsd/current/src-qt4/pbi-manager/man/pbi_autobuild.1
   pcbsd/current/src-qt4/pbi-manager/pbi-manager
Log:

Added functionality to "keep" a number of previously built PBIs from pbi_autobuild,
these will be used to generate patches to the latest version of the app, which are much
smaller than upgrading from the entire archive again



Modified: pcbsd/current/src-qt4/pbi-manager/man/pbi_autobuild.1
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/man/pbi_autobuild.1	2010-09-14 13:27:20 UTC (rev 7553)
+++ pcbsd/current/src-qt4/pbi-manager/man/pbi_autobuild.1	2010-09-14 15:06:30 UTC (rev 7554)
@@ -10,6 +10,8 @@
 .Op Fl d Ar portdir
 .Op Fl o Ar outdir
 .Op Fl h Ar script
+.Op Fl -genpatch
+.Op Fl -keep Ar num
 .Op Fl -prune
 .Op Fl -sign Ar keyfile
 .Sh DESCRIPTION
@@ -33,6 +35,13 @@
 .It Fl o Ar outdir
 The directory to place the finished PBI files, will also be used to determine
 which apps are in need of a rebuild if the associated FreeBSD port has been updated.
+.It Fl -genpatch
+When building a new PBI, check for archived copies, and generate smaller patch
+updates to the new version. (*.pbp files)
+.It Fl -keep Ar num
+When building new PBIs, keep <num> copies of past versions of working PBI in 
+<outdir>/archived/ folder. These archived copies can be used with the --genpatch 
+command to generate update patch files.
 .It Fl -prune
 Remove any PBIs which no longer have an associated module in confdir. 
 .It Fl -sign Ar keyfile

Modified: pcbsd/current/src-qt4/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/pbi-manager	2010-09-14 13:27:20 UTC (rev 7553)
+++ pcbsd/current/src-qt4/pbi-manager/pbi-manager	2010-09-14 15:06:30 UTC (rev 7554)
@@ -56,6 +56,8 @@
   -d portdir   -- Use different ports dir (Default: /usr/ports)
   -h script    -- Call the following helper script after each build
   -o outdir    -- Where to place the finished PBI file(s) <required>
+  --genpatch   -- Generate patch files (*.pbp) from archived PBIs to current
+  --keep <num> -- Keep <num> old versions in archive folder for each built PBI
   --prune      -- Remove files from 'outdir' that no longer have a module
   --sign key   -- Sign the PBI(s) with specified openssl key
 
@@ -287,6 +289,13 @@
                         PBI_AB_HELPS="$_ABSPATH"
                         ;;
 
+        --genpatch)     PBI_AB_GENPATCH="YES" 
+                        ;;
+            --keep)     if [ $# -eq 1 ]; then usage_autob_pbi; fi
+                        shift; PBI_AB_ARCHIVENUM="$1"
+			expr $PBI_AB_ARCHIVENUM + 1 2>/dev/null
+			if [ $? != 0 ] ; then usage_autob_pbi; fi
+                        ;;
            --prune)     PBI_AB_PRUNE="YES" 
                         ;;
             --sign)     if [ $# -eq 1 ]; then usage_autob_pbi; fi
@@ -547,7 +556,9 @@
 	PBI_UNINS_PATHSCRIPT="uninstall-pathlinks.sh"
 
         # User overridable variables
+	PBI_AB_ARCHIVENUM=""
 	PBI_AB_CONFDIR=""
+	PBI_AB_GENPATCH="NO"
 	PBI_AB_HELPS=""
 	PBI_AB_OUTDIR=""
 	PBI_AB_SSLPRIVKEY=""
@@ -2597,6 +2608,7 @@
 		        start_ext_ab "$PBI_MAKEPORT" \
 				"${PBI_BUILDKEY}" "${PBI_PROGVERSION}" \
 				"${_cd}" "${PBI_AB_OUTDIR}"
+
 		else
 			echo "${PBI_MAKEPORT} is up to date"
 		fi
@@ -2643,12 +2655,28 @@
 	echo "pbi_makeport ${_flags} ${_mp}"
 
 	if [ ! -d "${_od}" ] ; then mkdir -p "${_od}" ; fi
-	oldpbi="`ls ${_od}/*.pbi`"
+	oldpbi="`ls ${_od}/*.pbi*`"
 
 	pbi_makeport ${_flags} ${_mp} 2>${_od}/build.log >${_od}/build.log
 	if [ "$?" = "0" ] ; then
-		if [ ! -z "$oldpbi" ] ; then rm "$oldpbi" ; rm "${oldpbi}.sha256" ; fi
 
+		# Check for new PBIs, don't want to remove a rebuild of the same version
+		newpbi="`ls ${_od}/*.pbi`"
+
+		# Deal old PBIs if we need to
+		if [ "$newpbi" != "$oldpbi" ] ; then
+			if [ ! -z "$PBI_AB_ARCHIVENUM" ] ; then
+				# Move the old PBIs to the archived folder
+				archive_old_pbis "$_od" "$oldpbi" "$PBI_AB_ARCHIVENUM"
+			else
+				# Remove old PBI stuff
+				for _oldPBI in $oldpbi
+				do
+			  	 	rm "$_oldPBI"
+				done
+			fi
+		fi
+
 		echo "$PBI_PROGVERSION" > "${_od}/pbi-version"
 		if [ ! -z "$PBI_BUILDKEY" ] ; then
 			echo "$PBI_PROGVERSION" > "${_od}/pbi-buildkey"
@@ -2672,6 +2700,12 @@
 
 		rm "${_od}/build.log.bz2" >/dev/null 2>/dev/null
 		bzip2 "${_od}/build.log"
+
+		# Generate patch files to the new version of this PBI
+		if [ "$PBI_AB_GENPATCH" = "YES" -a -d "${_od}/archived" ] ; then
+			gen_pbi_patches "${_od}" "$PBI_PROGVERSION"
+		fi
+
 	else
 		echo "Failed" > "${_od}/pbi-result"
 		if [ ! -z "${PBI_AB_HELPS}" ] ; then
@@ -2680,6 +2714,35 @@
 	fi
 }
 
+# Move old PBIs to the archive
+archive_old_pbis()
+{
+	_od="$1"
+	_oldpbifiles="$2"
+	_keepnum="$3"
+
+	# Make sure the archived dir exists
+	if [ ! -d "${_od}/archived" ] ; then mkdir "${_od}/archived"; fi
+
+	# mv the old PBIs into the dir
+	for _oldPBI in $_oldpbifiles
+	do
+  	 	mv "${_od}/$_oldPBI" "${_od}/archived/"
+	done
+
+	# Prune anything beyond the _keepnum
+	oCount="0"
+	oFiles=`ls -t ${_od}/archived/*.pbi`
+	for oFile in $oFiles
+	do
+		if [ -z "$oFile" ] ; then continue ; fi
+		if [ $oCount > $_keepnum ] ; then
+			rm ${oFile}*
+		fi
+		oCount=`expr $oCount + 1`	
+	done
+}
+
 # Check if we need to do an auto-build of the target PBI
 check_ab_needed() {
 	_port="$1"



More information about the Commits mailing list