#!/bin/bash # $Header:$ # bash replacement for the original euse by Arun Bhanu # Author: Marius Mauch # Version: 0.1 # Licensed under the GPL v2 PROGRAM_NAME=euse PROGRAM_VERSION=0.1 MAKE_CONF_PATH=/etc/make.conf MAKE_GLOBALS_PATH=/etc/make.globals MAKE_PROFILE_PATH=/etc/make.profile MAKE_CONF_BACKUP_PATH=/etc/make.conf.euse_backup MODE="showhelp" # available operation modes: showhelp, showversion, showdesc, showflags, modify parse_arguments() { if [ -z "${1}" ]; then return fi while [ -n "${1}" ]; do case "${1}" in -h | --help) MODE="showhelp";; -v | --version) MODE="showversion";; -i | --info) MODE="showdesc";; -l | --local) SCOPE="local";; -g | --global) SCOPE="global";; -a | --active) MODE="showflags";; -E | --enable) MODE="modify"; ACTION="add";; -D | --disable) MODE="modify"; ACTION="remove";; -P | --prune) MODE="modify"; ACTION="prune";; # -m | --minimal) SCOPE="local";; -*) echo "ERROR: unknown option ${1} specified." echo MODE="showhelp" ;; *) ARGUMENTS="${ARGUMENTS} ${1}" ;; esac shift done } error() { echo "ERROR: ${1}" exit 1 } check_sanity() { # file permission tests local descdir descdir="$(get_portdir)/profiles" [ ! -r "${MAKE_CONF_PATH}" ] && error "${MAKE_CONF_PATH} is not readable" [ ! -r "${MAKE_GLOBALS_PATH}" ] && error "${MAKE_GLOBALS_PATH} is not readable" [ ! -s "${MAKE_PROFILE_PATH}" ] && error "${MAKE_PROFILE_PATH} is not a symlink" [ -z "$(get_portdir)" ] && error "\$PORTDIR couldn't be determined" [ ! -d "${descdir}" ] && error "${descdir} does not exist or is not a directory" [ ! -r "${descdir}/use.desc" ] && error "${descdir}/use.desc is not readable" [ ! -r "${descdir}/use.local.desc" ] && error "${descdir}/use.local.desc is not readable" [ ! -r "$(get_make_defaults)" ] && error "$(get_make_defaults) is not readable" [ "${MODE}" == "modify" -a ! -w "${MAKE_CONF_PATH}" ] && error ""${MAKE_CONF_PATH}" is not writable" } showhelp() { echo "${PROGRAM_NAME} v${PROGRAM_VERSION}" echo echo "Syntax: ${PROGRAM_NAME}