blob: fa1ad4808972ab6f0379cdd2b57f14f9e6c97d13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4
DESCRIPTION="Standard system configuration files"
HOMEPAGE="http://0pointer.de/blog/projects/the-new-configuration-files.html"
SRC_URI=""
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64"
# guess: guess the configuration from existing file, from openrc, or by
# executing commands, in that order
IUSE="+guess"
DEPEND=""
RDEPEND="${DEPEND}"
parse_value() {
local vname="$1"
local fname="$2"
local value
test -e "${fname}" || return
value="$(grep -i "^${vname}" "${fname}")"
value="${value#*=}"
value="${value#\"}"
value="${value%\"}"
value="${value#\'}"
value="${value%\'}"
echo -n "${value}"
}
claim-file() {
local fname="$1"
local bname="$(basename "${fname}")"
if test -e "${fname}"; then
cat "${fname}" >"${bname}"
else
return 1
fi
}
etc-hostname() {
claim-file /etc/hostname && return
local hostname
local fname=/etc/conf.d/hostname
use guess || ewarn "/etc/hostname must be manually created"
use guess || return
if test -e "${fname}"; then
echo "$(parse_value hostname "${fname}")" >hostname
else
echo "$(hostname)" >hostname
fi
einfo "guessed hostname: \"$(cat hostname)\""
}
print-if-nonempty-k-v-new-file() {
print_if_nonempty_k_v_file="$1"
test -e "$1" && rm "$1"
}
print-if-nonempty-k-v() {
local str="$@"
local key="${str%%=*}"
local value="${str#*=}"
test -n "${value}" &&
echo "${key}=${value}" >>"${print_if_nonempty_k_v_file}"
return 0
}
etc-vconsole.conf() {
claim-file /etc/vconsole.conf && return
use guess || return
#local vc_unicode="`parse_value unicode /etc/rc.conf`"
#local utf8="YES"
local vc_font="`parse_value consolefont /etc/conf.d/consolefont`"
local vc_font_map="`parse_value consoletranslation /etc/conf.d/consolefont`"
local vc_font_unimap="`parse_value unicodemap /etc/conf.d/consolefont`"
local vc_keymap="`parse_value keymap /etc/conf.d/keymaps`"
local vc_keymap_toggle="`parse_value keymap_toggle /etc/vconsole.conf`"
print-if-nonempty-k-v-new-file vconsole.conf
print-if-nonempty-k-v KEYMAP="$vc_keymap"
print-if-nonempty-k-v KEYMAP_TOGGLE="$vc_keymap_toggle"
print-if-nonempty-k-v FONT="$vc_font"
print-if-nonempty-k-v FONT_MAP="$vc_font_map"
print-if-nonempty-k-v FONT_UNIMAP="$vc_font_unimap"
}
etc-locale.conf() {
claim-file /etc/locale.conf && return
use guess || return
local fname=/etc/profile.env
print-if-nonempty-k-v-new-file locale.conf
for vn in LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT \
LC_IDENTIFICATION; do
print-if-nonempty-k-v ${vn}="$(parse_value "export $vn" "${fname}")"
done
}
src_unpack() {
mkdir -p "${S}"
}
src_configure() {
etc-hostname && einfo "hostname"
etc-vconsole.conf && einfo "vconsole.conf"
etc-locale.conf && einfo "locale.conf"
}
src_install() {
insinto /etc
doins *
}
|