[PC-BSD Commits] r8048 - in pcbsd/current/src-sh/pbi-manager: . man port-files

svn at pcbsd.org svn at pcbsd.org
Fri Nov 19 10:56:51 PST 2010


Author: kris
Date: 2010-11-19 10:56:51 -0800 (Fri, 19 Nov 2010)
New Revision: 8048

Added:
   pcbsd/current/src-sh/pbi-manager/man/pbi_indextool.1
Modified:
   pcbsd/current/src-sh/pbi-manager/install.sh
   pcbsd/current/src-sh/pbi-manager/pbi-manager
   pcbsd/current/src-sh/pbi-manager/port-files/Makefile
   pcbsd/current/src-sh/pbi-manager/port-files/pkg-plist
Log:

Added pbi_indextool to pbi-manager, which allows us to add / remove PBIs from 
a repository INDEX file without needing to hand-edit the file



Modified: pcbsd/current/src-sh/pbi-manager/install.sh
===================================================================
--- pcbsd/current/src-sh/pbi-manager/install.sh	2010-11-19 16:34:57 UTC (rev 8047)
+++ pcbsd/current/src-sh/pbi-manager/install.sh	2010-11-19 18:56:51 UTC (rev 8048)
@@ -18,14 +18,15 @@
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_add
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_addrepo
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_autobuild
+ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_delete
+ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_deleterepo
+ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_icon
+ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_info
+ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_indextool
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_listrepo
 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_makerepo
-ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_delete
-ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_deleterepo
-ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_icon
-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/pbid

Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-19 16:34:57 UTC (rev 8047)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-19 18:56:51 UTC (rev 8048)
@@ -178,6 +178,47 @@
         exit_trap
 }
 
+usage_it_add() {
+        cat <<EOF
+usage: `basename $0` add [options] indexfile
+                
+Options:
+  -b vers   	-- Mark previous versions as having binary diff patches available
+		   I.E. (2.7.3,2.8.1,2.8.2)
+  -f pbifile   	-- The PBI file we are adding to the index (Required)
+  -k num   	-- The number of previous versions of this PBI to keep in the index
+  -u fileurl   	-- The URL to this PBI on the mirror server(s) (Required)
+
+EOF
+	exit_trap
+}
+
+usage_it_rem() {
+        cat <<EOF
+usage: `basename $0` rem [options] indexfile
+                
+Options:
+  -m arch   	-- The PBI architecture to remove (Required)
+		   I.E. (i386,amd64,etc)
+  -n pbiname   	-- The PBI name we are removing from the index (Required)
+  -v version   	-- The version of the PBI to remove (Required) 
+
+EOF
+	exit_trap
+}
+
+usage_it_unknown() {
+        cat <<EOF
+usage: `basename $0` [options] indexfile
+                
+Options:
+  add   	-- Add a new entry to the specified indexfile
+  rem    	-- Remove an entry in the indexfile
+
+EOF
+	exit_trap
+}
+
 usage_listrepo_pbi() {
         cat <<EOF
 usage: `basename $0` [options] [repoid]
@@ -345,6 +386,81 @@
         load_info_from_header
 }
 
+# Parse the command line for editing a index file
+parse_it_pbi_cmdline() {
+
+	case $1 in
+  	   add)	PBI_IT_MODE="ADD" ; shift ; 
+		while [ $# -gt 0 ]; do
+                	case "$1" in
+          		-b) if [ $# -eq 1  ]; then usage_it_add; fi
+                       	    shift; PBI_IT_ADDBPVERS="$1"
+			    ;;
+          		-f) if [ $# -eq 1  ]; then usage_it_add; fi
+                       	    shift; PBI_IT_ADDFILE="$1"
+			    ;;
+          		-k) if [ $# -eq 1  ]; then usage_it_add; fi
+                       	    shift; PBI_IT_ADDKEEP="$1"
+			    ;;
+          		-u) if [ $# -eq 1  ]; then usage_it_add; fi
+                       	    shift; PBI_IT_ADDURL="$1"
+			    ;;
+                         *) if [ $# -gt 1  ]; then usage_it_add; fi
+                       	    PBI_IT_ADDINDEX="$1"
+                            ;;
+                	esac
+                	shift
+ 	       	done
+	  	;;
+  	   rem)	PBI_IT_MODE="REM" ; shift ; 
+		while [ $# -gt 0 ]; do
+                	case "$1" in
+          		-m) if [ $# -eq 1  ]; then usage_it_rem; fi
+                       	    shift; PBI_IT_REMARCH="$1"
+			    ;;
+          		-n) if [ $# -eq 1  ]; then usage_it_rem; fi
+                       	    shift; PBI_IT_REMNAME="$1"
+			    ;;
+          		-v) if [ $# -eq 1  ]; then usage_it_rem; fi
+                       	    shift; PBI_IT_REMVER="$1"
+			    ;;
+                         *) if [ $# -gt 1  ]; then usage_it_rem; fi
+                       	    PBI_IT_REMINDEX="$1"
+                            ;;
+			esac
+			shift
+		done
+		;;
+  	     *) usage_it_unknown ;;
+	esac
+
+	# Sanity check the values
+	case ${PBI_IT_MODE} in
+		ADD) if [ -z "${PBI_IT_ADDFILE}" ] ; then usage_it_add ; fi
+		     if [ -z "${PBI_IT_ADDURL}" ] ; then usage_it_add ; fi
+		     if [ -z "${PBI_IT_ADDINDEX}" ] ; then usage_it_add ; fi
+		     if [ ! -f "${PBI_IT_ADDFILE}" ] ; then 
+			exit_err "No such file ${PBI_IT_ADDFILE}"
+		     fi
+		     if [ ! -f "${PBI_IT_ADDINDEX}" ] ; then 
+			exit_err "No such file ${PBI_IT_ADDFILE}"
+		     fi
+		     if [ ! -z "${PBI_IT_ADDKEEP}" ] ; then 
+			expr ${PBI_IT_ADDKEEP} + 1 >/dev/null 2>/dev/null
+			if [ "$?" != "0" ] ; then
+				exit_err "-k option must be a integer!"
+			fi
+		     fi
+		;;
+		REM) if [ -z "${PBI_IT_REMNAME}" ] ; then usage_it_rem ; fi
+		     if [ -z "${PBI_IT_REMVER}" ] ; then usage_it_rem ; fi
+		     if [ -z "${PBI_IT_REMARCH}" ] ; then usage_it_rem ; fi
+		     if [ -z "${PBI_IT_REMINDEX}" ] ; then usage_it_rem ; fi
+		;;
+	esac
+
+}
+
 # Parse the command line for adding a new repo file
 parse_listrepo_pbi_cmdline() {
         while [ $# -gt 0 ]; do
@@ -1368,6 +1484,76 @@
 	rm_tmpdir
 }
 
+# Init the indextool
+pbi_it_init() {
+	parse_it_pbi_cmdline "$@"
+	case $PBI_IT_MODE in
+		ADD) do_pbi_it_add ;; 
+		REM) do_pbi_it_rem ;; 
+		  *) ;;
+	esac
+}
+
+# Remove a target PBI from an index
+do_pbi_it_rem() {
+	init_tmpdir
+	_pbilow="`echo ${PBI_IT_REMNAME} | tr '[:upper:]' '[:lower:]' | sed 's| ||g'`"
+
+	cat "${PBI_IT_REMINDEX}" | grep -v "${_pbilow}:${PBI_IT_REMARCH}:${PBI_IT_REMVER}" \
+		> "${PBI_TMPDIR}/.indextmp"
+	sort ${PBI_TMPDIR}/.indextmp > "${PBI_IT_REMINDEX}"
+
+	rm_tmpdir
+}
+
+# Add a new PBI to the specified INDEX file
+do_pbi_it_add() {
+	init_tmpdir
+
+	# First load values from the target PBI
+	PBI_FILENAME="$PBI_IT_ADDFILE"
+	load_info_from_header
+
+	# Get the name in lower-case
+	_pbilow="`echo ${PBI_PROGNAME} | tr '[:upper:]' '[:lower:]' | sed 's| ||g'`"
+	
+	# Prune any old copies of this app from the index
+	prune_from_index "$_pbilow" "$PBI_APPARCH"
+	
+	# Add the new index entry
+	add_to_index
+	rm_tmpdir
+}
+
+# Add the specified PBI to the index
+add_to_index() {
+	mv "${PBI_IT_ADDINDEX}" "${PBI_TMPDIR}/.indextmp"
+	local _date=`date '+%s'`
+	echo "${_pbilow}:${PBI_APPARCH}:${PBI_PROGVERSION}:${PBI_ARCHIVE_CHECKSUM}:${PBI_PROGMDATE}:${PBI_IT_ADDURL}:$_date:${PBI_IT_ADDBPVERS}:current" >>"${PBI_TMPDIR}/.indextmp"
+	sort ${PBI_TMPDIR}/.indextmp > "${PBI_IT_ADDINDEX}"
+}
+
+
+# Remove a set number of PBIs from the index
+prune_from_index() {
+	if [ -z "$PBI_IT_ADDKEEP" ]; then return ; fi
+
+	local found="0"
+	while read iLine
+	do
+		echo "$iLine" | grep "${1}:${2}:" >/dev/null 2>/dev/null
+		if [ "$?" != "0" ] ; then
+	 		echo "$iLine" >> ${PBI_TMPDIR}/.indextmp	
+			continue
+		fi
+		if [ $found -lt $PBI_IT_ADDKEEP ] ; then
+	 		echo "$iLine" | sed 's|:current|:active|' >> ${PBI_TMPDIR}/.indextmp	
+			found=`expr $found + 1`
+		fi
+	done < $PBI_IT_ADDINDEX	
+	mv "${PBI_TMPDIR}/.indextmp" "${PBI_IT_ADDINDEX}"
+}
+
 # Add a new repo to the db
 pbi_listrepo_init() {
   	require_root
@@ -4709,6 +4895,7 @@
    pbi_deleterepo) pbi_deleterepo_init "$@" ;;
    pbi_delete) pbi_delete_init "$@" ;;
    pbi_icon) pbi_icon_init "$@" ;;
