Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash -x
- BASE_APPS_PREFIX='/opt'
- slf="$0"
- if [ $# -eq 1 -a "$1" = '--help' -o "$1" = '-h' ]; then
- cat <<-"EOHELP"
- This is a smplest frontend to standart GNU configure script
- Usage: $slf PROGRAM VERSION [new] [noinst] [srclnk] [<configure-parameters>]
- Where:
- * PROGRAM is a program name and at the same time - name
- of subdirectory in $BASE_APPS_PREFIX (so root directory of a newely
- installed software will be $BASE_APPS_PREFIX/PROGRAM)
- * VERSION is a version of program that will be installed
- Keyword 'new' is used to tell this script that it is
- necessary to recreate symlink 'current' to point it to
- this VERSION of PROGRAM
- EOHELP
- ./configure --help
- exit 0
- fi
- { (($#>=2)) && [[ -x ./configure ]]; } || exit 1
- prg="$1"; shift
- ver="$1"; shift
- pfx="${BASE_APPS_PREFIX}/$prg/$ver"
- if (($(id -u)==0)) && make install; then
- while [[ $# > 0 ]]; do
- case "$1" in
- new)
- rm -f "${BASE_APPS_PREFIX}/$prg"/current
- ln -s $ver "${BASE_APPS_PREFIX}/$prg"/current
- ;;
- srclnk)
- { [ -d $pfx/Development ] || mkdir -p $pfx/Development; } && \
- { rm -f $pfx/Development/build; ln -s "`pwd`" $pfx/Development/build; }
- ;;
- *) :
- ;;
- esac
- shift
- done
- else
- args="$@"
- cmds="${args%%--*}"
- cfgoption=(
- prefix:${pfx}
- bindir:${pfx}/Binaries/exe
- sbindir:${pfx}/Binaries/exe/sys
- libexecdir:${pfx}/Binaries/exe/sys
- sysconfdir:${pfx}/Configuration
- sharedstatedir:${pfx}/Binaries/com
- localstatedir:${pfx}/DataFiles/dyn
- libdir:${pfx}/Binaries/lib
- includedir:${pfx}/Development/headers
- oldincludedir:${pfx}/Development/headers/old-compilers
- datarootdir:${pfx}/DataFiles/stat
- infodir:${pfx}/Documentation/info
- mandir:${pfx}/Documentation/man-pages
- localedir:${pfx}/DataFiles/stat/locale
- docdir:${pfx}/Documentation/misc
- htmldir:${pfx}/Documentation/html
- dvidir:${pfx}/Documentation/dvi
- pdfdir:${pfx}/Documentation/pdf
- psdir:${pfx}/Documentation/PostScript
- )
- configure_help=$(./configure --help | fgrep -- -- | tr -d '\n')
- # datarootdir infodir mandir localedir docdir htmldir dvidir pdfdir psdir
- configure_options=$(
- for ((i=0; i<${#cfgoption[@]}; i++)); do
- opt="${cfgoption[$i]}"
- [[ $configure_help =~ \-\-${opt%%:*} ]] && \
- echo -n '--'"${opt%%:*}=${opt#*:} "
- done
- )
- if ./configure $configure_options ${args:${#cmds}} && make && ! [[ $cmds =~ noinst ]]; then
- sudo $0 "$prg" "$ver" $cmds
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement