aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Stephen P. Bennett <spb@exherbo.org> 2006-09-08 22:10:04 +0000
committerAvatar Stephen P. Bennett <spb@exherbo.org> 2006-09-08 22:10:04 +0000
commit570fb9f4d921bb1b92c9a85dc174cc1e5a0d98f1 (patch)
tree662ecdcef5329442f3a67162ac3cfcd77c53efd2
parenteec604897e5b7333d1949c79a775c40beb6541db (diff)
downloadpaludis-570fb9f4d921bb1b92c9a85dc174cc1e5a0d98f1.tar.gz
paludis-570fb9f4d921bb1b92c9a85dc174cc1e5a0d98f1.tar.xz
Add repo.eselect
-rw-r--r--eselect/Makefile.am3
-rw-r--r--eselect/repo.eselect204
2 files changed, 206 insertions, 1 deletions
diff --git a/eselect/Makefile.am b/eselect/Makefile.am
index 0130e12..f207d2e 100644
--- a/eselect/Makefile.am
+++ b/eselect/Makefile.am
@@ -5,7 +5,8 @@ SUBDIRS = .
installeselectdir = $(datadir)/eselect/modules/
installeselect_SCRIPTS = \
- news.eselect
+ news.eselect \
+ repo.eselect
TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="$(srcdir)/ebuild/" \
diff --git a/eselect/repo.eselect b/eselect/repo.eselect
new file mode 100644
index 0000000..e62e360
--- /dev/null
+++ b/eselect/repo.eselect
@@ -0,0 +1,204 @@
+# Copyright 1999-2006 Stephen Bennett <spb@gentoo.org>
+# Distributed under the terms of the GNU General Public License v2
+# $Id: $
+
+DESCRIPTION="Manage Paludis repository config files"
+MAINTAINER="spb@gentoo.org"
+SVN_DATE='$Date: $'
+VERSION=$(svn_date_to_version "${SVN_DATE}" )
+
+REPO_CONFIG_FILE="${ROOT}/var/lib/eselect/repo/repo.config"
+
+inherit config
+
+## {{{ Utility functions
+
+cat_file() {
+ local filename=$1
+ if [[ -r ${filename} ]]; then
+ cat "${filename}"
+ elif [[ ${filename} == http://* ]]; then
+ wget -O - -q "${filename}"
+ elif [[ ${filename} == svn://* ]]; then
+ svn cat "${filename}"
+ elif [[ ${filename} != */* ]]; then
+ templateroot="$(get_var template_root)"
+ cat_file "${templateroot}/${filename}.templ"
+ else
+ die -q "Couldn't load ${filename}"
+ fi
+}
+
+get_var() {
+ default_template_root="http://svn.pioto.org/paludis/repo-templates"
+ default_repo_root="${ROOT}/var/paludis/repositories"
+ default_config_root="${ROOT}/etc/paludis"
+ if [[ -L /etc/make.profile ]]; then
+ default_profiles="$(readlink -f /etc/make.profile)"
+ fi
+ local var=$1
+ local defvar="default_$1"
+ local value="$(load_config ${REPO_CONFIG_FILE} "${var}")"
+ if [[ -z "${value}" ]]; then
+ value=${!defvar}
+ fi
+ echo "${value}"
+}
+
+## }}}
+
+### list action
+
+## {{{ list stuff
+describe_list() {
+ echo "Show available repository templates"
+}
+
+do_list() {
+ templateroot=$(get_var template_root)
+
+ local -a list=( $(cat_file ${templateroot}/list) )
+ write_list_start "Available repository templates: (* == installed)"
+ local count=0
+ for i in "${list[@]}"; do
+ local inst=''
+ if [[ -e $(get_var config_root)/repositories/${i}.conf ]]; then
+ inst=$(highlight \*)
+ fi
+ write_numbered_list_entry $(( ++count )) "${i} ${inst}"
+ done
+}
+## }}}
+
+### install action
+
+## {{{ install stuff
+describe_install() {
+ echo "Install a repository config from a given template name"
+}
+
+do_install() {
+ local force=0
+ if [[ $1 == -f ]] || [[ $1 == --force ]]; then
+ force=1
+ shift
+ fi
+
+ if [[ -e $(get_var config_root)/repositories/$1.conf ]] && [[ $force == 0 ]]; then
+ write_error_msg "$1 appears to be already installed. "
+ write_error_msg "To overwrite it, use --force or -f."
+ die -q "Repository already exists and --force not specified"
+ fi
+
+ do_subst() {
+ if [[ $1 == location_of ]]; then
+ echo $(paludis --list-repositories --repository $2 | sed -n \
+ 's/.*location: *//p') || die -q "Couldn't find location of $2"
+ elif [[ $1 == profiles ]]; then
+ profiles=$(get_var profiles)
+ if [[ -z ${profiles} ]]; then
+ die -q "profile expansion requested but no profiles set."
+ fi
+ echo ${profiles}
+ elif [[ $1 == repo_root ]]; then
+ echo $(get_var repo_root)
+ fi
+ }
+
+ ( cat_file $1 || die -q "Couldn't read template $1" ) | (
+ local format=portage
+ while read line; do
+ while [[ $line == *@*@* ]]; do
+ subst=${line#*@}
+ subst=${subst%%@*}
+ line=${line%%@*}$(do_subst ${subst})${line#*@*@}
+ done
+ if [[ ${line} == format=* ]]; then
+ format=${line#format=}
+ fi
+ echo $line
+ done;
+ if [[ ${format} == portage ]]; then
+ distdir=$(get_var distdir)
+ [[ -n ${distdir} ]] && echo "distdir=${distdir}"
+ fi
+ ) >"$(get_var config_root)/repositories/$1.conf.tmp"
+
+ if [[ ! -f "$(get_var config_root)/repositories/$1.conf)" ]]; then
+ mv $(get_var config_root)/repositories/$1.conf{.tmp,}
+ else
+ die -q "Error creating ${1}.conf"
+ fi
+}
+
+## }}}
+
+### uninstall action
+
+## {{{ uninstall stuff
+
+describe_uninstall()
+{
+ echo "Remove a repository config"
+}
+
+do_uninstall() {
+ repo_dir="$(get_var config_root)/repositories"
+ for i in "$@"; do
+ if [[ -f "${repo_dir}/${i}.conf" ]]; then
+ rm -f "${repo_dir}/${i}.conf"
+ else
+ write_error_msg "Repository '${i}' not found at"
+ write_error_msg "${repo_dir}/${i}.conf"
+ fi
+ done
+}
+
+## }}}
+
+### set action
+
+## {{{ set stuff
+
+describe_set()
+{
+ echo "Set various config values"
+}
+
+do_set()
+{
+ if [[ $# -ge 2 ]]; then
+ var=$1; shift
+ store_config ${REPO_CONFIG_FILE} $var "$*"
+ fi
+}
+
+## }}}
+
+### show action
+
+## {{{ show stuff
+
+describe_show()
+{
+ echo "Display various configuration variables"
+}
+
+do_show()
+{
+ if [[ -n $1 ]]; then
+ vars=$1
+ else
+ vars=( template_root repo_root profiles distdir config_root )
+ write_list_start "Current configuration variables:"
+ for i in $vars; do
+ if value=$(load_config ${REPO_CONFIG_FILE} $i); then
+ write_kv_list_entry $i "${value}"
+ fi
+ done
+ fi
+}
+
+## }}}
+
+# vim: ts=4 sw=4 noet fdm=marker