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

svn at pcbsd.org svn at pcbsd.org
Wed Nov 17 10:29:31 PST 2010


Author: kris
Date: 2010-11-17 10:29:31 -0800 (Wed, 17 Nov 2010)
New Revision: 8039

Added:
   pcbsd/current/src-sh/pbi-manager/man/pbi_addrepo.1
   pcbsd/current/src-sh/pbi-manager/man/pbi_deleterepo.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:

Updated pbi-manager, added pbi_addrepo and pbi_deleterepo to list of commands, which
will allow the user to add / remove new repositories created with pbi_makerepo. 



Modified: pcbsd/current/src-sh/pbi-manager/install.sh
===================================================================
--- pcbsd/current/src-sh/pbi-manager/install.sh	2010-11-17 16:41:02 UTC (rev 8038)
+++ pcbsd/current/src-sh/pbi-manager/install.sh	2010-11-17 18:29:31 UTC (rev 8039)
@@ -16,11 +16,14 @@
 mkdir ${LB}/sbin >/dev/null 2>/dev/null
 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_addrepo
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_autobuild
+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

Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-17 16:41:02 UTC (rev 8038)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-17 18:29:31 UTC (rev 8039)
@@ -161,6 +161,22 @@
         exit_trap
 }
 
+usage_addrepo_pbi() {
+        cat <<EOF
+usage: `basename $0` <Repo File>
+                
+EOF
+        exit_trap
+}
+
+usage_deleterepo_pbi() {
+        cat <<EOF
+usage: `basename $0` <Repo ID>
+                
+EOF
+        exit_trap
+}
+
 usage_makerepo_pbi() {
         cat <<EOF
 usage: `basename $0` [options] [outdir]
@@ -315,6 +331,42 @@
         load_info_from_header
 }
 
