1 |
Joshua Kinard wrote: |
2 |
> Basically what I am suggesting is finding a sane way to politely tell users |
3 |
> who set INSTALL_MASK locally that specific to systemd/udev packages, they |
4 |
> risk breaking their system if using it or migrating to it. Optionally, |
5 |
> telling them the same thing if they install a package that also installs |
6 |
> unit files. |
7 |
> |
8 |
> TBH, expanding on the idea, it doesn't even have to be specific to |
9 |
> systemd/udev, but a generic framework that can be used by ebuilds to warn |
10 |
> the user of invalid configurations that could render a system package (or |
11 |
> their system) unusable unless they change their configuration. |
12 |
> |
13 |
> This still leaves the power in the hands of the user to configure things how |
14 |
> they want (E.g., setting INSTALL_MASK). It also allows us devs to avoid |
15 |
> adding another variable into an already complex equation (having to decide |
16 |
> on INSTALL_MASK_ORDER settings for all archs/profiles). Package maintainers |
17 |
> are free to check for known problematic settings in make.conf or the envvars |
18 |
> and warn the user appropriately in their packages. If the user chooses to |
19 |
> proceed anyways, well, they were warned... |
20 |
> |
21 |
> W/o grepping the tree, I wouldn't be surprised if some ebuilds already do |
22 |
> this in some form. Basic grep on make.conf, ewarn or eerror if a problem |
23 |
> setting is discovered. Setup some function in eutils instead to do this: |
24 |
> |
25 |
> echeck_var_warn("INSTALL_MASK", "/usr/lib/systemd") |
26 |
> echeck_var_error("INSTALL_MASK", "/usr/lib/systemd") |
27 |
> |
28 |
> Etc... |
29 |
> |
30 |
> Brainstorming. If the idea is silly or nonsensical, well, then someone |
31 |
> propose something better. |
32 |
|
33 |
No, it makes a lot of sense. Though you don't use parentheses or commas |
34 |
in bash ;) |
35 |
|
36 |
I'd use something like: |
37 |
# echeck_warn -s : INSTALL_MASK /usr/lib/systemd |
38 |
echeck_warn(){ |
39 |
echeck_var warn "$@" |
40 |
} |
41 |
|
42 |
echeck_error(){ |
43 |
echeck_var error "$@" |
44 |
} |
45 |
|
46 |
echeck_var(){ |
47 |
local v n i f x r=0 s=' ' |
48 |
case $1 in |
49 |
warn) f=ewarn |
50 |
;; error) f=eerror |
51 |
;; *) die "bad use of: '$FUNCNAME $*'" |
52 |
esac |
53 |
shift |
54 |
[[ $1 = -s ]] && { |
55 |
s=$2; shift 2; |
56 |
# handle PATH style |
57 |
[[ $s = : ]] && x='/*' |
58 |
} |
59 |
v="$s${!1}$s" || die "bad var: $1" |
60 |
n=$1 |
61 |
shift |
62 |
for i; do |
63 |
if [[ $v = *"$s$i$s"* ]]; then |
64 |
: |
65 |
elif [[ $x ]]; then |
66 |
if [[ $v = *"$s$i$x$s"* ]]; then |
67 |
: |
68 |
elif [[ $i = */ ]] && [[ $v = *"$s$i*$s"* ]]; then |
69 |
: |
70 |
else continue |
71 |
fi |
72 |
else continue |
73 |
fi |
74 |
"$f" "$n contains: '$i'" |
75 |
r=1 |
76 |
done |
77 |
if ((r)) && [[ $f = eerror ]]; then |
78 |
die "Bad $n" |
79 |
else |
80 |
return $r |
81 |
fi |
82 |
} |
83 |
|
84 |
eg: |
85 |
$ INSTALL_MASK='/lib/udev/*:/usr/lib/systemd/*' |
86 |
$ echeck_error -s : INSTALL_MASK /lib/udev /usr/lib/systemd/ |
87 |
!! INSTALL_MASK contains: '/lib/udev' |
88 |
!! INSTALL_MASK contains: '/usr/lib/systemd/' |
89 |
!! die: Bad INSTALL_MASK |
90 |
|
91 |
You'd replace literal * in: [[ $v = *"$s$i*$s"* ]] with: ${x#/} |
92 |
for something more complex. And you might prefer simple return |
93 |
and use echeck_error .. || die .. |
94 |
HTH as a start. |
95 |
|
96 |
Regards, |
97 |
steveL |
98 |
-- |
99 |
#friendly-coders -- We're friendly, but we're not /that/ friendly ;-) |