blob: b11495df20bfb60e8a939a36b3fa41f4596a29e6 (
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
|
#!/bin/bash
INCLUDE_CONF_SH=conf.sh
LIBREUSER="${SUDO_USER:-$USER}"
LIBREHOME="$(eval echo ~$LIBREUSER)"
if [[ -z ${XDG_CONFIG_HOME:-} ]]; then
export XDG_CONFIG_HOME="${LIBREHOME}/.config"
fi
# Generic functions ############################################################
get_files() {
local slug=$1
case $slug in
makepkg.conf)
if [[ $MAKEPKG_CONF != /etc/$slug && -r $MAKEPKG_CONF ]]; then
echo "$MAKEPKG_CONF"
else
echo /etc/$slug
echo "$LIBREHOME/.$slug"
fi
;;
libretools.conf)
echo /etc/$slug
echo "$XDG_CONFIG_HOME/libretools/$slug"
;;
*.conf)
echo /etc/libretools.d/$slug
echo "$XDG_CONFIG_HOME/libretools/$slug"
;;
esac
}
load_files() {
for file in $(get_files $1.conf); do
if [[ -r $file ]]; then
. "$file"
fi
done
}
check_vars() {
local slug=$1
shift
local ret=0
for VAR in "$@"; do
if [[ -z ${!VAR} ]]; then
if [[ $(get_files $slug|wc -l) > 1 ]]; then
echo "Configure '$VAR' in one of:"
get_files $slug | sed 's/./ -> &/'
else
echo "Configure '$VAR' in $(get_files $slug)"
fi
ret=1
fi >>/dev/stderr
done
if [[ $ret != 0 ]]; then
return 1
fi
}
# makepkg configuration ########################################################
[[ -n ${MAKEPKG_CONF:-} ]] || MAKEPKG_CONF=/etc/makepkg.conf
load_conf_makepkg() {
load_files makepkg
}
get_conf_makepkg() (
set +euE
local setting=$1
local default=$2
load_conf_makepkg
printf '%s\n' "${!setting:-${default}}"
)
set_conf_makepkg() {
local key=$1
local val=$2
for file in `get_files makepkg.conf|tac`; do
if [[ -w $file ]]; then
sed -i "/^\s*$key=/d" "$file"
echo "$key='$val'" >> "$file"
return 0
fi
done
return 1
}
# libretools configuration #####################################################
check_conf_libretools() {
check_vars libretools.conf \
PARABOLAHOST LIBREDESTDIR BLACKLIST WORKDIR REPOS ARCHES \
ABSLIBREGIT COMMITCMD DIFFTOOL FULLBUILDCMD SIGEXT SIGID
}
load_conf_libretools() {
load_files libretools
check_conf_libretools
}
load_conf_libretools_chroot() {
load_files chroot
# Exclude CHROOTEXTRAPKG from the checks because an empty value is valid
if [[ -f /.arch-chroot ]]; then
# inside of a chroot, only CHROOTEXTRAPKG needs to be set, but
# as stated above, we don't check for it.
:
else
check_vars chroot.conf CHROOTDIR CHROOT
fi
}
|