Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 2822

Show
Ignore:
Timestamp:
11/09/07 05:55:20 (1 year ago)
Author:
larsivi
Message:

Fixed uninstall and dmd.conf for new naming scheme. Added --verify switch as a sort of unittesting. refs #660

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/install-dmd.sh

    r2821 r2822  
    1818Options: 
    1919  --prefix: Install to the specified prefix (absolute path). 
    20   --uninstall: Uninstall tango, switch back to standard phobos.' 
     20  --uninstall: Uninstall Tango, switch back to standard Phobos. 
     21  --verify: Will verify installation.' 
    2122    exit 0 
    2223} 
     
    2627# 0) Parse arguments 
    2728UNINSTALL=0 
    28 REPLACE_PHOBOS=0 
     29VERIFY=0 
    2930 
    3031while [ "$#" != "0" ] 
     
    3839    then 
    3940        UNINSTALL=1 
    40     else 
     41    elif [ "$1" = "--verify" ] 
     42    then 
     43        VERIFY=1 
     44     else 
    4145        usage 
    4246    fi 
     
    5155echo "$PREFIX" 
    5256 
     57# Verify that PREFIX is absolute 
    5358if [ "${PREFIX:0:1}" != "/" ] 
    5459then 
     
    5661fi 
    5762 
     63# Verify presence of DMD 
    5864dmd --help >& /dev/null || die "dmd not found on your \$PATH!" 1 
    59  
    60 if [ -e "$PREFIX/lib/libphobos.a" ] 
    61 then 
    62     REPLACE_PHOBOS=1 
    63 fi 
    6465 
    6566# If uninstalling, do that now 
    6667if [ "$UNINSTALL" = "1" ] 
    6768then 
    68     # revert to phobos if earlier evidence of existense is found 
     69    # Revert to Phobos if earlier evidence of existense is found 
     70    # Only relevant for pre 0.99.3 installations 
    6971    if [ -e "$PREFIX/lib/libphobos.a.phobos" ] 
    7072    then 
    7173        mv     $PREFIX/lib/libphobos.a.phobos $PREFIX/lib/libphobos.a 
     74    else 
     75        if [ -e "$PREFIX/lib/libphobos.a" ] 
     76        then 
     77            rm -f $PREFIX/lib/libphobos.a 
     78        fi 
    7279    fi 
    7380    if [ -e "$PREFIX/include/d/object.d.phobos" ] 
     
    9299        rm -f  $PREFIX/include/d/tango/object.di 
    93100    fi 
    94     # Since tango 0.99 
     101    # Since Tango 0.99 
    95102    if [ -e "$PREFIX/include/d/object.di" ] 
    96103    then 
     
    100107    fi 
    101108 
     109    # Prior to Tango 0.99.3 
    102110    if [ -e "$PREFIX/lib/libtango.a" ] 
    103111    then 
    104112        rm -f $PREFIX/lib/libtango.a 
    105113    fi 
     114 
     115    # Since Tango 0.99.3 
     116    if [ -e "$PREFIX/lib/libdtango-base-dmd.a" ] 
     117    then 
     118        rm -f $PREFIX/lib/libdtango-base-dmd.a 
     119    fi 
     120 
     121    if [ -e "$PREFIX/lib/libdtango-user-tango.a" ] 
     122    then 
     123        rm -f $PREFIX/lib/libdtango-user-tango.a 
     124    fi 
     125 
    106126    die "Done!" 0 
    107127fi 
    108128 
    109129 
    110 # Sanity check 
     130# Verify that runtime was built 
    111131if [ ! -e libdtango-base-dmd.a ] 
    112132then 
     
    115135 
    116136# Back up the original files 
    117 if [ "$REPLACE_PHOBOS" = "1" ] 
    118 then 
    119     if [ -e "$PREFIX/lib/libphobos.a.phobos" ] 
    120     then 
    121         die "You must uninstall your old copy of Tango before installing a new one." 4 
    122     fi 
    123     mv -f $PREFIX/lib/libphobos.a $PREFIX/lib/libphobos.a.phobos 
    124     if [ -e "$PREFIX/include/d/object.d" ] 
    125     then 
    126         mv -f $PREFIX/include/d/object.d $PREFIX/include/d/object.d.phobos 
    127     fi 
    128 fi 
    129  
     137if [ -e "$PREFIX/include/d/object.d" ] 
     138then 
     139    mv -f $PREFIX/include/d/object.d $PREFIX/include/d/object.d.phobos 
     140fi 
     141 
     142# Create dmd.conf 
    130143create_dmd_conf() { 
    131144    cat > $PREFIX/bin/dmd.conf <<EOF 
     
    152165        create_dmd_conf 
    153166    else 
    154         echo 'Found Tango enabled dmd.conf, assume it is working and leave it as is' 
    155     fi 
     167        if [ ! "`grep '\-defaultlib=dtango\-base\-dmd' $PREFIX/bin/dmd.conf`" ] 
     168        then 
     169            echo 'Appending -defaultlib switch to DFLAGS' 
     170            sed -i.bak -e 's/^DFLAGS=.*$/& -defaultlib=dtango-base-dmd/' $PREFIX/bin/dmd.conf 
     171        else 
     172            echo 'Found Tango enabled dmd.conf, assume it is working and leave it as is' 
     173        fi 
     174    fi 
     175fi 
     176 
     177# Verify installation 
     178if [ "$VERIFY" = "1" ] 
     179then 
     180    echo 'Verifying installation.' 
     181    if [ ! -e "$PREFIX/include/d/object.di" ] 
     182    then 
     183        die "object.di not properly installed to $PREFIX/include/d" 9 
     184    fi 
     185    if [ ! -e "$PREFIX/lib/libdtango-base-dmd.a" ] 
     186    then 
     187        die "libdtango-base-dmd.a not properly installed to $PREFIX/lib" 10  
     188    fi 
     189    if [ ! -e "$PREFIX/bin/dmd.conf" ] 
     190    then 
     191        die "dmd.conf not present in $PREFIX/bin" 11  
     192    elif [ ! "`grep '\-version=Tango' $PREFIX/bin/dmd.conf`" ] 
     193    then 
     194        die "dmd.conf not Tango enabled" 12 
     195    elif [ ! "`grep '\-defaultlib=dtango\-base\-dmd' $PREFIX/bin/dmd.conf`" ] 
     196    then 
     197        die "dmd.conf don't have -defaultlib switch" 13 
     198    fi 
     199    echo 'Installation OK.' 
    156200fi 
    157201