[PC-BSD Commits] r7563 - in pcbsd/current/src-qt4/pbi-manager: . icons man port-files

svn at pcbsd.org svn at pcbsd.org
Wed Sep 15 10:49:05 PDT 2010


Author: kris
Date: 2010-09-15 10:49:05 -0700 (Wed, 15 Sep 2010)
New Revision: 7563

Added:
   pcbsd/current/src-qt4/pbi-manager/icons/patch.png
   pcbsd/current/src-qt4/pbi-manager/man/pbi_makepatch.1
   pcbsd/current/src-qt4/pbi-manager/man/pbi_patch.1
Modified:
   pcbsd/current/src-qt4/pbi-manager/install.sh
   pcbsd/current/src-qt4/pbi-manager/pbi-manager
   pcbsd/current/src-qt4/pbi-manager/port-files/Makefile
   pcbsd/current/src-qt4/pbi-manager/port-files/pkg-plist
Log:

Added new pbi_makepatch command, which compares the differences between two PBIs and
produces a much smaller patch file (.PBP). This patch file can be used to upgrade
an installed PBI to a new version without needing to re-download the entire archive again.

Still working on the pbi_patch command for installing the patch, will be added soon




Property changes on: pcbsd/current/src-qt4/pbi-manager/icons/patch.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: pcbsd/current/src-qt4/pbi-manager/install.sh
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/install.sh	2010-09-15 14:52:41 UTC (rev 7562)
+++ pcbsd/current/src-qt4/pbi-manager/install.sh	2010-09-15 17:49:05 UTC (rev 7563)
@@ -17,9 +17,11 @@
 cp pbi-manager ${LB}/sbin/pbi_create
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_add
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_autobuild
+ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_makepatch
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_makeport
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_delete
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_info
+ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_patch
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_update
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi-crashhandler
 
@@ -40,6 +42,7 @@
 # Copy the icon
 mkdir -p ${LB}/share/pbi-manager/icons >/dev/null 2>/dev/null
 cp ${DIR}/icons/default.png ${LB}/share/pbi-manager/icons
+cp ${DIR}/icons/patch.png ${LB}/share/pbi-manager/icons
 
 mkdir -p /var/db/pbi-keys >/dev/null 2>/dev/null
 cp ${DIR}/keys/pubkey.ssl /var/db/pbi-keys/pcbsd.ssl

Modified: pcbsd/current/src-qt4/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/pbi-manager	2010-09-15 14:52:41 UTC (rev 7562)
+++ pcbsd/current/src-qt4/pbi-manager/pbi-manager	2010-09-15 17:49:05 UTC (rev 7563)
@@ -130,6 +130,35 @@
         exit 0
 }
 
+usage_makepatch_pbi() {
+        cat <<EOF
+usage: `basename $0` [options] oldpbi newpbi
+                
+Options:
+  -o outdir    -- Save the .PBP file to outdir
+  --sign key   -- Sign the PBI with specified openssl key
+
+EOF
+        exit 0
+}
+
+usage_patch_pbi() {
+        cat <<EOF
+usage: `basename $0` [options] pbp
+                
+Options:
+  -e             -- Extract Only
+  -g             -- Get and show path to icon / images for gui installer
+  -i             -- Display information about this PBI
+  -o outdir      -- Extract to target directory
+  --checkscript  -- Display any custom install / removal scripts
+  --no-checksig  -- Ignore signature verification and force install
+  --no-hash      -- Disable using shared hash folder for PBI
+
+EOF
+        exit 0
+}
+
 # update usage
 usage_update_pbi() {
         cat <<EOF
@@ -191,6 +220,88 @@
 	fi
 }
 
+# Parse the command line for patching
+parse_makepatch_pbi_cmdline() {
+        while [ $# -gt 0 ]; do
+                case "$1" in
+                -o)     if [ $# -eq 1 ]; then usage_makepatch_pbi; fi
+                        shift; PBI_PATCHOUTDIR="$1"
+                        ;;
+            --sign)     if [ $# -eq 1 ]; then usage_makepatch_pbi; fi
+                        shift; PBI_SSLPRIVKEY="$1"
+                        ;;
+                 *)	if [ $# -gt 2  ]; then usage_makepatch_pbi; fi
+                       	PBI_OLDFILENAME="$1"
+			shift
+                       	PBI_FILENAME="$1"
+                        ;;
+                esac
+                shift
+        done
+
+        if [ -z "${PBI_FILENAME}" ]; then usage_makepatch_pbi ; fi
+        if [ -z "${PBI_OLDFILENAME}" ]; then usage_makepatch_pbi ; fi
+        if [ -z "${PBI_PATCHOUTDIR}" ]; then PBI_PATCHOUTDIR=`pwd` ; fi
+
+        # Load all the information about this PBI / PBP
+        load_info_from_header
+}
+
+# Parse the command line for patching
+parse_patch_pbi_cmdline() {
+        while [ $# -gt 0 ]; do
+                case "$1" in
+                -e)     PBI_EXTRACTONLY="YES"
+                        ;;
+                -g)     PBI_ADD_GUIDISPLAY="YES" 
+                        ;;
+                -i)     PBI_ADD_INFODISPLAY="YES" 
+                        ;;
+                -o)
+                        if [ $# -eq 1 ]; then usage_patch_pbi; fi
+                        shift; PBI_ALTEXTRACT_DIR="$1"
+                        ;;
+     --checkscript)     PBI_CHECKSCRIPTS="YES" ;;
+         --no-hash)     PBI_DISABLEHASHDIR="YES" ;;
+     --no-checksum)     PBI_SKIPCHECKSUM="YES" ;;
+     --no-checksig)     PBI_SKIPSIGVERIFY="YES" ;;
+                 *)	if [ $# -gt 1 ]; then usage_patch_pbi; fi
+                        PBI_FILENAME="$1"
+                        ;;
+                esac
+                shift
+        done
+
+
+        if [ -z "${PBI_FILENAME}" ]; then usage_patch_pbi ; fi
+
+        # Load all the information about this PBI / PBP
+        load_info_from_header
+
+	# Make sure this isn't a patch file
+	is_pbi_patch
+	if [ "$?" = "1" ] ; then
+		exit_err "This is not a PBP patch file"
+	fi
+
+        if [ -z "${PBI_ORIGPROGDIRPATH}" ]; then usage_patch_pbi ; fi
+
+        # Lastly set PBI_PROGDIRNAME
+        PBI_PROGDIRNAME="`echo ${PBI_ORIGPROGDIRPATH} | rev | cut -d '/' -f 1 | rev`"
+                        
+        if [ "${PBI_EXTRACTONLY}" = "YES" ] ; then
+                # If extracting to a alt-outdir, set it now
+                PBI_PROGDIRPATH="`pwd`/${PBI_PROGDIRNAME}"
+        
+                if [ ! -z "${PBI_ALTEXTRACT_DIR}" ]; then
+                        PBI_PROGDIRPATH="${PBI_ALTEXTRACT_DIR}/${PBI_PROGDIRNAME}"
+                fi      
+        else
+                # Set the installation dir
+                PBI_PROGDIRPATH="${PBI_ORIGPROGDIRPATH}"
+        fi
+}
+
 # Parse the command line for adding
 parse_add_pbi_cmdline() {
         while [ $# -gt 0 ]; do
@@ -241,6 +352,11 @@
 
         if [ -z "${PBI_ORIGPROGDIRPATH}" ]; then usage_add_pbi ; fi
 
+	# Make sure this isn't a patch file
+	is_pbi_patch
+	if [ "$?" = "0" ] ; then
+		exit_err "This is a PBP patch file, use 'pbi_patch' instead"
+	fi
 
         # Lastly set PBI_PROGDIRNAME
         PBI_PROGDIRNAME="`echo ${PBI_ORIGPROGDIRPATH} | rev | cut -d '/' -f 1 | rev`"
@@ -257,7 +373,6 @@
 		# Set the installation dir
 		PBI_PROGDIRPATH="${PBI_ORIGPROGDIRPATH}"
 	fi
-
 }
 
 # Parse the command line
@@ -501,6 +616,7 @@
 	PBI_RCDIR="${SYS_LOCALBASE}/etc/rc.d"
 	PBI_ETCCONF="${SYS_LOCALBASE}/etc/pbi.conf"
 	PBI_DEFAULT_ICON="${PROGBASE}/share/pbi-manager/icons/default.png"
+	PBI_PATCH_ICON="${PROGBASE}/share/pbi-manager/icons/patch.png"
 	PBI_LDCONFIGFILE="${PROGBASE}/etc/ldpbiconfig"
 	PBI_LDCONFIGRC="${PROGBASE}/etc/rc.d/ldpbiconfig"
 	PROGVERSION="1.0"
@@ -541,6 +657,7 @@
 	PBI_INS_PATHSCRIPT="install-pathlinks.sh"
 	PBI_LICAGREE="NO"
 	PBI_LICENSEFILE="LICENSE"
+	PBI_PATCHVERSION=""
 	PBI_REMOTEFETCH=""
 	PBI_RESOURCE_DIR="resources"
 	PBI_SS_ICON="__PBI_ICON__"
@@ -795,6 +912,36 @@
   fi 
 }
 
