[MacPorts] Scripts/testport_script modified
MacPorts
noreply at macports.org
Thu Apr 26 11:27:19 PDT 2012
Changed page "Scripts/testport_script" by kato23 at mailinator.com from 84.163.63.76*
Page URL: <https://trac.macports.org/wiki/Scripts/testport_script>
Diff URL: <https://trac.macports.org/wiki/Scripts/testport_script?action=diff&version=11>
Revision 11
-------8<------8<------8<------8<------8<------8<------8<------8<--------
Index: Scripts/testport_script
=========================================================================
--- Scripts/testport_script (version: 10)
+++ Scripts/testport_script (version: 11)
@@ -23,6 +23,7 @@
# testport -n -l /opt/macports-gnu gawk
# testport -c -r -e -v clang-3.1
# testport -s clang-3.1
+# testport -c -r openal configure.cc='/opt/macports-test/bin/clang-mp-3.1' configure.cxx='/opt/macports-test/bin/clang++-mp-3.1'
show_usage() {
@@ -39,7 +40,7 @@
-p: print PATH variable value
-r: remove / uninstall specified port before reinstalling it
-s: build and install from source only
--u: update MacPorts system and upgrade outdated ports
+-u: update MacPorts system and upgrade outdated ports (cleans work directories)
-v: enable verbose mode
-l dir: specify dir as location of MacPorts system (otherwise defaults to /opt/macports-test)
'
@@ -70,6 +71,39 @@
exit
}
+
+do_clean_all() {
+ [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --all installed
+ [[ $(port list inactive | wc -l) -gt 0 ]] && port -f uninstall inactive
+ find -x "${MP_PREFIX}/var/macports/build" -maxdepth 3 -type d -name work -print0 | while IFS="" read -r -d "" dirpath; do
+ portname="$( basename "$(dirname "${dirpath}")" )"
+ echo port -f -v clean --all "${portname}"
+ port -f -v clean --all "${portname}"
+ done
+ return 0
+}
+
+do_clean_work() {
+ [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --work installed
+ find -x "${MP_PREFIX}/var/macports/build" -maxdepth 3 -type d -name work -print0 | while IFS="" read -r -d "" dirpath; do
+ portname="$( basename "$(dirname "${dirpath}")" )"
+ echo port -f -v clean --work "${portname}"
+ port -f -v clean --work "${portname}"
+ done
+ return 0
+}
+
+
+do_update() {
+ do_clean_work
+ port selfupdate
+ port outdated
+ [[ $(port outdated | wc -l) -gt 1 ]] && port upgrade -R -u outdated
+ return 0
+}
+
+
+
unset CDPATH PATH IFS LC_ALL MP_PREFIX all_new
IFS=$' \t\n'
LC_ALL=C
@@ -177,6 +211,14 @@
PATH="${MP_PREFIX}/bin:${MP_PREFIX}/sbin:/usr/bin:/bin:/usr/sbin:/sbin"
export PATH
+
+if [[ $(id -u) -ne 0 ]] || [[ "${HOME}" != '/var/root' ]]; then
+ echo 'This script must be run in a root shell to prevent sudo timeout!' 1>&2
+ echo 'Use: sudo -H -i' 1>&2
+ exit 1
+fi
+
+
if [[ $printpath -eq 1 ]]; then
printf '\n\n%s\n\n\n' "export PATH=\"${MP_PREFIX}/bin:${MP_PREFIX}/sbin:/usr/bin:/bin:/usr/sbin:/sbin\""
exit
@@ -189,14 +231,15 @@
if [[ $# -eq 0 ]]; then
- if [[ $clean_all -eq 1 ]]; then
- [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --all installed
+ if [[ $clean_all -eq 1 ]] && [[ $update -eq 1 ]]; then
+ do_clean_all
+ do_update
+ exit
+ elif [[ $clean_all -eq 1 ]]; then
+ do_clean_all
exit
elif [[ $update -eq 1 ]]; then
- [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --all installed
- port selfupdate
- port outdated
- [[ $(port outdated | wc -l) -gt 1 ]] && port upgrade -R -u outdated
+ do_update
exit
else
echo
@@ -207,20 +250,8 @@
fi
-if [[ $(id -u) -ne 0 ]] || [[ "${HOME}" != '/var/root' ]]; then
- echo 'This script must be run in a root shell to prevent sudo timeout!' 1>&2
- echo 'Use: sudo -H -i' 1>&2
- exit 1
-fi
-
-
-dsclHome="$(dscl . -read /Users/macports NFSHomeDirectory | sed 's/^NFSHomeDirectory: *//')"
-dscl . -change /Users/macports NFSHomeDirectory "${dsclHome}" "${MP_PREFIX}/var/macports/home"
-
-
# make sure the current working directory exists
pwd -P 1>/dev/null || exit 1
-
# prevent idle sleep
pmset -a force sleep 0 displaysleep 0 disksleep 0
@@ -237,6 +268,9 @@
trap on_exit EXIT TERM HUP INT QUIT
+dsclHome="$(dscl . -read /Users/macports NFSHomeDirectory | sed 's/^NFSHomeDirectory: *//')"
+dscl . -change /Users/macports NFSHomeDirectory "${dsclHome}" "${MP_PREFIX}/var/macports/home"
+
echo
# make sure /usr/local is not interfering with MacPorts build processes for /opt/local
@@ -246,15 +280,6 @@
[[ -d '/opt/local' ]] && sudo mv -iv /opt/local "${opt_local_off}"
echo
-
-# clean up previous "${MP_PREFIX}" directory
-if [[ -x "${MP_PREFIX}/bin/port" ]]; then
- if [[ $clean_all -eq 1 ]]; then
- [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --all installed
- else
- [[ $(port installed "$@" | wc -l) -gt 1 ]] && port -f clean --work "$@"
- fi
-fi
if [[ $all_new -eq 1 ]]; then
@@ -278,7 +303,7 @@
curl -L -O https://distfiles.macports.org/MacPorts/MacPorts-2.0.4.tar.bz2 || exit 1
tar -xjf MacPorts-2.0.4.tar.bz2
cd MacPorts-2.0.4 || exit 1
- #--with-install-user=$owner --with-install-group=$group --with-directory-mode=$perms"
+ # --enable-werror --with-install-user=$owner --with-install-group=$group --with-directory-mode=$perms"
./configure --prefix="${MP_PREFIX}" --with-tclpackage="${MP_PREFIX}/tcl" --with-applications-dir="${MP_PREFIX}/Applications"
make
@@ -296,11 +321,20 @@
PATH="${MP_PREFIX}/bin:${MP_PREFIX}/sbin:/usr/bin:/bin:/usr/sbin:/sbin"
export PATH
+echo
+
+# clean up previous "${MP_PREFIX}" directory
+if [[ $all_new -eq 0 ]] && [[ -x "${MP_PREFIX}/bin/port" ]]; then
+ if [[ $clean_all -eq 1 ]]; then
+ do_clean_all
+ else
+ do_clean_work
+ fi
+fi
+
+
if [[ $update -eq 1 ]]; then
- [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --all installed
- port selfupdate
- port outdated
- [[ $(port outdated | wc -l) -gt 1 ]] && port upgrade -R -u outdated
+ do_update
fi
-------8<------8<------8<------8<------8<------8<------8<------8<--------
* The IP shown here might not mean anything if the user or the server is
behind a proxy.
--
MacPorts <http://www.macports.org/>
Ports system for Mac OS
This is an automated message. Someone at http://www.macports.org/ added your email
address to be notified of changes on Scripts/testport_script. If it was not you, please
report to .
More information about the macports-changes
mailing list