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

svn at pcbsd.org svn at pcbsd.org
Fri Sep 17 08:11:23 PDT 2010


Author: kris
Date: 2010-09-17 08:11:23 -0700 (Fri, 17 Sep 2010)
New Revision: 7588

Added:
   pcbsd/current/src-qt4/pbi-manager/man/pbi_icon.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_icon command, which lets the user easily add/remove desktop/menu/mime xdg stuff
after a PBI has been installed



Modified: pcbsd/current/src-qt4/pbi-manager/install.sh
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/install.sh	2010-09-17 14:03:01 UTC (rev 7587)
+++ pcbsd/current/src-qt4/pbi-manager/install.sh	2010-09-17 15:11:23 UTC (rev 7588)
@@ -20,6 +20,7 @@
 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_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

Modified: pcbsd/current/src-qt4/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/pbi-manager	2010-09-17 14:03:01 UTC (rev 7587)
+++ pcbsd/current/src-qt4/pbi-manager/pbi-manager	2010-09-17 15:11:23 UTC (rev 7588)
@@ -118,6 +118,22 @@
         exit_trap
 }
 
+usage_icon_pbi() {
+        cat <<EOF
+usage: `basename $0` [options] pbi
+
+Options:
+  add-desktop          -- Add desktop icons
+  add-menu             -- Add menu icons (Needs root)
+  add-mime             -- Add mime registration (Needs root)
+  del-desktop          -- Remove desktop icons
+  del-menu             -- Remove menu icons (Needs root)
+  del-mime             -- Remove mime registration (Needs root)
+
+EOF
+        exit_trap
+}
+
 usage_info_pbi() {
         cat <<EOF
 usage: `basename $0` [options] pbi
@@ -195,6 +211,30 @@
 	if [ -z "${PBI_DELETENAME}" ];then usage_delete_pbi; fi
 }
 
+# Parse the command line for icon
+parse_icon_pbi_cmdline() {
+        while [ $# -gt 0 ]; do
+                case "$1" in
+                add-desktop)	PBI_DESKADD="YES" ;;
+                add-menu)	PBI_MENUADD="YES" ;;
+                add-mime)	PBI_MIMEADD="YES" ;;
+                del-desktop)	PBI_DESKDEL="YES" ;;
+                del-menu)	PBI_MENUDEL="YES" ;;
+                del-mime)	PBI_MIMEDEL="YES" ;;
+                 *)
+                        if [ $# -gt 1 ]; then usage_icon_pbi; fi
+			if [ ! -e "${PBI_DBDIR}/${1}" ] ; then
+                                exit_err "can't find installed pbi (${1})"
+                        fi
+                        PBI_ICONTARGETAPP="$1"
+                        ;;
+                esac
+                shift
+        done
+	if [ -z "${PBI_ICONTARGETAPP}" ] ; then 
+		usage_icon_pbi
+	fi
+}
 
 # Parse the command line for info
 parse_info_pbi_cmdline() {
@@ -592,9 +632,9 @@
 
 # Make some of our required PBI dirs
 mk_required_dirs() {
-	if [ ! -d "${PBI_APPDIR}" ] ; then mkdir -p ${PBI_APPDIR} ; fi
-	if [ ! -d "${PBI_RCDIR}" ] ; then mkdir -p ${PBI_RCDIR} ; fi
-	if [ ! -d "${PBI_HASHDIR}" ] ; then mkdir -p ${PBI_HASHDIR} ; fi
+	if [ ! -d "${PBI_APPDIR}" ] ; then mkdir -p ${PBI_APPDIR} >/dev/null 2>/dev/null ; fi
+	if [ ! -d "${PBI_RCDIR}" ] ; then mkdir -p ${PBI_RCDIR} >/dev/null 2>/dev/null ; fi
+	if [ ! -d "${PBI_HASHDIR}" ] ; then mkdir -p ${PBI_HASHDIR} >/dev/null 2>/dev/null ; fi
 }
 
 # Get the absolute path of a dir
@@ -647,6 +687,12 @@
 	PBI_APPDESK_DIR=".${MOD_XDGDESK_DIR}"
 	PBI_APPMENU_DIR=".${MOD_XDGMENU_DIR}"
 	PBI_APPMIME_DIR=".${MOD_XDGMIME_DIR}"
+	PBI_DESKADD="NO"
+	PBI_MENUADD="NO"
+	PBI_MIMEADD="NO"
+	PBI_DESKDEL="NO"
+	PBI_MENUDEL="NO"
+	PBI_MIMEDEL="NO"
 	PBI_DELETENAME=""
 	PBI_FAKEBIN_DIR=".sbin"
 	PBI_FILENAME=""
@@ -1207,7 +1253,7 @@
         open_header_tmp
         if [ -f "${PBI_HEADER_TMPDIR}/${PBI_LICENSEFILE}" -a "${PBI_LICAGREE}" = "NO" ] ; then
         	delete_header_tmp
-		exit_err "LICENSE must be accepted before this PBI can be installed."
+		exit_err "LICENSE must be agreed to (--licagree) before this PBI can be installed."
         fi
         delete_header_tmp
 }
@@ -1266,6 +1312,18 @@
   	        1) echo "Signature: Bad" ;;
 		*) echo "Signature: <Unknown>" ;;
 	esac
+
+	# See if we have any XDG stuff
+	if [ -e "${PBI_ORIGPROGDIRPATH}/.xdg-desktop/install-desktop-icons.sh" ] ; then
+		echo "DesktopIcons: YES"
+	fi
+	if [ -e "${PBI_ORIGPROGDIRPATH}/.xdg-menu/install-menu-icons.sh" ] ; then
+		echo "MenuIcons: YES"
+	fi
+	if [ -e "${PBI_ORIGPROGDIRPATH}/.xdg-mime/install-mime.sh" ] ; then
+		echo "MimeRegistration: YES"
+	fi
+
 }
 
 # See if we need to display gui header info
@@ -1971,6 +2029,7 @@
 # Create any XDG script for desktop icons
 mk_xdg_desktop_script() {
   	if [ ! -d "${PBI_CONFDIR}/${MOD_XDGDESK_DIR}" ] ; then return 0 ; fi
+	_dFound=0
 
 	dir="${PBI_STAGEDIR}/${PBI_APPDESK_DIR}"
 	if [ ! -d "${dir}" ] ; then mkdir -p "${dir}" ; fi
@@ -1980,12 +2039,13 @@
   	cd "${PBI_CONFDIR}/${MOD_XDGDESK_DIR}"
   	for i in `ls *.desktop 2>/dev/null`
   	do
+		_dFound=1
+
 		# Copy over the .desktop file, modifying any variables within
 	        cat "${i}" \
            	| sed "s|%%PBI_EXEDIR%%|$PBI_PROGDIRPATH/$PBI_FAKEBIN_DIR|g" \
 		| sed "s|%%PBI_APPDIR%%|$PBI_PROGDIRPATH|g" \
 		> "${dir}/PBI-${i}"
-		#cp "${i}" "${dir}/PBI-${i}"
 
 		ifi="$PBI_PROGDIRPATH/${PBI_APPDESK_DIR}/PBI-${i}"
 
@@ -1998,12 +2058,20 @@
 
 	chmod 755 "${dir}/${PBI_INS_DESKSCRIPT}"
 	chmod 755 "${dir}/${PBI_UNINS_DESKSCRIPT}"
+
+	# No desktop entries
+        if [ "$_dFound" = "0" ] ; then
+                rm "${dir}/${PBI_INS_DESKSCRIPT}"
+                rm "${dir}/${PBI_UNINS_DESKSCRIPT}"
+        fi
 }
 
 # Create any XDG script for menu icons
 mk_xdg_menu_script() {
   	if [ ! -d "${PBI_CONFDIR}/${MOD_XDGMENU_DIR}" ] ; then return 0 ; fi
 
+	_mFound=0
+
 	dir="${PBI_STAGEDIR}/${PBI_APPMENU_DIR}"
         if [ ! -d "${dir}" ] ; then mkdir -p "${dir}" ; fi
         echo "#!/bin/sh" >"${dir}/${PBI_INS_MENUSCRIPT}"
@@ -2012,6 +2080,8 @@
   	cd "${PBI_CONFDIR}/${MOD_XDGMENU_DIR}"
   	for i in `ls *.desktop 2>/dev/null`
   	do
+		_mFound=1
+
 		# Copy the desktop file, changing any included vars
 	        cat "${i}" \
            	| sed "s|%%PBI_EXEDIR%%|$PBI_PROGDIRPATH/$PBI_FAKEBIN_DIR|g" \
@@ -2041,11 +2111,18 @@
 
 	chmod 755 "${dir}/${PBI_INS_MENUSCRIPT}"
 	chmod 755 "${dir}/${PBI_UNINS_MENUSCRIPT}"
+
+	# No mime entries
+        if [ "$_mFound" = "0" ] ; then
+                rm "${dir}/${PBI_INS_MENUSCRIPT}"
+                rm "${dir}/${PBI_UNINS_MENUSCRIPT}"
+        fi
 }
 
 # Create any XDG script for mime types
 mk_xdg_mime_script() {
   	if [ ! -d "${PBI_CONFDIR}/${MOD_XDGMIME_DIR}" ] ; then return 0 ; fi
+	_mFound=0
 
         dir="${PBI_STAGEDIR}/${PBI_APPMIME_DIR}"
         if [ ! -d "${dir}" ] ; then mkdir -p "${dir}" ; fi
@@ -2056,6 +2133,7 @@
   	cd "${PBI_CONFDIR}/${MOD_XDGMIME_DIR}"
   	for i in `ls *.xml 2>/dev/null`
   	do
+		_mFound=1
 		cp "${i}" "${dir}/PBI-${i}"
 		ifi="$PBI_PROGDIRPATH/${PBI_APPMIME_DIR}/PBI-${i}"
 
@@ -2080,6 +2158,12 @@
 
 	chmod 755 "${dir}/${PBI_INS_MIMESCRIPT}"
 	chmod 755 "${dir}/${PBI_UNINS_MIMESCRIPT}"
+
+	# No mime entries
+	if [ "$_mFound" = "0" ] ; then
+		rm "${dir}/${PBI_INS_MIMESCRIPT}"
+		rm "${dir}/${PBI_UNINS_MIMESCRIPT}"
+	fi
 }
 
 
@@ -2481,6 +2565,59 @@
        	sh "${PBI_DBDIR}/${PBI_DELETENAME}/${MOD_PREREM}"
 }
 
+pbi_icon_init() {
+	parse_icon_pbi_cmdline "$@"
+	
+	do_pbi_icon
+}
+
+# Start the PBI icon process
+do_pbi_icon() {
+	# Get the dir for this PBI
+	_appDir=`cat ${PBI_DBDIR}/${PBI_ICONTARGETAPP}/pbi_installedpath`
+
+	if [ "${PBI_DESKADD}" = "YES" ] ; then
+		if [ ! -e "${_appDir}/.xdg-desktop/${PBI_INS_DESKSCRIPT}" ] ; then 
+			exit_err "No desktop icons for this PBI"
+		fi
+		sh "${_appDir}/.xdg-desktop/${PBI_INS_DESKSCRIPT}"
+	fi
+	if [ "${PBI_DESKDEL}" = "YES" ] ; then
+		if [ ! -e "${_appDir}/.xdg-desktop/${PBI_UNINS_DESKSCRIPT}" ] ; then 
+			exit_err "No desktop icons for this PBI"
+		fi
+		sh "${_appDir}/.xdg-desktop/${PBI_UNINS_DESKSCRIPT}"
+	fi
+	if [ "${PBI_MENUADD}" = "YES" ] ; then
+		require_root
+		if [ ! -e "${_appDir}/.xdg-menu/${PBI_INS_MENUSCRIPT}" ] ; then 
+			exit_err "No menu icons for this PBI"
+		fi
+		sh "${_appDir}/.xdg-menu/${PBI_INS_MENUSCRIPT}"
+	fi
+	if [ "${PBI_MENUDEL}" = "YES" ] ; then
+		require_root
+		if [ ! -e "${_appDir}/.xdg-menu/${PBI_UNINS_MENUSCRIPT}" ] ; then 
+			exit_err "No menu icons for this PBI"
+		fi
+		sh "${_appDir}/.xdg-menu/${PBI_UNINS_MENUSCRIPT}"
+	fi
+	if [ "${PBI_MIMEADD}" = "YES" ] ; then
+		require_root
+		if [ ! -e "${_appDir}/.xdg-mime/${PBI_INS_MIMESCRIPT}" ] ; then 
+			exit_err "No mime registration for this PBI"
+		fi
+		sh "${_appDir}/.xdg-mime/${PBI_INS_MIMESCRIPT}"
+	fi
+	if [ "${PBI_MIMEDEL}" = "YES" ] ; then
+		require_root
+		if [ ! -e "${_appDir}/.xdg-mime/${PBI_UNINS_MIMESCRIPT}" ] ; then 
+			exit_err "No mime registration for this PBI"
+		fi
+		sh "${_appDir}/.xdg-mime/${PBI_UNINS_MIMESCRIPT}"
+	fi
+}
+
 pbi_info_init() {
 	parse_info_pbi_cmdline "$@"
 	
@@ -3730,6 +3867,7 @@
    pbi_autobuild) pbi_autob_init "$@" ;;
    pbi_create) pbi_create_init "$@" ;;
    pbi_delete) pbi_delete_init "$@" ;;
+   pbi_icon) pbi_icon_init "$@" ;;
    pbi_info) pbi_info_init "$@" ;;
    pbi_makeport) pbi_make_init "$@" ;;
    pbi_makepatch) pbi_makepatch_init "$@" ;;

Modified: pcbsd/current/src-qt4/pbi-manager/port-files/Makefile
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/port-files/Makefile	2010-09-17 14:03:01 UTC (rev 7587)
+++ pcbsd/current/src-qt4/pbi-manager/port-files/Makefile	2010-09-17 15:11:23 UTC (rev 7588)
@@ -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 \
+MAN1=		pbi_autobuild.1 pbi_add.1 pbi_create.1 pbi_delete.1 \
+		pbi_icon.1 pbi_info.1 \
 		pbi_patch.1 pbi_makeport.1 pbi_makepatch.1 pbi.conf.1
 
 do-install:

Modified: pcbsd/current/src-qt4/pbi-manager/port-files/pkg-plist
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/port-files/pkg-plist	2010-09-17 14:03:01 UTC (rev 7587)
+++ pcbsd/current/src-qt4/pbi-manager/port-files/pkg-plist	2010-09-17 15:11:23 UTC (rev 7588)
@@ -3,6 +3,7 @@
 sbin/pbi_autobuild
 sbin/pbi_create
 sbin/pbi_delete
+sbin/pbi_icon
 sbin/pbi_info
 sbin/pbi_makepatch
 sbin/pbi_makeport



More information about the Commits mailing list