+# Star the make patch process
+pbi_makepatch_init() {
+	parse_makepatch_pbi_cmdline "$@"
+
+  	require_root
+
+	# Create a new patch file from the two PBIs specified
+	make_pbi_patchfile "${PBI_FILENAME}" "${PBI_OLDFILENAME}" "${PBI_PATCHOUTDIR}"
+}
+
+# Start the patch process
+pbi_patch_init() {
+	parse_patch_pbi_cmdline "$@"
+
+  	require_root
+
+	# Check if we are only displaying information
+	check_pbi_info_display
+	check_pbi_gui_display
+	check_pbi_scripts_display
+	check_pbi_license_display
+	if [ "$PBI_ADD_GUIDISPLAY" = "YES" -o "$PBI_ADD_INFODISPLAY" = "YES" -o "$PBI_CHECKSCRIPTS" = "YES" -o "${PBI_ADD_LICDISPLAY}" = "YES" ] 
+	then 
+		exit 0 
+	fi
+
+	# Try to apply this patch file
+	do_pbi_patch
+}
+
 pbi_add_init() {
 	parse_add_pbi_cmdline "$@"
 
@@ -867,9 +1014,18 @@
 	tmp="`echo ${PBI_PROGNAME} | tr -d ' ' | tr [A-Z] [a-z]`"
         _appname="${tmp}-${PBI_PROGVERSION}-${PBI_APPARCH}"
 
-	echo "PBI Information for: $_appname"
+	if [ -z "$PBI_PATCHVERSION" ] ; then
+		echo "PBI Information for: $_appname"
+	else
+		echo "PBP Information for: $_appname"
+	fi
 	echo "-----------------------------------------------------"
 	echo "Name: ${PBI_PROGNAME}"
+
+	if [ ! -z "$PBI_PATCHVERSION" ] ; then
+		echo "PatchTarget: `echo $PBI_PATCHVERSION | cut -d ':' -f 1`"
+	fi
+
 	echo "Version: ${PBI_PROGVERSION}"
 	echo "Built: ${PBI_PROGMDATE}"
 	echo "Prefix: ${PBI_ORIGPROGDIRPATH}"
@@ -934,7 +1090,14 @@
 }
 
 open_header_tmp() {
-	PBI_HEADER_TMPDIR=".PBI-header.$$"
+
+	# If we have a custom extract dir, use it
+	if [ -z "$1" ] ; then
+		PBI_HEADER_TMPDIR=".PBI-header.$$"
+	else
+		PBI_HEADER_TMPDIR="${1}/.PBI-header.$$"
+	fi
+
 	if [ -e "${PBI_HEADER_TMPDIR}" ] ; then rm -rf "${PBI_HEADER_TMPDIR}" ; fi
 	mkdir -p "${PBI_HEADER_TMPDIR}"
 	
@@ -1002,6 +1165,7 @@
         PBI_ARCHIVE_COUNT=""
         PBI_ARCHIVE_CHECKSUM=""
 	PBI_SIGVALID=""
+	PBI_PATCHVERSION=""
 
 	PBI_ORIGPROGDIRPATH="`cat ${1}/pbi_defaultpath`"
         PBI_PROGNAME="`cat ${1}/pbi_name`"
@@ -1014,6 +1178,11 @@
         PBI_APPCREATEVER="`cat ${1}/pbi_createver 2>/dev/null`"
         PBI_ARCHIVE_COUNT="`cat ${1}/pbi_archivecount 2>/dev/null`"
         PBI_ARCHIVE_CHECKSUM="`cat ${1}/pbi_archivesum 2>/dev/null`"
+	
+	# Check if this is a patch file
+	if [ -e "${1}/pbi_patchfile" ] ; then
+        	PBI_PATCHVERSION=`cat ${1}/pbi_patchfile`
+	fi
 
 	# See if this PBI was signed
 	if [ -e "${1}/pbi_archivesum.sha1" ] ; then
@@ -1235,7 +1404,7 @@
 	return 0	
 }
 
