Ticket #23634: patch-destroot.diff

File patch-destroot.diff, 4.7 KB (added by mail_ben_schmidt@…, 14 years ago)
  • main.aap

    diff -ru aap-1.091.orig/main.aap aap-1.091/main.aap
    old new  
    55:attr all {comment = Same as "test"}
    66:attr clean {comment = Cleanup after testing}
    77:attr fetch {comment = Obtain latest version from CVS}
    8 :attr install {comment = Install Aap; use PREFIX=path to specify where; use FULLDOCS=no to skip installing HTML and PDF docs; use HTMLDIR=/html to install HTML files in a subdirectory}
     8:attr install {comment = Install Aap; use PREFIX=path and/or DESTDIR=path to specify where; use FULLDOCS=no to skip installing HTML and PDF docs; use HTMLDIR=/html to install HTML files in a subdirectory}
    99:attr uninstall {comment = Uninstall current version of Aap; use PREFIX=path to specify where; use VERSION=1.123 to specify a different version}
    1010:attr tags {comment = Create a tags file (requires Exuberant ctags)}
    1111
     
    3131install:
    3232    @if os.name == 'posix':
    3333        PREFIX = `os.path.expanduser(_no.PREFIX)`
    34         @if not os.access(_no.PREFIX, os.W_OK):
    35             @if os.access(_no.PREFIX, os.R_OK):
    36                 :error Install directory is not writable: $PREFIX
    37             @r = raw_input(('\nThe $PREFIX directory does not exist: "%s"\n'
    38             @               % _no.PREFIX) +
     34        DESTDIR = $DESTDIR/$PREFIX
     35        @if not os.access(_no.DESTDIR, os.W_OK):
     36            @if os.access(_no.DESTDIR, os.R_OK):
     37                :error Install directory is not writable: $DESTDIR
     38            @r = raw_input(('\nThe $DESTDIR directory does not exist: "%s"\n'
     39            @               % _no.DESTDIR) +
    3940            @           "Do you want to try creating it? (y/n) ")
    4041            @if not r or (r[0] != 'y' and r[0] != 'Y'):
    41                 :error Install directory does not exist: $PREFIX
    42             :mkdir {r} $PREFIX
     42                :error Install directory does not exist: $DESTDIR
     43            :mkdir {r} $DESTDIR
    4344
    4445        # Get the version string from AapVersion.py, because $VERSIONSTR is
    4546        # from the current Aap, which may be older.
     
    4748                                    stdin).group(1) | :assign Version
    4849
    4950        # Directories to be used.
    50         dir = $PREFIX/lib/aap/Exec-$Version
     51        dir = $DESTDIR/lib/aap/Exec-$Version
    5152        toolsdir = $dir/tools
    5253        modulesdir = $dir/modules
    5354        docdir = $dir/doc
    5455        htmldocdir = $docdir$?HTMLDIR
    55         bindir = $PREFIX/bin
    56         mandir = $PREFIX/man/man1
    57         sharedocdir = $PREFIX/share/doc
     56        bindir = $DESTDIR/bin
     57        mandir = $DESTDIR/share/man/man1
     58        sharedocdir = $DESTDIR/share/doc
    5859        sharedocdiraap = $sharedocdir/aap
    5960        sharehtmldocdir = $sharedocdiraap$?HTMLDIR
     61        prefixdir = $PREFIX/lib/aap/Exec-$Version
     62        prefixdocdir = $dir/doc
     63        prefixhtmldocdir = $docdir$?HTMLDIR
     64        prefixsharedocdir = $PREFIX/share/doc
     65        prefixsharedocdiraap = $sharedocdir/aap
     66        prefixsharehtmldocdir = $sharedocdiraap$?HTMLDIR
    6067
    6168        # Copy the files.
    6269        :mkdir {r}{f} $toolsdir $modulesdir
     
    7380            # Create symbolic links for the docs dir.
    7481            @if os.path.exists(sharedocdir):
    7582                :print Creating a symbolic link for "aap" in $sharedocdir
    76                 :symlink {f} $docdir $sharedocdiraap
    77                 indexstr = $sharehtmldocdir/index.html
    78                 htmlstr = $sharehtmldocdir/*.html
    79                 pdfstr = $sharedocdiraap/exec.pdf
     83                :symlink {f} $prefixdocdir $sharedocdiraap
     84                indexstr = $prefixsharehtmldocdir/index.html
     85                htmlstr = $prefixsharehtmldocdir/*.html
     86                pdfstr = $prefixsharedocdiraap/exec.pdf
    8087            @else:
    8188                indexstr = $htmldocdir/index.html
    8289                htmlstr = $htmldocdir/*.html
     
    116123        # Create symbolic links for the program.
    117124        :print Creating a symbolic link for "aap" in $bindir
    118125        :mkdir {f} $bindir
    119         :symlink {f} $dir/aap $bindir/aap
     126        :symlink {f} $prefixdir/aap $bindir/aap
    120127
    121128    @elif os.name in ["win32", "mswin", "nt"]:
    122129        # On MS-Windows we write an aap.bat file in the Windows directory.
     
    156163uninstall:
    157164    @if os.name == 'posix':
    158165        PREFIX = `os.path.expanduser(_no.PREFIX)`
    159         @if not os.access(_no.PREFIX, os.W_OK):
    160             :error Install directory is not writable: $PREFIX
     166        DESTDIR = $DESTDIR/$PREFIX
     167        @if not os.access(_no.DESTDIR, os.W_OK):
     168            :error Install directory is not writable: $DESTDIR
    161169
    162170        # What version to uninstall?  Default is what we are currently running.
    163171        VERSION ?= $VERSIONSTR
    164172
    165         dir = $PREFIX/lib/aap/Exec-$VERSION
    166         mandir = $PREFIX/man/man1
     173        dir = $DESTDIR/lib/aap/Exec-$VERSION
     174        mandir = $DESTDIR/share/man/man1
    167175
    168176        # Only delete the bin/aap and share/doc symlinks if they point to the
    169177        # version we uninstalled.
    170178        @try:
    171             n = $PREFIX/bin/aap
     179            n = $DESTDIR/bin/aap
    172180            @if string.find(os.readlink(n), _no.VERSION) >= 0:
    173181                :del {f} $n
    174182        @except:
    175183        @   pass
    176184
    177185        @try:
    178             n = $PREFIX/share/doc/aap
     186            n = $DESTDIR/share/doc/aap
    179187            @if string.find(os.readlink(n), _no.VERSION) >= 0:
    180188                :del {f} $n
    181189        @except: