Changes between Version 10 and Version 11 of Scripts/testport_script


Ignore:
Timestamp:
Apr 26, 2012, 6:27:18 PM (13 years ago)
Author:
kato23@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Scripts/testport_script

    v10 v11  
    2424# testport -c -r -e -v clang-3.1
    2525# testport -s clang-3.1
     26# testport -c -r openal configure.cc='/opt/macports-test/bin/clang-mp-3.1' configure.cxx='/opt/macports-test/bin/clang++-mp-3.1'
    2627
    2728
     
    4041-r: remove / uninstall specified port before reinstalling it
    4142-s: build and install from source only
    42 -u: update MacPorts system and upgrade outdated ports
     43-u: update MacPorts system and upgrade outdated ports (cleans work directories)
    4344-v: enable verbose mode
    4445-l dir: specify dir as location of MacPorts system (otherwise defaults to /opt/macports-test)
     
    7172}
    7273
     74
     75do_clean_all() {
     76   [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --all installed
     77   [[ $(port list inactive | wc -l) -gt 0 ]] && port -f uninstall inactive
     78   find -x "${MP_PREFIX}/var/macports/build" -maxdepth 3 -type d -name work -print0 | while IFS="" read -r -d "" dirpath; do
     79      portname="$( basename "$(dirname "${dirpath}")" )"
     80      echo port -f -v clean --all "${portname}"
     81      port -f -v clean --all "${portname}"
     82   done
     83   return 0
     84}
     85
     86do_clean_work() {
     87  [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --work installed
     88   find -x "${MP_PREFIX}/var/macports/build" -maxdepth 3 -type d -name work -print0 | while IFS="" read -r -d "" dirpath; do
     89      portname="$( basename "$(dirname "${dirpath}")" )"
     90      echo port -f -v clean --work "${portname}"
     91      port -f -v clean --work "${portname}"
     92   done
     93   return 0
     94}
     95
     96
     97do_update() {
     98   do_clean_work
     99   port selfupdate
     100   port outdated
     101   [[ $(port outdated | wc -l) -gt 1 ]] && port upgrade -R -u outdated
     102   return 0
     103}
     104
     105
     106
    73107unset CDPATH PATH IFS LC_ALL MP_PREFIX all_new
    74108IFS=$' \t\n'
     
    178212export PATH
    179213
     214
     215if [[ $(id -u) -ne 0 ]] || [[ "${HOME}" != '/var/root' ]]; then
     216   echo 'This script must be run in a root shell to prevent sudo timeout!' 1>&2
     217   echo 'Use: sudo -H -i' 1>&2
     218   exit 1
     219fi
     220
     221
    180222if [[ $printpath -eq 1 ]]; then
    181223   printf '\n\n%s\n\n\n' "export PATH=\"${MP_PREFIX}/bin:${MP_PREFIX}/sbin:/usr/bin:/bin:/usr/sbin:/sbin\""
     
    190232
    191233if [[ $# -eq 0 ]]; then
    192   if [[ $clean_all -eq 1 ]]; then
    193       [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --all installed
     234   if [[ $clean_all -eq 1 ]] && [[ $update -eq 1 ]]; then
     235      do_clean_all
     236      do_update
     237      exit
     238   elif [[ $clean_all -eq 1 ]]; then
     239      do_clean_all
    194240      exit
    195241   elif [[ $update -eq 1 ]]; then
    196       [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --all installed
    197       port selfupdate
    198       port outdated
    199       [[ $(port outdated | wc -l) -gt 1 ]] && port upgrade -R -u outdated
     242      do_update
    200243      exit
    201244   else
     
    208251
    209252
    210 if [[ $(id -u) -ne 0 ]] || [[ "${HOME}" != '/var/root' ]]; then
    211    echo 'This script must be run in a root shell to prevent sudo timeout!' 1>&2
    212    echo 'Use: sudo -H -i' 1>&2
    213    exit 1
    214 fi
    215 
    216 
    217 dsclHome="$(dscl . -read /Users/macports NFSHomeDirectory | sed 's/^NFSHomeDirectory: *//')"
    218 dscl . -change /Users/macports NFSHomeDirectory "${dsclHome}" "${MP_PREFIX}/var/macports/home"
    219 
    220 
    221253# make sure the current working directory exists
    222254pwd -P 1>/dev/null || exit 1
    223 
    224255
    225256# prevent idle sleep
     
    238269trap on_exit EXIT TERM HUP INT QUIT
    239270
     271dsclHome="$(dscl . -read /Users/macports NFSHomeDirectory | sed 's/^NFSHomeDirectory: *//')"
     272dscl . -change /Users/macports NFSHomeDirectory "${dsclHome}" "${MP_PREFIX}/var/macports/home"
     273
    240274echo
    241275
     
    247281
    248282echo
    249 
    250 # clean up previous "${MP_PREFIX}" directory
    251 if [[ -x "${MP_PREFIX}/bin/port" ]]; then
    252    if [[ $clean_all -eq 1 ]]; then
    253       [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --all installed
    254    else
    255       [[ $(port installed "$@" | wc -l) -gt 1 ]] && port -f clean --work "$@"
    256    fi
    257 fi
    258283
    259284
     
    279304   tar -xjf MacPorts-2.0.4.tar.bz2
    280305   cd MacPorts-2.0.4 || exit 1
    281    #--with-install-user=$owner --with-install-group=$group --with-directory-mode=$perms"
     306   # --enable-werror --with-install-user=$owner --with-install-group=$group --with-directory-mode=$perms"
    282307   ./configure --prefix="${MP_PREFIX}" --with-tclpackage="${MP_PREFIX}/tcl" --with-applications-dir="${MP_PREFIX}/Applications"
    283308
     
    297322export PATH
    298323
     324echo
     325
     326# clean up previous "${MP_PREFIX}" directory
     327if [[ $all_new -eq 0 ]] && [[ -x "${MP_PREFIX}/bin/port" ]]; then
     328   if [[ $clean_all -eq 1 ]]; then
     329      do_clean_all
     330   else
     331      do_clean_work
     332   fi
     333fi
     334
     335
    299336if [[ $update -eq 1 ]]; then
    300    [[ $(port installed | wc -l) -gt 1 ]] && port -f clean --all installed
    301    port selfupdate
    302    port outdated
    303    [[ $(port outdated | wc -l) -gt 1 ]] && port upgrade -R -u outdated
     337   do_update
    304338fi
    305339