summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-09-28 19:54:10 +0200
committerDave Reisner <dreisner@archlinux.org>2012-10-07 02:38:02 +0200
commit367ac227f42ca9c8a7c050da0bcc04248fae29b1 (patch)
treef40bebd836e87a884b1995fac189d1da5edc6b42 /install
parent4bbca4a841eb6810b003009838cb681fd7ace07a (diff)
downloadmkinitcpio-367ac227f42ca9c8a7c050da0bcc04248fae29b1.tar.gz
mkinitcpio-367ac227f42ca9c8a7c050da0bcc04248fae29b1.tar.xz
commit to some level of style in variable naming
This is an ugly patch, and probably does more than I'd like it to. The idea is that mkinitcpio adopts some sort of consistent style which I'm actually happy with. I define 3 kinds of variables: 1) local variables: all lower case, and scoped within functions. Use freely, as they're well contained. 2) global variables: these are known to mkinitcpio internally, but are global in scope. They mainly carry runtime configuration and collected data during the image generation process. These are always lower case, but carry a leading underscore to denote that they're global. 3) "API" variables: also global in scope, but exist "outside" of mkinitcpio -- either drawn in from the configuration file, or "exported" to the install hooks. These are always all upper case. When introducing new variables, extreme care must be taken to pick names that will not conflict with the environment inherited by mkinitcpio. A HACKING file is introduced with a similar description of the above, and more. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'install')
-rw-r--r--install/autodetect17
1 files changed, 9 insertions, 8 deletions
diff --git a/install/autodetect b/install/autodetect
index c0c7563..4f1e4bb 100644
--- a/install/autodetect
+++ b/install/autodetect
@@ -3,17 +3,17 @@
build() {
local -a md_devs
- MODULE_FILE=$workdir/autodetect_modules
+ _f_autodetect_cache=$_d_workdir/autodetect_modules
add_if_avail() {
local resolved
# treat this as an alias, since ext3 might be aliased to ext4.
IFS=$'\n' read -rd '' -a resolved < \
- <(modprobe -d "$MODULEROOT" -S "$KERNELVERSION" -R "$1" 2>/dev/null)
+ <(modprobe -d "$_optmoduleroot" -S "$KERNELVERSION" -R "$1" 2>/dev/null)
if (( ${#resolved[*]} )); then
- printf '%s\n' "${resolved[@]}" >>"$MODULE_FILE"
+ printf '%s\n' "${resolved[@]}" >>"$_f_autodetect_cache"
fi
}
@@ -22,7 +22,7 @@ build() {
return 1
fi
- auto_modules >"$MODULE_FILE"
+ auto_modules >"$_f_autodetect_cache"
# detect filesystem for root
if rootfstype=$(findmnt -uno fstype '/'); then
@@ -40,12 +40,13 @@ build() {
# scan for md raid devices
md_devs=(/sys/class/block/md*/md/level)
if [[ -e $md_devs ]]; then
- (( !QUIET )) && plain "found %d mdadm arrays to scan" "${#md_devs[*]}"
- awk '{ gsub(/raid[456]/, "raid456"); print; }' "${md_devs[@]}" | sort -u >>"$MODULE_FILE"
+ quiet "found %d mdadm arrays to scan" "${#md_devs[*]}"
+ awk '{ gsub(/raid[456]/, "raid456"); print; }' "${md_devs[@]}" |
+ sort -u >>"$_f_autodetect_cache"
fi
- if (( !QUIET )) && [[ -s $MODULE_FILE ]]; then
- plain "caching %d modules" $(wc -l < "$MODULE_FILE")
+ if [[ -s $_f_autodetect_cache ]]; then
+ quiet "caching %d modules" $(wc -l < "$_f_autodetect_cache")
fi
}