summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-02-04 20:21:42 +0100
committerDave Reisner <dreisner@archlinux.org>2013-02-05 02:21:52 +0100
commit85ae2bcd44de36b282ebe216ed64127d243e72c5 (patch)
tree55194b2983b8ee56c8b9c9d1f7224692e8cef35d
parente5b9d8a94576e11d7a19e7645328a9bccf90ce73 (diff)
downloadmkinitcpio-85ae2bcd44de36b282ebe216ed64127d243e72c5.tar.gz
mkinitcpio-85ae2bcd44de36b282ebe216ed64127d243e72c5.tar.xz
Add -P, --allpresets option
As a logical extension, allow the -p option to be specified multiple times in order to process several presets at once. Original-patch-by: Sébastien Luttringer <seblu@seblu.net> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r--bash-completion2
-rw-r--r--man/mkinitcpio.8.txt8
-rwxr-xr-xmkinitcpio27
3 files changed, 24 insertions, 13 deletions
diff --git a/bash-completion b/bash-completion
index 559b2f3..e7c1db0 100644
--- a/bash-completion
+++ b/bash-completion
@@ -63,7 +63,7 @@ _files_from_dirs() {
_mkinitcpio() {
local action cur prev opts
opts=(-A --addhooks -c --config -g --generate -H --hookhelp -h --help -k --kernel
- -L --listhooks -M --automods -n --nocolor -p --preset -r --moduleroot
+ -L --listhooks -M --automods -n --nocolor -P --allpresets -p --preset -r --moduleroot
-S --skiphooks -s --save -t --builddir -V --version -v --verbose -z --compress)
_get_comp_words_by_ref cur prev
diff --git a/man/mkinitcpio.8.txt b/man/mkinitcpio.8.txt
index 2b0f524..56ac571 100644
--- a/man/mkinitcpio.8.txt
+++ b/man/mkinitcpio.8.txt
@@ -57,10 +57,14 @@ Options
*-n, \--nocolor*::
Disable color output.
+*-P, \--allpresets*::
+ Process all presets contained in '/etc/mkinitcpio.d'. See the '-p' option for
+ more detail about presets.
+
*-p, \--preset* 'preset'::
Build initramfs image(s) according to specified 'preset'. This may be a file in
/etc/mkinitcpio.d (without the .preset extension) or a full, absolute path to a
- file.
+ file. This option may be specified multiple times to process multiple presets.
*-r, \--moduleroot* 'root'::
Specifies the root directory to find modules in, defaulting to '/'.
@@ -254,7 +258,7 @@ Files
Default configuration file for mkinitcpio.
'/etc/mkinitcpio.d'::
- Folder containing mkinitcpio presets.
+ Directory containing mkinitcpio presets.
'/usr/lib/initcpio/install'::
'/lib/initcpio/install'::
diff --git a/mkinitcpio b/mkinitcpio
index 9802fd5..1330a9b 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -17,11 +17,11 @@ _d_install="$PWD/install:/usr/lib/initcpio/install:/lib/initcpio/install"
_d_presets=mkinitcpio.d
# options and runtime data
-_optmoduleroot= _optkver= _optgenimg= _optpreset=
+_optmoduleroot= _optkver= _optgenimg=
_optcompress=
_optshowautomods=0 _optsavetree=0 _optshowmods=0
_optquiet=1 _optcolor=1
-_optskiphooks=() _optaddhooks=() _hooks=()
+_optskiphooks=() _optaddhooks=() _hooks=() _optpreset=()
declare -A _runhooks _addedmodules _modpaths _autodetect_cache
# export a sane PATH
@@ -236,7 +236,7 @@ build_image() {
fi
}
-process_preset() {
+process_preset() (
local preset=$1 preset_image= preset_options=
local -a preset_mkopts preset_cmd
@@ -245,7 +245,7 @@ process_preset() {
printf -v preset '%s/%s.preset' "$_d_presets" "$preset"
fi
- . "$preset" || die "Preset not found: \`%s'" "$preset"
+ . "$preset" 2>/dev/null || die "Preset not found: \`%s'" "$preset"
# Use -m and -v options specified earlier
(( _optquiet )) || preset_mkopts+=(-v)
@@ -253,7 +253,7 @@ process_preset() {
ret=0
for p in "${PRESETS[@]}"; do
- msg "Building image from preset: '$p'"
+ msg "Building image from preset: $preset: '$p'"
preset_cmd=("${preset_mkopts[@]}")
preset_kver=${p}_kver
@@ -291,7 +291,7 @@ process_preset() {
done
exit $ret
-}
+)
install_modules() {
local m moduledest=$BUILDROOT/lib/modules/$KERNELVERSION
@@ -339,9 +339,9 @@ install_modules() {
trap 'cleanup 130' INT
trap 'cleanup 143' TERM
-_opt_short='A:c:g:H:hk:nLMp:r:S:st:Vvz:'
+_opt_short='A:c:g:H:hk:nLMPp:r:S:st:Vvz:'
_opt_long=('add:' 'addhooks:' 'config:' 'generate:' 'hookhelp:' 'help'
- 'kernel:' 'listhooks' 'automods' 'moduleroot:' 'nocolor'
+ 'kernel:' 'listhooks' 'automods' 'moduleroot:' 'nocolor' 'allpresets'
'preset:' 'skiphooks:' 'save' 'builddir:' 'version' 'verbose' 'compress:')
parseopts "$_opt_short" "${_opt_long[@]}" -- "$@" || exit 1
@@ -378,7 +378,7 @@ while :; do
cleanup 0 ;;
-p|--preset)
shift
- _optpreset=$1 ;;
+ _optpreset+=("$1") ;;
-n|--nocolor)
_optcolor=0 ;;
-v|--verbose)
@@ -397,6 +397,10 @@ while :; do
exit 0 ;;
-M|--automods)
_optshowautomods=1 ;;
+ -P|--allpresets)
+ _optpreset=("$_d_presets"/*.preset)
+ [[ -e ${_optpreset[0]} ]] || die "No presets found in $_d_presets"
+ ;;
-t|--builddir)
shift
export TMPDIR=$1 ;;
@@ -424,7 +428,10 @@ fi
[[ -e /dev/fd ]] || die "/dev must be mounted!"
# use preset $_optpreset (exits after processing)
-[[ $_optpreset ]] && process_preset "$_optpreset"
+if (( ${#_optpreset[*]} )); then
+ map process_preset "${_optpreset[@]}"
+ exit
+fi
KERNELVERSION=$(resolve_kernver "$_optkver") || cleanup 1
_d_kmoduledir=$_optmoduleroot/lib/modules/$KERNELVERSION