+   pbi_indextool) pbi_it_init "$@" ;;
    pbi_info) pbi_info_init "$@" ;;
    pbi_listrepo) pbi_listrepo_init "$@" ;;
    pbi_makeport) pbi_make_init "$@" ;;

Modified: pcbsd/current/src-sh/pbi-manager/port-files/Makefile
===================================================================
--- pcbsd/current/src-sh/pbi-manager/port-files/Makefile	2010-11-19 16:34:57 UTC (rev 8047)
+++ pcbsd/current/src-sh/pbi-manager/port-files/Makefile	2010-11-19 18:56:51 UTC (rev 8048)
@@ -20,7 +20,8 @@
 NO_BUILD=	yes
 
 MAN1=		pbi_autobuild.1 pbi_add.1 pbi_create.1 pbi_delete.1 \
-		pbi_icon.1 pbi_info.1 pbid.1 pbi_addrepo.1 pbi_listrepo.1 pbi_deleterepo.1 \
+		pbi_icon.1 pbi_indextool.1 pbi_info.1 pbid.1 pbi_addrepo.1 \
+		pbi_listrepo.1 pbi_deleterepo.1 \
 		pbi_patch.1 pbi_makeport.1 pbi_makepatch.1 pbi_makerepo.1 pbi.conf.1
 
 do-install:

Modified: pcbsd/current/src-sh/pbi-manager/port-files/pkg-plist
===================================================================
--- pcbsd/current/src-sh/pbi-manager/port-files/pkg-plist	2010-11-19 16:34:57 UTC (rev 8047)
+++ pcbsd/current/src-sh/pbi-manager/port-files/pkg-plist	2010-11-19 18:56:51 UTC (rev 8048)
@@ -5,6 +5,7 @@
 sbin/pbi_create
 sbin/pbi_deleterepo
 sbin/pbi_icon
+sbin/pbi_indextool
 sbin/pbi_info
 sbin/pbi_listrepo
 sbin/pbi_makepatch



More information about the Commits mailing list