Ticket #14615: select.diff

File select.diff, 1.7 KB (added by blb@…, 16 years ago)

diff to select/select.sh

  • select/select.sh

     
    3737TOOL=${NAME}_select
    3838CONFPATH=${PREFIX}/etc/select/${NAME}
    3939VERSION=__VERSION__
     40SELECTEDVERSION=${CONFPATH}/.current
    4041
    4142
    4243## GLOBALS
     
    6768-v        Display version of ${TOOL}.
    6869-l        List available options for version.
    6970-i path   Install mode to perform an initial selection in path.
     71-s        Show the currently selected version
    7072
    7173EOD
    7274}
     
    8284        echo $(ls -1 ${CONFPATH} | grep -v base)
    8385}
    8486
     87# list the currently selected version
     88list_current_selection() {
     89        if [ -e ${SELECTEDVERSION} ]; then
     90                cat ${SELECTEDVERSION}
     91        else
     92                echo "none"
     93        fi
     94}
     95
    8596# test if a particular version is available
    8697version_is_valid() {
    8798        for version in $(ls -1 ${CONFPATH} | grep -v base); do
     
    118129        local i=1
    119130        local empty=0
    120131        echo "Selecting version \"${1}\" for ${NAME}"
     132        if [ 1 == ${noexec} ]; then
     133                echo "echo ${1} >| ${SELECTEDVERSION}"
     134        else
     135                echo ${1} >| ${SELECTEDVERSION}
     136        fi
    121137        for target in $(cat ${CONFPATH}/base); do
    122138                src=$(head -n ${i} ${CONFPATH}/${1} | tail -n 1)
    123139
     
    146162fi
    147163
    148164# parse command line args
    149 args=$(/usr/bin/getopt i:fhndlrv $*)
     165args=$(/usr/bin/getopt i:fhndlrsv $*)
    150166set -- ${args}
    151167for i; do
    152168        case "${i}" in
     
    166182                        version; exit 0;;
    167183                -i)
    168184                        inst_mode=1; DESTDIR=${2}; shift; shift;;
     185                -s)
     186                        list_current_selection; exit 0;;
    169187                --)
    170188                        shift; break;;
    171189        esac
     
    180198if [ "1" = "${inst_mode}" ]; then
    181199        echo "install mode: destroot: \"${DESTDIR}\""
    182200        CONFPATH=${DESTDIR}${CONFPATH}
     201        SELECTEDVERSION=${CONFPATH}/.current
    183202        select_version ${1}
    184203        exit ${?}
    185204fi