[rkward-cvs] SF.net SVN: rkward-code:[4720] trunk/rkward/macports

m-eik at users.sf.net m-eik at users.sf.net
Thu Apr 25 09:22:22 UTC 2013


Revision: 4720
          http://sourceforge.net/p/rkward/code/4720
Author:   m-eik
Date:     2013-04-25 09:22:20 +0000 (Thu, 25 Apr 2013)
Log Message:
-----------
MacPorts: small fix to bundle script, added two new scripts: replace_port.sh can be used in development environments to "hide" the installation, install a bundle, test it, discard it and restore the build installation. uninstall.sh is an experimental implementation for a proper package uninstall tool.

Modified Paths:
--------------
    trunk/rkward/macports/update_bundle.sh

Added Paths:
-----------
    trunk/rkward/macports/replace_port.sh
    trunk/rkward/macports/uninstall.sh

Added: trunk/rkward/macports/replace_port.sh
===================================================================
--- trunk/rkward/macports/replace_port.sh	                        (rev 0)
+++ trunk/rkward/macports/replace_port.sh	2013-04-25 09:22:20 UTC (rev 4720)
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+# specify macports installation path
+MPTINST=/opt/rkward
+# specify application dir used
+APPLDIR=/Applications/RKWard
+# specify path to make
+MAKEPATH=/usr/bin/make
+# specify deactivation suffix
+DCTSFFX="_works"
+
+if [[ $1 == "" ]] ; then
+ echo "Usage: replace_port.sh OPTION
+          OPTIONS:
+           -d (deactivate running RKWard installation)
+           -a (re-activate previous RKWard installation)
+           -m (also include ${MAKEPATH} in the process)
+           -x (!remove! the deactivated RKWard installation)
+"
+fi
+
+# get the options
+while getopts ":damx" OPT; do
+  case $OPT in
+    d) DEACT=TRUE >&2 ;;
+    a) REACT=TRUE >&2 ;;
+    m) IMAKE=TRUE >&2 ;;
+    x) RMDCT=TRUE >&2 ;;
+    \?)
+      echo "Invalid option: -$OPTARG" >&2
+      exit 1
+      ;;
+    :)
+      echo "Option -$OPTARG requires an argument." >&2
+      exit 1
+      ;;
+  esac
+done
+
+if [[ $DEACT ]] ; then
+	if [ -d "${MPTINST}${DCTSFFX}" ] ; then
+		echo "ouch: \"${MPTINST}${DCTSFFX}\" already exists, aborting!"
+		exit 1
+	fi
+	if [ -d "${APPLDIR}${DCTSFFX}" ] ; then
+		echo "ouch: \"${APPLDIR}${DCTSFFX}\" already exists, aborting!"
+		exit 1
+	fi
+	sudo mv "${MPTINST}" "${MPTINST}${DCTSFFX}"
+	sudo mv "${APPLDIR}" "${APPLDIR}${DCTSFFX}"
+	if [[ $IMAKE ]] && [ -f "${MAKEPATH}${DCTSFFX}" ] ; then
+		echo "ouch: \"${MAKEPATH}${DCTSFFX}\" already exists, skipping!"
+	else
+		sudo mv "${MAKEPATH}" "${MAKEPATH}${DCTSFFX}"
+	fi
+fi
+
+if [[ $REACT ]] ; then
+	if [[ $IMAKE ]] && ! [ -f "${MAKEPATH}${DCTSFFX}" ] ; then
+		echo "ouch: \"${MAKEPATH}${DCTSFFX}\" doesn't exist, skipping!"
+	else
+		sudo mv "${MAKEPATH}${DCTSFFX}" "${MAKEPATH}"
+	fi
+	if ! [ -d "${MPTINST}${DCTSFFX}" ] ; then
+		echo "ouch: \"${MPTINST}${DCTSFFX}\" doesn't exist, aborting!"
+		exit 1
+	else
+		sudo rm -rf "${MPTINST}"
+		sudo mv "${MPTINST}${DCTSFFX}" "${MPTINST}"
+	fi
+	if ! [ -d "${APPLDIR}${DCTSFFX}" ] ; then
+		echo "ouch: \"${APPLDIR}${DCTSFFX}\" doesn't exist, aborting!"
+		exit 1
+	else
+		sudo rm -rf "${APPLDIR}"
+		sudo mv "${APPLDIR}${DCTSFFX}" "${APPLDIR}"
+	fi
+fi
+
+exit 0


Property changes on: trunk/rkward/macports/replace_port.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/rkward/macports/uninstall.sh
===================================================================
--- trunk/rkward/macports/uninstall.sh	                        (rev 0)
+++ trunk/rkward/macports/uninstall.sh	2013-04-25 09:22:20 UTC (rev 4720)
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+if [[ $1 == "" ]] ; then
+  echo "Usage: uninstall.sh OPTIONS
+          OPTIONS:
+
+           -l list all files and directories to be removed
+           -R actually remove all files and directories (if empty)
+"
+  exit 0
+fi
+
+# get the options
+while getopts ":lR" OPT; do
+  case $OPT in
+    l) LIST=TRUE >&2 ;;
+    R) REMOVE=TRUE >&2 ;;
+    \?)
+      echo "Invalid option: -$OPTARG" >&2
+      exit 1
+      ;;
+    :)
+      echo "Option -$OPTARG requires an argument." >&2
+      exit 1
+      ;;
+  esac
+done
+
+
+# fetch a list of all installed MacPorts packages
+ALLINSTPORTS=$(pkgutil --pkgs=org.macports.*)
+
+# treat only those who are associated with /opt/rkward
+for i in ${ALLINSTPORTS} ; do
+  if [[ $(pkgutil --only-dirs --files "$i" | grep "opt/rkward/") != "" ]] ; then
+    if [ ${LIST} ] ; then
+      pkgutil --files "$i" | sed -e "s#^#/#g"
+    fi
+    if [ ${REMOVE} ] ; then
+      # remove files
+      sudo rm $(pkgutil --only-files --files "$i" | sed -e "s#^#/#g") || exit 1
+      # remove directories if empty
+      sudo rmdir -p $(pkgutil --only-dirs --files "$i" | sed -e "s#^#/#g")
+      # forget about the package
+      sudo pkgutil --forget "$i"
+    fi
+  fi
+done
+
+exit 0


Property changes on: trunk/rkward/macports/uninstall.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/rkward/macports/update_bundle.sh
===================================================================
--- trunk/rkward/macports/update_bundle.sh	2013-04-25 07:54:03 UTC (rev 4719)
+++ trunk/rkward/macports/update_bundle.sh	2013-04-25 09:22:20 UTC (rev 4720)
@@ -57,6 +57,7 @@
            -s (create sources .tar)
            -c (copy .mdmg and src.tar to ${LPUBDIR}, if created)
            -x (completely!!! wipe ${MPTINST}/var/macports/distfiles)"
+exit 0
 fi
 
 # get the options





More information about the rkward-tracker mailing list