From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 4036E1384BD for ; Tue, 15 Jan 2013 19:02:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 158DFE0509; Tue, 15 Jan 2013 19:02:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 88947E0509 for ; Tue, 15 Jan 2013 19:02:52 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 77B8A33DAC3 for ; Tue, 15 Jan 2013 19:02:51 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 1A2CDE4073 for ; Tue, 15 Jan 2013 19:02:50 +0000 (UTC) From: "Christoph Junghans" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Christoph Junghans" Message-ID: <1357519526.43ca639fb83870d24dc022ba22e3aa6b61d85299.ottxor@gentoo> Subject: [gentoo-commits] proj/eselect:extern commit in: /, modules/ X-VCS-Repository: proj/eselect X-VCS-Files: AUTHORS ChangeLog modules/awk.eselect modules/timezone.eselect X-VCS-Directories: / modules/ X-VCS-Committer: ottxor X-VCS-Committer-Name: Christoph Junghans X-VCS-Revision: 43ca639fb83870d24dc022ba22e3aa6b61d85299 X-VCS-Branch: extern Date: Tue, 15 Jan 2013 19:02:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: bfcb3a05-937e-4eb5-a49e-e876c5e33fc1 X-Archives-Hash: ce1bb690983013412f886ed22b35f22a commit: 43ca639fb83870d24dc022ba22e3aa6b61d85299 Author: Christoph Junghans gentoo org> AuthorDate: Mon Jan 7 00:45:26 2013 +0000 Commit: Christoph Junghans gentoo org> CommitDate: Mon Jan 7 00:45:26 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=43ca639f awk, timezone: added --- AUTHORS | 3 + ChangeLog | 6 ++ modules/awk.eselect | 159 ++++++++++++++++++++++++++++++++++++++++++++++ modules/timezone.eselect | 132 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 300 insertions(+), 0 deletions(-) diff --git a/AUTHORS b/AUTHORS index a54f624..fb58161 100644 --- a/AUTHORS +++ b/AUTHORS @@ -27,3 +27,6 @@ Ryan Hill Chí-Thanh Christopher Nguyễn Modules: mesa + +Christoph Junghans + Modules: awk, timezone diff --git a/ChangeLog b/ChangeLog index d4c3a67..9499f4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-01-06 Christoph Junghans + + * modules/awk.eselect: Add awk selection module + * modules/timezoe.eselect: Add timezone setting module + * AUTHOR: Add myself + 2013-01-01 Matt Turner * modules/opengl.eselect: switch GLES3, bug #444114. diff --git a/modules/awk.eselect b/modules/awk.eselect new file mode 100644 index 0000000..61650c4 --- /dev/null +++ b/modules/awk.eselect @@ -0,0 +1,159 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id: $ + +DESCRIPTION="Manage {,/usr}/bin/awk implementations" +MAINTAINER="ottxor@gentoo.org" +VERSION="0.2" + +## Functions ## + +# find a list of awk symlink targets, best first +find_targets() { + local t + for t in \ + "${EROOT}/usr/bin/gawk" \ + "${EROOT}/usr/bin/mawk" \ + "${EROOT}/usr/bin/nawk" \ + "${EROOT}/bin/busybox" \ + ; do + if [[ -x ${t} ]]; then + echo ${t##*/} + fi + done +} + +# set the awk symlink +set_symlinks() { + local target=${1} targets extension dir i rel_target + + [[ ! -L ${EROOT}/bin/awk && -e ${EROOT}/bin/awk ]] && \ + die -q "/bin/awk is not a symlink!" + + [[ ! -L ${EROOT}/usr/bin/awk && -e ${EROOT}/usr/bin/awk ]] && \ + die -q "/usr/bin/awk is not a symlink!" + + if is_number "${target}" && [[ ${target} -ge 1 ]]; then + targets=( $(find_targets) ) + target=${targets[target-1]} + fi + + if [[ ${target} == "busybox" ]]; then + dir="${EROOT}/bin" + else + dir="${EROOT}/usr/bin" + fi + + [[ -x ${dir}/${target} ]] || die -q "Target '${target}' doesn't appear to be valid!" + + for i in /bin /usr/bin; do + rel_target=$(relative_name "${dir}/${target}" "${EROOT}${i}") + ln -sf "${rel_target}" "${EROOT}${i}/awk" || \ + die -q "Couldn't set ${target} ${i}/awk symlink" + done + + rm -f "${EROOT}"/usr/share/man/man1/awk.1{,.bz2,.gz,lzma} + for x in ".1" ".1.bz2" ".1.gz" ".1.lzma" ; do + if [[ -e ${EROOT}/usr/share/man/man1/${target}${x} ]] ; then + extension="${x}" + break + fi + done + + #busybox has no man page + if [[ -z "${extension}" ]] ; then + echo "Couldn't find a man page for ${target}; skipping." 1>&2 + return 1 + fi + + if ! ln -s "${target}${extension}" "${EROOT}/usr/share/man/man1/awk${extension}"; then + echo "Couldn't create man page symlink for ${target}; skipping." 1>&2 + return 1 + fi +} + +### show action ### + +describe_show() { + echo "Show the current awk implementation" +} + +do_show() { + [[ -z ${@} ]] || die -q "Too many parameters" + + write_list_start "Current awk implementation:" + if [[ -L ${EROOT}/usr/bin/awk ]]; then + write_kv_list_entry "$(basename $(readlink ${ROOT}/usr/bin/awk))" "" + elif [[ -e ${EROOT}/usr/bin/awk ]]; then + write_kv_list_entry "(not a symlink)" "" + else + write_kv_list_entry "(unset)" "" + fi +} + +### list action ### + +describe_list() { + echo "List available awk implementations" +} + +do_list() { + [[ -z ${@} ]] || die -q "Too many parameters" + + local i targets + + targets=( $(find_targets) ) + for (( i = 0; i < ${#targets[@]}; i++ )) ; do + [[ ${targets[${i}]} == $(basename $(readlink "${EROOT}"/usr/bin/awk)) ]] && \ + targets[${i}]=$(highlight_marker "${targets[${i}]}") + done + write_list_start "Available awk implementations:" + write_numbered_list -m '(none found)' "${targets[@]}" +} + +### set action ### + +describe_set() { + echo "Set a new awk implementation" +} + +describe_set_options() { + echo "target : Target name or number (from 'list' action)" +} + +describe_set_parameters() { + echo "" +} + +do_set() { + if [[ -z ${1} ]]; then + die -q "Not enough parameters" + elif [[ -n ${2} ]]; then + die -q "Too many parameters" + else + set_symlinks "${1}" + fi +} + +### update action ### + +describe_update() { + echo "Automatically update the awk implementation" +} + +describe_update_options() { + echo "ifunset : Do not override existing implementation" +} + +do_update() { + [[ -z ${1} || ( -z ${2} && ( ${1} == ifunset || ${1} == '--if-unset' ) ) ]] || \ + die -q "Usage error" + + [[ ( ${1} == ifunset || ${1} == '--if-unset' ) \ + && -L ${EROOT}/usr/bin/awk && -x ${EROOT}/usr/bin/awk ]] && \ + return + + set_symlinks 1 +} + +# vim: set syn=sh : diff --git a/modules/timezone.eselect b/modules/timezone.eselect new file mode 100644 index 0000000..d2abd57 --- /dev/null +++ b/modules/timezone.eselect @@ -0,0 +1,132 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id: $ + +DESCRIPTION="Manages timezone selection" +MAINTAINER="ottxor@gentoo.org" +VERSION="0.2" + +ZONE_DIR="${EROOT}/usr/share/zoneinfo" +## Functions ## + +# find a list of zones in ZONE_DIR +find_targets() { + local t + [[ -d ${ZONE_DIR}/${1} ]] || die -q "Directory ${1} does not exist in ${ZONE_DIR}" + for t in $(find "${ZONE_DIR}/${1}" -type f | sort ) ; do + [[ $(file ${t}) = *"timezone data"* ]] && echo ${t#${ZONE_DIR}/} + done +} + +### show action ### + +describe_show() { + echo "Show the current timezone selection" +} + +do_show() { + [[ -z ${@} ]] || die -q "Too many parameters" + + local zone + + [[ -f ${EROOT}/etc/timezone ]] && \ + zone=$(grep -e "^[^#]" "${EROOT}"/etc/timezone) + + write_list_start "Current timezone selection:" + if [[ -z ${zone} ]]; then + write_kv_list_entry "(unset in ${EROOT}/etc/timezone)" "" + elif [[ ! -f ${ZONE_DIR}/${zone} ]]; then + write_kv_list_entry "(invalid zone in ${EROOT}/etc/localtime)" "" + elif [[ -f ${EROOT}/etc/localtime ]]; then + cmp -s "${ZONE_DIR}/${zone}" "${EROOT}/etc/localtime" && \ + write_kv_list_entry "${zone}" "" || \ + write_kv_list_entry "(set to ${zone} in ${EROOT}/etc/timezone, but differs from ${EROOT}/etc/localtime" + else + write_kv_list_entry "(set to ${zone} in ${EROOT}/etc/timezone, but unset in ${EROOT}/etc/localtime)" "" + fi +} + +### list action ### + +describe_list() { + echo "List available timezones" +} + +describe_list_options() { + echo "basedir : Basedir to show zones from (from 'list' action)" +} + +describe_list_parameters() { + echo "[basedir]" +} + +do_list() { + local basedir= + if [[ -n ${1} ]]; then + basedir="${1}" + shift + [[ -d ${ZONE_DIR}/${basedir} ]] || die -q "Directory ${basedir} does not exist in ${ZONE_DIR}" + fi + + [[ -z ${@} ]] || die -q "Too many parameters" + + local i targets + + local zone + + zone=$(grep -e "^[^#]" "${EROOT}"/etc/timezone) + + targets=( $(find_targets "${basedir}") ) + for (( i = 0; i < ${#targets[@]}; i++ )) ; do + [[ ${targets[${i}]} == ${zone} ]] && \ + targets[${i}]=$(highlight_marker "${targets[${i}]}") + done + write_list_start "Available timezones:" + if [[ -z ${basedir} ]] ; then + write_numbered_list -m '(none found)' "${targets[@]}" + else + for (( i = 0; i < ${#targets[@]}; i++ )) ; do + write_kv_list_entry -p "${targets[i]}" "" + done + fi +} + +### set action ### + +describe_set() { + echo "Set a new timezone" +} + +describe_set_options() { + echo "target : Target name or number (from 'list' action)" +} + +describe_set_parameters() { + echo "" +} + +do_set() { + if [[ -z ${1} ]]; then + die -q "Not enough parameters" + elif [[ -n ${2} ]]; then + die -q "Too many parameters" + fi + + local target=${1} targets + + if is_number "${target}" && [[ ${target} -ge 1 ]]; then + targets=( $(find_targets "") ) + target=${targets[target-1]} + fi + + [[ -f ${ZONE_DIR}/${target} ]] || die -q "Target '${target}' doesn't appear to be valid!" + + #if localtime is a symlink cp would fail + rm -f "${EROOT}/etc/localtime" || die -q "Couldn't remove ${EROOT}/etc/localtime" + cp "${ZONE_DIR}/${target}" "${EROOT}"/etc/localtime || \ + die -q "Couldn't copy ${target} to ${EROOT}/etc/localtime" + echo "${target}" > "${EROOT}"/etc/timezone || \ + die -q "Couldn't save ${target} in ${EROOT}/etc/timezone" +} + +# vim: set syn=sh :