-# Verify if the archive checmsum is good
+# Verify if the archive checksum is good
 pbi_verify_archivesum() {
 	if [ "${PBI_SKIPCHECKSUM}" = "YES" ] ; then return 0 ; fi
 	echo -e "Verifying CheckSum...\c"
@@ -1799,7 +1968,7 @@
 copy_resource_dir() {
 	if [ -d "${PBI_CONFDIR}/${PBI_RESOURCE_DIR}" ] ; then
 		echo "Copying ${PBI_CONFDIR}/${PBI_RESOURCE_DIR} -> ${PBI_STAGEDIR}"
-		tar cvf - -C ${PBI_CONFDIR}/${PBI_RESOURCE_DIR} . 2>/dev/null \
+		tar cvf - -C ${PBI_CONFDIR}/${PBI_RESOURCE_DIR} --exclude .svn . 2>/dev/null \
 		| tar xvpf - -C ${PBI_STAGEDIR} 2>/dev/null
 	fi
 }
@@ -1889,13 +2058,13 @@
 	# Save a checksum of archive file
 	sha256 -q "${PBI_CREATE_ARCHIVE}" > "${PBI_HEADERDIR}/pbi_archivesum"
 
-	sign_pbi_files
+	sign_pbi_files "$PBI_HEADERDIR"
 }
 
 # Use openssl to sign parts of the pbi header structure and archive 
 sign_pbi_files() {
 	if [ -z "${PBI_SSLPRIVKEY}" ] ; then return 0 ; fi
-	_sf="${PBI_HEADERDIR}/pbi_archivesum ${PBI_HEADERDIR}/${MOD_PREINS} ${PBI_HEADERDIR}/${MOD_POSTINS} ${PBI_HEADERDIR}/${MOD_PREREM}"
+	_sf="${1}/pbi_archivesum ${1}/${MOD_PREINS} ${1}/${MOD_POSTINS} ${1}/${MOD_PREREM}"
 	for i in $_sf
 	do
 		openssl dgst -sha1 \
@@ -2703,7 +2872,7 @@
 
 		# 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"
+			gen_pbi_patches "${_od}" "${_od}/archived"
 		fi
 
 	else
@@ -2714,6 +2883,289 @@
 	fi
 }
 
+# Function which begins to generate patch files from archived PBIs to current
+gen_pbi_patches()
+{
+	_curPBIdir="$1"
+	_oldPBIdir="$2"
+
+	_curPBI=`ls ${_curPBIdir}/*.pbi`
+
+	# First remove any old patches
+	rm ${_curPBIdir}/*.pbp 2>/dev/null
+
+	# Build a list of old PBIs we need to make patches from
+	_oPBIs=`ls ${oldPBIdir}/*.pbi`
+	for _oPBI in $_oPBIs
+	do
+		# Make sure we don't try to make a patch of identical files
+	  	if [ "`basename $oPBI`" != "`basename $_curPBI`" ] ; then	
+			make_pbi_patchfile "$_curPBI" "$_oPBI" "$_curPBIdir"
+		fi
+	done
+}
+
+# Function which compares two PBIs, and creates a .pbp file from the differences 
+make_pbi_patchfile()
+{
+	_pbiNew="$1"
+	_pbiOld="$2"
+	_cDir="$3"
+
+	_pbiNewDir="${PBI_APPDIR}/.newPBI-$$"
+	_pbiOldDir="${PBI_APPDIR}/.oldPBI-$$"
+	_pbiPatchDir="${PBI_APPDIR}/.patchPBI-$$"
+	_pbiPatchHeaderDir="${PBI_APPDIR}/.patchPBIHeaderDir-$$"
+	_pbiPatchArchiveFile="${PBI_APPDIR}/.patchPBIArchive-$$"
+	_pbiPatchHeaderFile="${PBI_APPDIR}/.patchPBIHeaderFile-$$"
+
+	# Get the PBI Versions
+	get_ver_from_pbi_file "$_pbiNew"
+	_pbiNewVer="$VAL"
+	get_ver_from_pbi_file "$_pbiOld"
+	_pbiOldVer="$VAL"
+
+	# Get the PBI directory names
+	get_prefix_from_pbi_file "$_pbiNew"
+	_pbiNewPrefix="`basename $VAL`"
+	get_prefix_from_pbi_file "$_pbiOld"
+	_pbiOldPrefix="`basename $VAL`"
+
+	# Sanity check these prefixes
+	if [ "${_pbiNewPrefix}" != "${_pbiOldPrefix}" ] ; then
+		echo "Error: Prefix mismatch between $_pbiNew and $_pbiOld"
+		return
+	fi
+
+	# Make our extraction directories
+	if [ -e "$_pbiNewDir" ] ; then rm -rf "$_pbiNewDir"; fi
+	if [ -e "$_pbiOldDir" ] ; then rm -rf "$_pbiOldDir"; fi
+	if [ -e "$_pbiPatchDir" ] ; then rm -rf "$_pbiPatchDir"; fi
+	mkdir -p "$_pbiNewDir"
+	mkdir -p "$_pbiOldDir"
+	mkdir -p "$_pbiPatchDir"
+
+	# Extract the two PBIs
+	echo "Extracting PBI: $_pbiNew"
+	pbi_add -e --licagree -o "${_pbiNewDir}" "${_pbiNew}" >/dev/null 2>/dev/null
+	echo "Extracting PBI: $_pbiOld"
+	pbi_add -e --licagree -o "${_pbiOldDir}" "${_pbiOld}" >/dev/null 2>/dev/null
+
+	if [ ! -d "${_pbiNewDir}/${_pbiNewPrefix}" -o ! -d "${_pbiOldDir}/${_pbiOldPrefix}" ] ; then 
+		if [ -d "$_pbiNewDir" ] ; then rm -rf "$_pbiNewDir"; fi
+		if [ -d "$_pbiOldDir" ] ; then rm -rf "$_pbiOldDir"; fi
+		if [ -d "$_pbiPatchDir" ] ; then rm -rf "$_pbiPatchDir"; fi
+		exit_err "Failed Extracting PBIs for comparision!"
+	fi
+
+	# Get a list of files which are removed in the new PBI vs the old
+	gen_rem_list "$_pbiNewDir/$_pbiNewPrefix" "$_pbiOldDir/$_pbiOldPrefix"
+	_rFileList="$VAL"
+	if [ ! -z "$_rFileList" ] ; then
+		echo "Saving removed file list"
+		mv "${_rFileList}" ${_pbiPatchDir}/PBI-rmList
+	fi
+
+	# Get archive of files/dirs which are new to the PBI
+	gen_newfile_list "$_pbiNewDir/$_pbiNewPrefix" "$_pbiOldDir/$_pbiOldPrefix"
+	_nFileList="$VAL"
+	if [ ! -z "$_nFileList" ] ; then
+		echo "Saving new files archive..."
+		tar cvf "$_pbiPatchDir/PBI-newFiles.tar" \
+			-C "$_pbiNewDir/$_pbiNewPrefix" -T "$_nFileList" >/dev/null 2>/dev/null
+		rm "$_nFileList"
+	fi
+
+	# Generate diffs of files which have changed between the two
+	gen_bsdiffs_dirs "$_pbiNewDir/$_pbiNewPrefix" "$_pbiOldDir/$_pbiOldPrefix" "$_pbiPatchDir"
+
+	# Make the file archive
+	if test_tar_lzma ; then _tcmp="J" ; else _tcmp="j" ; fi
+	echo "Creating compressed archive..."
+	tar cv${_tcmp}f "${_pbiPatchArchiveFile}" -C ${_pbiPatchDir} . 2>/dev/null 
+	rm -rf ${_pbiPatchDir} 
+
+	# Make the header file
+	if [ -e "$_pbiPatchHeaderDir" ] ; then rm -rf "$_pbiPatchHeaderDir"; fi
+	mkdir -p "$_pbiPatchHeaderDir"
+	open_header_tmp "/tmp/"
+  	cp ${PBI_HEADER_TMPDIR}/* "$_pbiPatchHeaderDir/"
+
+	# Remove any signatures
+  	rm $_pbiPatchHeaderDir/*.sha1 >/dev/null 2>/dev/null
+
+	# Get the archive checksum
+	sha256 -q "${_pbiPatchArchiveFile}" > "${_pbiPatchHeaderDir}/pbi_archivesum"
+	
+	# Set the tag that this is a patch file
+	echo "${_pbiOldVer}:${_pbiNewVer}" > "${_pbiPatchHeaderDir}/pbi_patchfile"
+	
+	# Sign the files if necessary
+	sign_pbi_files "${_pbiPatchHeaderDir}"
+
+	# Make the header tmpfile
+	tar cv${_tcmp}f "${_pbiPatchHeaderFile}" -C ${_pbiPatchHeaderDir} . 2>/dev/null 
+	rm -rf ${_pbiPatchHeaderDir} 
+	
+	# Make the pbp file
+	get_progname_from_pbi_file "$_pbiNew"
+        _pbilow="`echo ${VAL} | tr '[:upper:]' '[:lower:]' | sed 's| ||g'`"
+        
+        outfile="${_cDir}/${_pbilow}-${_pbiOldVer}_to_${_pbiNewVer}-`uname -m`.pbp"
+        mark1="${_cDir}/.pbimark1.$$"
+        mark2="${_cDir}/.pbimark2.$$"
+        
+        echo "
+${PBI_SS_ICON}" >$mark1
+        echo "
+${PBI_SS_ARCHIVE}" >$mark2
+                
+        # DO IT, DO IT NOW!!!
+        cat ${_pbiPatchHeaderFile} $mark1 ${PBI_PATCH_ICON} $mark2 ${_pbiPatchArchiveFile} > ${outfile}
+        sha256 -q ${outfile} > ${outfile}.sha256
+
+        echo "Created PBP: ${outfile}"
+
+	# Cleanup the archive stuff
+        rm $mark1
+        rm $mark2
+        rm ${_pbiPatchHeaderFile}
+        rm ${_pbiPatchArchiveFile}
+	
+	# Cleanup the directories
+	if [ -e "$_pbiNewDir" ] ; then rm -rf "$_pbiNewDir"; fi
+	if [ -e "$_pbiOldDir" ] ; then rm -rf "$_pbiOldDir"; fi
+}
+
+# Function which compares two directories, and returns a list of files / dirs removed in the new dir
+gen_bsdiffs_dirs() {
+
+	find ${1} | sed "s|^${1}/||g" | sed "s|^${1}||g" >/tmp/.pbi.nDir.$$
+
+	echo "Getting bsdiffs of changed files..."
+
+	while read line
+	do
+		# Make sure this file exists in the new / old dirs
+		if [ -z "$line" ] ; then continue ; fi
+		if [ ! -f "${1}/$line" ] ; then continue ; fi
+		if [ ! -e "${2}/$line" ] ; then continue ; fi
+
+		# Filter out any special files, we don't need diffs of them
+		if [ -L "${1}/$line" ] ; then continue ; fi
+		if [ -p "${1}/$line" ] ; then continue ; fi
+		if [ -S "${1}/$line" ] ; then continue ; fi
+		if [ -d "${1}/$line" ] ; then continue ; fi
+		if [ -b "${1}/$line" ] ; then continue ; fi
+		if [ -c "${1}/$line" ] ; then continue ; fi
+
+		diff -q ${1}/$line ${2}/$line >/dev/null 2>/dev/null
+		if [ $? != 0 ] ; then
+			# These files differ, get a binary patch made of them
+			_tDir="${3}/`dirname $line`"
+			_bName=`basename $line`
+			if [ ! -d "$_tDir" ] ; then mkdir -p "$_tDir" ; fi
+			
+			#echo "Making patch for $line"
+			bsdiff ${2}/${line} ${1}/${line} ${_tDir}/${_bName}.bsdiff
+			if [ "$?" != "0" ] ; then
+				exit_err "Failed creating bsdiff patch for $line"
+			fi
+		fi
+
+	done < /tmp/.pbi.nDir.$$
+
+	# Remove the tmp list files
+	rm /tmp/.pbi.nDir.$$
+}
+
+# Function which compares two directories, and returns a list of files / dirs removed in the new dir
+gen_rem_list() {
+
+	find ${1} | sed "s|^${1}/||g" | sed "s|^${1}||g" >/tmp/.pbi.nDir.$$
+	find ${2} | sed "s|^${2}/||g" | sed "s|^${2}||g" >/tmp/.pbi.oDir.$$
+
+	echo "Finding removed files..."
+
+	_rmList="/tmp/.pbi.rmList.$$"
+	if [ -e "$_rmList" ] ; then rm "$_rmList" ; fi
+
+	while read line
+	do
+		if [ -z "$line" ] ; then continue ; fi
+		grep "^$line" /tmp/.pbi.nDir.$$ >/dev/null 2>/dev/null
+		if [ "$?" != "0" ] ; then
+			#echo "Removed File: $line"
+			echo "$line" >> ${_rmList}
+		fi
+
+	done < /tmp/.pbi.oDir.$$
+
+	# Remove the tmp list files
+	rm /tmp/.pbi.nDir.$$
+	rm /tmp/.pbi.oDir.$$
+
+	if [ -e "$_rmList" ] ; then
+		VAL="$_rmList"
+	else
+		VAL=""
+	fi
+}
+
+# Function which compares two directories, and returns a list of files / dirs added in the new dir
+gen_newfile_list() {
+
+	find ${1} | sed "s|^${1}/||g" | sed "s|^${1}||g" >/tmp/.pbi.nDir.$$
+	find ${2} | sed "s|^${2}/||g" | sed "s|^${2}||g" >/tmp/.pbi.oDir.$$
+
+	echo "Finding new files..."
+
+	_addList="/tmp/.pbi.addList.$$"
+	if [ -e "$_addList" ] ; then rm "$_addList" ; fi
+
+	while read line
+	do
+		# Search for all new files + symlinks to include in tarball
+		if [ -z "$line" ] ; then continue ; fi
+		grep "^$line" /tmp/.pbi.oDir.$$ >/dev/null 2>/dev/null
+		if [ "$?" != "0" -o -L "${1}/$line" ] ; then
+			#echo "New File: $line"
+			echo "./$line" >> ${_addList}
+		fi
+
+	done < /tmp/.pbi.nDir.$$
+
+	# Remove the tmp list files
+	rm /tmp/.pbi.nDir.$$
+	rm /tmp/.pbi.oDir.$$
+
+	if [ -e "$_addList" ] ; then
+		VAL="$_addList"
+	else
+		VAL=""
+	fi
+}
+
+# Read the version from a PBI file
+get_ver_from_pbi_file() 
+{
+	VAL="`pbi_add -i $1 | grep Version: | cut -d ':' -f 2 | tr -d ' '`"
+	export VAL
+}
+
+# Read the version from a PBI file
+get_progname_from_pbi_file() 
+{
+	VAL="`pbi_add -i $1 | grep Name: | cut -d ':' -f 2 | tr -d ' '`"
+	export VAL
+}
+
+get_prefix_from_pbi_file()
+{
+	VAL="`pbi_add -i $1 | grep Prefix: | cut -d ':' -f 2 | tr -d ' '`"
+	export VAL
+}
+
 # Move old PBIs to the archive
 archive_old_pbis()
 {
@@ -2979,9 +3431,19 @@
 	fi
 }
 
+# If the loaded file is a PBI PatchFile
+is_pbi_patch() {
+	if [ -z "$PBI_PATCHVERSION" ] ; then
+		return 1
+	else
+		return 0
+	fi
+}
+
 # Main program operation
 ##############################################################
 init_vars
+require_root
 mk_required_dirs
 load_pbi_etcconf
 
@@ -2995,6 +3457,8 @@
    pbi_delete) pbi_delete_init "$@" ;;
    pbi_info) pbi_info_init "$@" ;;
    pbi_makeport) pbi_make_init "$@" ;;
+   pbi_makepatch) pbi_makepatch_init "$@" ;;
+   pbi_patch) pbi_patch_init "$@" ;;
    pbi_update) pbi_update_init "$@" ;;
    pbi-crashhandler) pbi_crash_init "$@" ;;
    *) echo "Error: Called with invalid basename!" ; exit 1 ;;

Modified: pcbsd/current/src-qt4/pbi-manager/port-files/Makefile
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/port-files/Makefile	2010-09-15 14:52:41 UTC (rev 7562)
+++ pcbsd/current/src-qt4/pbi-manager/port-files/Makefile	2010-09-15 17:49:05 UTC (rev 7563)
@@ -20,7 +20,8 @@
 USE_BZIP2=	yes
 NO_BUILD=	yes
 
-MAN1=		pbi_autobuild.1 pbi_add.1 pbi_create.1 pbi_delete.1 pbi_info.1 pbi_makeport.1 pbi.conf.1
+MAN1=		pbi_autobuild.1 pbi_add.1 pbi_create.1 pbi_delete.1 pbi_info.1 \
+		pbi_patch.1 pbi_makeport.1 pbi_makepatch.1 pbi.conf.1
 
 do-install:
 	cd ${WRKSRC} && ./install.sh ${LOCALBASE}

Modified: pcbsd/current/src-qt4/pbi-manager/port-files/pkg-plist
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/port-files/pkg-plist	2010-09-15 14:52:41 UTC (rev 7562)
+++ pcbsd/current/src-qt4/pbi-manager/port-files/pkg-plist	2010-09-15 17:49:05 UTC (rev 7563)
@@ -4,8 +4,10 @@
 sbin/pbi_create
 sbin/pbi_delete
 sbin/pbi_info
+sbin/pbi_makepatch
 sbin/pbi_makeport
 sbin/pbi_update
+sbin/pbi_patch
 etc/pbi.conf
 %%DATADIR%%/module-examples/gimp/xdg-menu/gimp.desktop
 %%DATADIR%%/module-examples/gimp/xdg-mime/gimp-xdg.png
@@ -36,6 +38,7 @@
 %%DATADIR%%/module-examples/firefox/external-links
 %%DATADIR%%/module-examples/firefox/pbi.conf
 %%DATADIR%%/icons/default.png
+%%DATADIR%%/icons/patch.png
 @dirrm %%DATADIR%%/module-examples/firefox/resources
 @dirrm %%DATADIR%%/module-examples/firefox/scripts
 @dirrm %%DATADIR%%/module-examples/firefox/xdg-desktop



More information about the Commits mailing list