+# Parse the command line for adding a new repo file
+parse_addrepo_pbi_cmdline() {
+        while [ $# -gt 0 ]; do
+                case "$1" in
+                 *)	if [ $# -gt 1  ]; then usage_addrepo_pbi; fi
+                       	PBI_ADDREPO_FILE="$1"
+                        ;;
+                esac
+                shift
+        done
+
+	if [ -z "$PBI_ADDREPO_FILE" ] ; then 
+		usage_addrepo_pbi
+	fi
+	if [ ! -f "$PBI_ADDREPO_FILE" ] ; then 
+		exit_err "Repo file ${PBI_ADDREPO_FILE} does not exist!"
+	fi
+}
+
+# Parse the command line for deleting a repo
+parse_deleterepo_pbi_cmdline() {
+        while [ $# -gt 0 ]; do
+                case "$1" in
+                 *)	if [ $# -gt 1  ]; then usage_deleterepo_pbi; fi
+                       	PBI_DELREPO_ID="$1"
+                        ;;
+                esac
+                shift
+        done
+
+	if [ -z "$PBI_DELREPO_ID" ] ; then 
+		usage_deleterepo_pbi
+	fi
+}
+
+
 # Parse the command line for making a new repo file
 parse_makerepo_pbi_cmdline() {
         while [ $# -gt 0 ]; do
@@ -717,6 +769,7 @@
 	if [ ! -d "${PBI_DBAPPDIR}" ] ; then mkdir -p ${PBI_DBAPPDIR} >/dev/null 2>/dev/null ; fi
 	if [ ! -d "${PBI_DBKEYDIR}" ] ; then mkdir -p ${PBI_DBKEYDIR} >/dev/null 2>/dev/null ; fi
 	if [ ! -d "${PBI_DBINDEXDIR}" ] ; then mkdir -p ${PBI_DBINDEXDIR} >/dev/null 2>/dev/null ; fi
+	if [ ! -d "${PBI_DBREPODIR}" ] ; then mkdir -p ${PBI_DBREPODIR} >/dev/null 2>/dev/null ; fi
 	if [ ! -d "${PBI_DBHASHQUEUEDIR}" ] ; then mkdir -p ${PBI_DBHASHQUEUEDIR} >/dev/null 2>/dev/null ; fi
 }
 
@@ -840,6 +893,7 @@
 	PBI_DBHASHQUEUEDIR="${PBI_DBDIR}/.hashqueue"
 	PBI_DBINDEXDIR="${PBI_DBDIR}/index"
 	PBI_DBKEYDIR="${PBI_DBDIR}/keys"
+	PBI_DBREPODIR="${PBI_DBDIR}/repos"
 	PBI_DISABLEHASHDIR="NO"
 	PBI_GUITOPBANNER="gui_banner.png"
 	PBI_GUISIDEBANNER="gui_sidebanner.png"
@@ -1095,6 +1149,114 @@
 	make_pbi_patchfile "${PBI_FILENAME}" "${PBI_OLDFILENAME}" "${PBI_PATCHOUTDIR}"
 }
 
+# Remove a repo from the DB
+pbi_deleterepo_init() {
+  	require_root
+	parse_deleterepo_pbi_cmdline "$@"
+
+	delete_pbi_repo
+}
+
+# Do the removal of a PBI repo
+delete_pbi_repo() {
+	# Make sure this repo exists
+	ls ${PBI_DBREPODIR}/${PBI_DELREPO_ID}.* >/dev/null 2>/dev/null
+	if [ "$?" != "0" ] ; then
+		exit_err "No such repo ID: ${PBI_DELREPO_ID}"
+	fi
+	
+	_md5=`ls ${PBI_DBREPODIR}/${PBI_DELREPO_ID}.* | sed "s|^${PBI_DBREPODIR}/${PBI_DELREPO_ID}.||g"`
+	if [ -e "${PBI_DBREPODIR}/${PBI_DELREPO_ID}.${_md5}" ] ; then
+		rm "${PBI_DBREPODIR}/${PBI_DELREPO_ID}.${_md5}"
+	else
+		echo "Warning: ${PBI_DELREPO_ID}.${_md5} does not exist in the database."
+	fi
+	if [ -e "${PBI_DBKEYDIR}/${_md5}.ssl" ] ; then
+		rm "${PBI_DBKEYDIR}/${_md5}.ssl"
+	else
+		echo "Warning: ${_md5}.ssl does not exist in the keys database."
+	fi
+
+	# Make sure we renumber the repos
+	renumber_repos
+
+	echo "Deleted Repository ${PBI_DELREPO_ID}."
+
+}
+
+# After deleting a repo, this can be run to renumber the IDs
+renumber_repos() {
+	_rNum="1"
+	for i in `ls ${PBI_DBREPODIR} | sort`
+	do
+		case `echo ${_rNum} | wc -m | tr -d ' '` in
+			2) _rNum="00${_rNum}" ;;
+			3) _rNum="0${_rNum}" ;;
+			*) ;;
+		esac
+
+		_md5=`echo ${i} | cut -d '.' -f 2`
+		mv "${PBI_DBREPODIR}/${i}" "${PBI_DBREPODIR}/${_rNum}.${_md5}"
+
+		_rNum=`expr ${_rNum} + 1`
+	done
+}
+
+# Add a new repo to the db
+pbi_addrepo_init() {
+  	require_root
+	parse_addrepo_pbi_cmdline "$@"
+
+	# Create a new repo file
+	add_pbi_repo
+}
+
+# Extract the repo and add it to the DB
+add_pbi_repo() {
+	init_tmpdir
+	tar xvf "${PBI_ADDREPO_FILE}" -C ${PBI_TMPDIR} >/dev/null 2>/dev/null
+	if [ "$?" != "0" ] ; then
+		exit_err "Failed to read ${PBI_ADDREPO_FILE}"
+	fi
+	if [ ! -f "${PBI_TMPDIR}/repokey.ssl" -o ! -f "${PBI_TMPDIR}/repo-url" -o ! -f "${PBI_TMPDIR}/repo-desc" ] ; then
+		exit_err "Improperly packaged repo file!"
+	fi
+
+	# Figure out the next repo number
+	get_next_repo_num
+
+	_md5=`md5 -q ${PBI_TMPDIR}/repo-url`
+	_url=`cat ${PBI_TMPDIR}/repo-url`
+	_desc=`cat ${PBI_TMPDIR}/repo-desc`
+	echo "URL: ${_url}" > ${PBI_DBREPODIR}/${_rNum}.${_md5}
+	echo "Desc: ${_desc}" >> ${PBI_DBREPODIR}/${_rNum}.${_md5}
+	cp "${PBI_TMPDIR}/repokey.ssl" "${PBI_DBKEYDIR}/${_md5}.ssl"
+	
+	rm_tmpdir
+
+	echo "Added new repo: \"${_desc}\" to the database."
+
+}
+
+# Function to do listing of installed repos, and return next available number
+get_next_repo_num() {
+	_rNum="0"
+	for i in `ls ${PBI_DBREPODIR} | sort`
+	do
+		_rNum=`expr ${_rNum} + 1`
+	done
+
+	_rNum=`expr ${_rNum} + 1`
+
+	case `echo ${_rNum} | wc -m | tr -d ' '` in
+		2) _rNum="00${_rNum}" ;;
+		3) _rNum="0${_rNum}" ;;
+		*) ;;
+	esac
+
+	export _rNum
+}
+
 # Start the make patch process
 pbi_makerepo_init() {
   	require_root
@@ -4289,8 +4451,10 @@
 # Figure out which mode we are running in
 case `basename ${0}` in
    pbi_add) pbi_add_init "$@" ;;
+   pbi_addrepo) pbi_addrepo_init "$@" ;;
    pbi_autobuild) pbi_autob_init "$@" ;;
    pbi_create) pbi_create_init "$@" ;;
+   pbi_deleterepo) pbi_deleterepo_init "$@" ;;
    pbi_delete) pbi_delete_init "$@" ;;
    pbi_icon) pbi_icon_init "$@" ;;
    pbi_info) pbi_info_init "$@" ;;

Modified: pcbsd/current/src-sh/pbi-manager/port-files/Makefile
===================================================================
--- pcbsd/current/src-sh/pbi-manager/port-files/Makefile	2010-11-17 16:41:02 UTC (rev 8038)
+++ pcbsd/current/src-sh/pbi-manager/port-files/Makefile	2010-11-17 18:29:31 UTC (rev 8039)
@@ -20,7 +20,7 @@
 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_icon.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-17 16:41:02 UTC (rev 8038)
+++ pcbsd/current/src-sh/pbi-manager/port-files/pkg-plist	2010-11-17 18:29:31 UTC (rev 8039)
@@ -1,10 +1,12 @@
 bin/pbi-crashhandler
 sbin/pbi_add
+sbin/pbi_addrepo
 sbin/pbi_autobuild
 sbin/pbi_create
-sbin/pbi_delete
+sbin/pbi_deleterepo
 sbin/pbi_icon
 sbin/pbi_info
+sbin/pbi_listrepo
 sbin/pbi_makepatch
 sbin/pbi_makeport
 sbin/pbi_makerepo



More information about the Commits mailing list