[arch-projects] [mkinitcpio] [PATCH 1/3] mkinitcpio: add -T option
The -T (--targetdirectory) option writes the root of the generated image directly to the specified directory. Useful for generating a shutdown-ramfs with mkinitcpio -T /run/initramfs/. --- functions | 35 ++++++++++++++++++----------------- mkinitcpio | 19 ++++++++++++++----- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/functions b/functions index f0dce80..acec621 100644 --- a/functions +++ b/functions @@ -627,45 +627,46 @@ initialize_buildroot() { # creates a temporary directory for the buildroot and initialize it with a # basic set of necessary directories and symlinks - local workdir= kernver=$1 arch=$(uname -m) + local workdir= kernver=$1 arch=$(uname -m) buildroot=$2 if ! workdir=$(mktemp -d --tmpdir mkinitcpio.XXXXXX); then error 'Failed to create temporary working directory in %s' "${TMPDIR:-/tmp}" return 1 fi + [[ -z $buildroot ]] && buildroot=$workdir/root # base directory structure - install -dm755 "$workdir/root"/{new_root,proc,sys,dev,run,tmp,etc,usr/{local,lib,bin}} - ln -s "usr/lib" "$workdir/root/lib" - ln -s "../lib" "$workdir/root/usr/local/lib" - ln -s "bin" "$workdir/root/usr/sbin" - ln -s "usr/bin" "$workdir/root/bin" - ln -s "usr/bin" "$workdir/root/sbin" - ln -s "../bin" "$workdir/root/usr/local/bin" - ln -s "../bin" "$workdir/root/usr/local/sbin" + install -dm755 "$buildroot"/{new_root,proc,sys,dev,run,tmp,etc,usr/{local,lib,bin}} + ln -s "usr/lib" "$buildroot/lib" + ln -s "../lib" "$buildroot/usr/local/lib" + ln -s "bin" "$buildroot/usr/sbin" + ln -s "usr/bin" "$buildroot/bin" + ln -s "usr/bin" "$buildroot/sbin" + ln -s "../bin" "$buildroot/usr/local/bin" + ln -s "../bin" "$buildroot/usr/local/sbin" case $arch in x86_64) - ln -s "lib" "$workdir/root/usr/lib64" - ln -s "usr/lib" "$workdir/root/lib64" + ln -s "lib" "$buildroot/usr/lib64" + ln -s "usr/lib" "$buildroot/lib64" ;; esac # mkinitcpio version stamp - printf '%s' "$version" >"$workdir/root/VERSION" + printf '%s' "$version" >"$buildroot/VERSION" # kernel module dir - install -dm755 "$workdir/root/usr/lib/modules/$kernver/kernel" + install -dm755 "$buildroot/usr/lib/modules/$kernver/kernel" # mount tables - ln -s /proc/self/mounts "$workdir/root/etc/mtab" - >"$workdir/root/etc/fstab" + ln -s /proc/self/mounts "$buildroot/etc/mtab" + >"$buildroot/etc/fstab" # indicate that this is an initramfs - >"$workdir/root/etc/initrd-release" + >"$buildroot/etc/initrd-release" # add a blank ld.so.conf to keep ldconfig happy - >"$workdir/root/etc/ld.so.conf" + >"$buildroot/etc/ld.so.conf" printf '%s' "$workdir" } diff --git a/mkinitcpio b/mkinitcpio index 7ce6c5c..489e199 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -19,7 +19,7 @@ _d_presets=mkinitcpio.d # options and runtime data _optmoduleroot= _optkver= _optgenimg= -_optcompress= +_optcompress= _opttargetdir= _optshowautomods=0 _optsavetree=0 _optshowmods=0 _optquiet=1 _optcolor=1 _optskiphooks=() _optaddhooks=() _hooks=() _optpreset=() @@ -53,6 +53,7 @@ usage: ${0##*/} [options] -r, --moduleroot <dir> Root directory for modules (default: /) -S, --skiphooks <hooks> Skip specified hooks, comma-separated, during build -s, --save Save build directory. (default: no) + -T, --targetdirectory <dir> Write generated image into <dir> -t, --builddir <dir> Use DIR as the temporary build directory -V, --version Display version information and exit -v, --verbose Verbose output (default: no) @@ -298,10 +299,10 @@ process_preset() ( trap 'cleanup 130' INT trap 'cleanup 143' TERM -_opt_short='A:c:g:H:hk:nLMPp:r:S:st:Vvz:' +_opt_short='A:c:g:H:hk:nLMPp:r:S:sT:t:Vvz:' _opt_long=('add:' 'addhooks:' 'config:' 'generate:' 'hookhelp:' 'help' 'kernel:' 'listhooks' 'automods' 'moduleroot:' 'nocolor' 'allpresets' - 'preset:' 'skiphooks:' 'save' 'builddir:' 'version' 'verbose' 'compress:') + 'preset:' 'skiphooks:' 'save' 'targetdirectory:' 'builddir:' 'version' 'verbose' 'compress:') parseopts "$_opt_short" "${_opt_long[@]}" -- "$@" || exit 1 set -- "${OPTRET[@]}" @@ -327,6 +328,10 @@ while :; do -s|--save) _optsavetree=1 ;; + -T|--targetdirectory) + shift + _opttargetdir=$1 + ;; -g|--generate) shift [[ -d $1 ]] && die "Invalid image path -- must not be a directory" @@ -414,8 +419,12 @@ KERNELVERSION=$(resolve_kernver "$_optkver") || cleanup 1 _d_kmoduledir=$_optmoduleroot/lib/modules/$KERNELVERSION [[ -d $_d_kmoduledir ]] || die "'$_d_kmoduledir' is not a valid kernel module directory" -_d_workdir=$(initialize_buildroot "$KERNELVERSION") || cleanup 1 -BUILDROOT=$_d_workdir/root +_d_workdir=$(initialize_buildroot "$KERNELVERSION" $_opttargetdir) || cleanup 1 +if [[ -z $_opttargetdir ]]; then + BUILDROOT=$_d_workdir/root +else + BUILDROOT=$_opttargetdir +fi . "$_f_config" || die "Failed to read configuration \`%s'" "$_f_config" -- 1.8.4.2
--- mkinitcpio | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/mkinitcpio b/mkinitcpio index 489e199..16f1b98 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -444,19 +444,21 @@ if (( _optshowautomods )); then cleanup 0 fi -if [[ -z $_optgenimg ]]; then +if [[ ( -z $_optgenimg && -z $_optsavetree ) ]]; then msg "Starting dry run: %s" "$KERNELVERSION" else - # check for permissions. if the image doesn't already exist, - # then check the directory - if [[ ( -e $_optgenimg && ! -w $_optgenimg ) || - ( ! -d ${_optgenimg%/*} || ! -w ${_optgenimg%/*} ) ]]; then - die 'Unable to write to %s' "$_optgenimg" - fi + if [[ $_optgenimg ]]; then + # check for permissions. if the image doesn't already exist, + # then check the directory + if [[ ( -e $_optgenimg && ! -w $_optgenimg ) || + ( ! -d ${_optgenimg%/*} || ! -w ${_optgenimg%/*} ) ]]; then + die 'Unable to write to %s' "$_optgenimg" + fi - _optcompress=${_optcompress:-${COMPRESSION:-gzip}} - if ! type -P "$_optcompress" >/dev/null; then - die "Unable to locate compression method: %s" "$_optcompress" + _optcompress=${_optcompress:-${COMPRESSION:-gzip}} + if ! type -P "$_optcompress" >/dev/null; then + die "Unable to locate compression method: %s" "$_optcompress" + fi fi msg "Starting build: %s" "$KERNELVERSION" @@ -498,6 +500,8 @@ ldconfig -r "$BUILDROOT" &>/dev/null if [[ $_optgenimg ]]; then build_image "$_optgenimg" "$_optcompress" +elif [[ $_optsavetree ]]; then + msg "Build complete." else msg "Dry run complete, use -g IMAGE to generate a real image" fi -- 1.8.4.2
On Mon, Nov 18, 2013 at 08:21:47PM +0100, Thomas Bächler wrote:
--- mkinitcpio | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/mkinitcpio b/mkinitcpio index 489e199..16f1b98 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -444,19 +444,21 @@ if (( _optshowautomods )); then cleanup 0 fi
-if [[ -z $_optgenimg ]]; then +if [[ ( -z $_optgenimg && -z $_optsavetree ) ]]; then
Did you mean to check $_opttargetdir rather than $_optsavetree?
msg "Starting dry run: %s" "$KERNELVERSION" else
I think you save yourself some patch noise by making this an elif on the $_optgenimg conditional.
- # check for permissions. if the image doesn't already exist, - # then check the directory - if [[ ( -e $_optgenimg && ! -w $_optgenimg ) || - ( ! -d ${_optgenimg%/*} || ! -w ${_optgenimg%/*} ) ]]; then - die 'Unable to write to %s' "$_optgenimg" - fi + if [[ $_optgenimg ]]; then + # check for permissions. if the image doesn't already exist, + # then check the directory + if [[ ( -e $_optgenimg && ! -w $_optgenimg ) || + ( ! -d ${_optgenimg%/*} || ! -w ${_optgenimg%/*} ) ]]; then + die 'Unable to write to %s' "$_optgenimg" + fi
- _optcompress=${_optcompress:-${COMPRESSION:-gzip}} - if ! type -P "$_optcompress" >/dev/null; then - die "Unable to locate compression method: %s" "$_optcompress" + _optcompress=${_optcompress:-${COMPRESSION:-gzip}} + if ! type -P "$_optcompress" >/dev/null; then + die "Unable to locate compression method: %s" "$_optcompress" + fi fi
msg "Starting build: %s" "$KERNELVERSION" @@ -498,6 +500,8 @@ ldconfig -r "$BUILDROOT" &>/dev/null
if [[ $_optgenimg ]]; then build_image "$_optgenimg" "$_optcompress" +elif [[ $_optsavetree ]]; then + msg "Build complete."
Maybe reaffirm the output directory here?
else msg "Dry run complete, use -g IMAGE to generate a real image" fi -- 1.8.4.2
Am 19.11.2013 04:17, schrieb Dave Reisner:
On Mon, Nov 18, 2013 at 08:21:47PM +0100, Thomas Bächler wrote:
--- mkinitcpio | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/mkinitcpio b/mkinitcpio index 489e199..16f1b98 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -444,19 +444,21 @@ if (( _optshowautomods )); then cleanup 0 fi
-if [[ -z $_optgenimg ]]; then +if [[ ( -z $_optgenimg && -z $_optsavetree ) ]]; then
Did you mean to check $_opttargetdir rather than $_optsavetree?
I think I did.
msg "Starting dry run: %s" "$KERNELVERSION" else
I think you save yourself some patch noise by making this an elif on the $_optgenimg conditional.
Patch looks nice when you ignore whitespace :) I'll have another look.
- # check for permissions. if the image doesn't already exist, - # then check the directory - if [[ ( -e $_optgenimg && ! -w $_optgenimg ) || - ( ! -d ${_optgenimg%/*} || ! -w ${_optgenimg%/*} ) ]]; then - die 'Unable to write to %s' "$_optgenimg" - fi + if [[ $_optgenimg ]]; then + # check for permissions. if the image doesn't already exist, + # then check the directory + if [[ ( -e $_optgenimg && ! -w $_optgenimg ) || + ( ! -d ${_optgenimg%/*} || ! -w ${_optgenimg%/*} ) ]]; then + die 'Unable to write to %s' "$_optgenimg" + fi
- _optcompress=${_optcompress:-${COMPRESSION:-gzip}} - if ! type -P "$_optcompress" >/dev/null; then - die "Unable to locate compression method: %s" "$_optcompress" + _optcompress=${_optcompress:-${COMPRESSION:-gzip}} + if ! type -P "$_optcompress" >/dev/null; then + die "Unable to locate compression method: %s" "$_optcompress" + fi fi
msg "Starting build: %s" "$KERNELVERSION" @@ -498,6 +500,8 @@ ldconfig -r "$BUILDROOT" &>/dev/null
if [[ $_optgenimg ]]; then build_image "$_optgenimg" "$_optcompress" +elif [[ $_optsavetree ]]; then + msg "Build complete."
Maybe reaffirm the output directory here?
If the output directory cannot be accessed, the build should already have failed in initialize_buildoot, right?
When enabled, this service generates an "initramfs" that systemd pivots to on shutdown to ensure clean umounting and shutdown of loop and dm devices. The actual work is done by systemd-shutdown. --- Makefile | 4 +++- install/sd-shutdown | 14 ++++++++++++++ mkinitcpio-generate-shutdown-ramfs.service | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 install/sd-shutdown create mode 100644 mkinitcpio-generate-shutdown-ramfs.service diff --git a/Makefile b/Makefile index 1b933c9..38a7111 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,8 @@ DIRS = \ /usr/share/man/man8 \ /usr/share/man/man5 \ /usr/share/man/man1 \ - /usr/share/mkinitcpio + /usr/share/mkinitcpio \ + /usr/lib/systemd/system all: doc @@ -48,6 +49,7 @@ install: all cp -at $(DESTDIR)/usr/lib/initcpio hooks install install -m644 -t $(DESTDIR)/usr/share/mkinitcpio mkinitcpio.d/* + install -m644 mkinitcpio-generate-shutdown-ramfs.service $(DESTDIR)/usr/lib/systemd/system/mkinitcpio-generate-shutdown-ramfs.service install -m755 50-mkinitcpio.install $(DESTDIR)/usr/lib/kernel/install.d/50-mkinitcpio.install diff --git a/install/sd-shutdown b/install/sd-shutdown new file mode 100644 index 0000000..7e86dad --- /dev/null +++ b/install/sd-shutdown @@ -0,0 +1,14 @@ +#!/bin/bash + +build() { + add_binary /usr/lib/systemd/systemd-shutdown /shutdown +} + +help() { + cat <<HELPEOF +This hook adds systemd-shutdown to the initramfs. This is only +if the image is extracted to /run/initramfs before shutdown. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/mkinitcpio-generate-shutdown-ramfs.service b/mkinitcpio-generate-shutdown-ramfs.service new file mode 100644 index 0000000..4a147be --- /dev/null +++ b/mkinitcpio-generate-shutdown-ramfs.service @@ -0,0 +1,15 @@ +[Unit] +Description=Generate shutdown-ramfs +DefaultDependencies=no +Before=shutdown.target +ConditionFileIsExecutable=!/run/initramfs/shutdown + +[Service] +Type=oneshot +# /tmp could be umounted at this point +# use /run as temporary directory +Environment=TMPDIR=/run +ExecStart=/usr/bin/mkinitcpio -A sd-shutdown -c /dev/null -T /run/initramfs + +[Install] +WantedBy=shutdown.target -- 1.8.4.2
On Mon, Nov 18, 2013 at 08:21:48PM +0100, Thomas Bächler wrote:
When enabled, this service generates an "initramfs" that systemd pivots to on shutdown to ensure clean umounting and shutdown of loop and dm devices.
The actual work is done by systemd-shutdown. ---
No code comments here, but.... I love how simple this was all to implement with existing mkinitcpio machinery...
Makefile | 4 +++- install/sd-shutdown | 14 ++++++++++++++ mkinitcpio-generate-shutdown-ramfs.service | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 install/sd-shutdown create mode 100644 mkinitcpio-generate-shutdown-ramfs.service
diff --git a/Makefile b/Makefile index 1b933c9..38a7111 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,8 @@ DIRS = \ /usr/share/man/man8 \ /usr/share/man/man5 \ /usr/share/man/man1 \ - /usr/share/mkinitcpio + /usr/share/mkinitcpio \ + /usr/lib/systemd/system
all: doc
@@ -48,6 +49,7 @@ install: all
cp -at $(DESTDIR)/usr/lib/initcpio hooks install install -m644 -t $(DESTDIR)/usr/share/mkinitcpio mkinitcpio.d/* + install -m644 mkinitcpio-generate-shutdown-ramfs.service $(DESTDIR)/usr/lib/systemd/system/mkinitcpio-generate-shutdown-ramfs.service
install -m755 50-mkinitcpio.install $(DESTDIR)/usr/lib/kernel/install.d/50-mkinitcpio.install
diff --git a/install/sd-shutdown b/install/sd-shutdown new file mode 100644 index 0000000..7e86dad --- /dev/null +++ b/install/sd-shutdown @@ -0,0 +1,14 @@ +#!/bin/bash + +build() { + add_binary /usr/lib/systemd/systemd-shutdown /shutdown +} + +help() { + cat <<HELPEOF +This hook adds systemd-shutdown to the initramfs. This is only +if the image is extracted to /run/initramfs before shutdown. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/mkinitcpio-generate-shutdown-ramfs.service b/mkinitcpio-generate-shutdown-ramfs.service new file mode 100644 index 0000000..4a147be --- /dev/null +++ b/mkinitcpio-generate-shutdown-ramfs.service @@ -0,0 +1,15 @@ +[Unit] +Description=Generate shutdown-ramfs +DefaultDependencies=no +Before=shutdown.target +ConditionFileIsExecutable=!/run/initramfs/shutdown + +[Service] +Type=oneshot +# /tmp could be umounted at this point +# use /run as temporary directory +Environment=TMPDIR=/run +ExecStart=/usr/bin/mkinitcpio -A sd-shutdown -c /dev/null -T /run/initramfs + +[Install] +WantedBy=shutdown.target -- 1.8.4.2
On Mon, Nov 18, 2013 at 08:21:46PM +0100, Thomas Bächler wrote:
The -T (--targetdirectory) option writes the root of the generated image directly to the specified directory.
Useful for generating a shutdown-ramfs with mkinitcpio -T /run/initramfs/. ---
Totally on board with this -- just a few comments.
functions | 35 ++++++++++++++++++----------------- mkinitcpio | 19 ++++++++++++++----- 2 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/functions b/functions index f0dce80..acec621 100644 --- a/functions +++ b/functions @@ -627,45 +627,46 @@ initialize_buildroot() { # creates a temporary directory for the buildroot and initialize it with a # basic set of necessary directories and symlinks
- local workdir= kernver=$1 arch=$(uname -m) + local workdir= kernver=$1 arch=$(uname -m) buildroot=$2
if ! workdir=$(mktemp -d --tmpdir mkinitcpio.XXXXXX); then error 'Failed to create temporary working directory in %s' "${TMPDIR:-/tmp}" return 1 fi + [[ -z $buildroot ]] && buildroot=$workdir/root
You could just define buildroot here as: buildroot=${2:-$workdir/root}
# base directory structure - install -dm755 "$workdir/root"/{new_root,proc,sys,dev,run,tmp,etc,usr/{local,lib,bin}} - ln -s "usr/lib" "$workdir/root/lib" - ln -s "../lib" "$workdir/root/usr/local/lib" - ln -s "bin" "$workdir/root/usr/sbin" - ln -s "usr/bin" "$workdir/root/bin" - ln -s "usr/bin" "$workdir/root/sbin" - ln -s "../bin" "$workdir/root/usr/local/bin" - ln -s "../bin" "$workdir/root/usr/local/sbin" + install -dm755 "$buildroot"/{new_root,proc,sys,dev,run,tmp,etc,usr/{local,lib,bin}} + ln -s "usr/lib" "$buildroot/lib" + ln -s "../lib" "$buildroot/usr/local/lib" + ln -s "bin" "$buildroot/usr/sbin" + ln -s "usr/bin" "$buildroot/bin" + ln -s "usr/bin" "$buildroot/sbin" + ln -s "../bin" "$buildroot/usr/local/bin" + ln -s "../bin" "$buildroot/usr/local/sbin"
case $arch in x86_64) - ln -s "lib" "$workdir/root/usr/lib64" - ln -s "usr/lib" "$workdir/root/lib64" + ln -s "lib" "$buildroot/usr/lib64" + ln -s "usr/lib" "$buildroot/lib64" ;; esac
# mkinitcpio version stamp - printf '%s' "$version" >"$workdir/root/VERSION" + printf '%s' "$version" >"$buildroot/VERSION"
# kernel module dir - install -dm755 "$workdir/root/usr/lib/modules/$kernver/kernel" + install -dm755 "$buildroot/usr/lib/modules/$kernver/kernel"
# mount tables - ln -s /proc/self/mounts "$workdir/root/etc/mtab" - >"$workdir/root/etc/fstab" + ln -s /proc/self/mounts "$buildroot/etc/mtab" + >"$buildroot/etc/fstab"
# indicate that this is an initramfs - >"$workdir/root/etc/initrd-release" + >"$buildroot/etc/initrd-release"
# add a blank ld.so.conf to keep ldconfig happy - >"$workdir/root/etc/ld.so.conf" + >"$buildroot/etc/ld.so.conf"
printf '%s' "$workdir" } diff --git a/mkinitcpio b/mkinitcpio index 7ce6c5c..489e199 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -19,7 +19,7 @@ _d_presets=mkinitcpio.d
# options and runtime data _optmoduleroot= _optkver= _optgenimg= -_optcompress= +_optcompress= _opttargetdir= _optshowautomods=0 _optsavetree=0 _optshowmods=0 _optquiet=1 _optcolor=1 _optskiphooks=() _optaddhooks=() _hooks=() _optpreset=() @@ -53,6 +53,7 @@ usage: ${0##*/} [options] -r, --moduleroot <dir> Root directory for modules (default: /) -S, --skiphooks <hooks> Skip specified hooks, comma-separated, during build -s, --save Save build directory. (default: no) + -T, --targetdirectory <dir> Write generated image into <dir> -t, --builddir <dir> Use DIR as the temporary build directory -V, --version Display version information and exit -v, --verbose Verbose output (default: no) @@ -298,10 +299,10 @@ process_preset() ( trap 'cleanup 130' INT trap 'cleanup 143' TERM
-_opt_short='A:c:g:H:hk:nLMPp:r:S:st:Vvz:' +_opt_short='A:c:g:H:hk:nLMPp:r:S:sT:t:Vvz:' _opt_long=('add:' 'addhooks:' 'config:' 'generate:' 'hookhelp:' 'help' 'kernel:' 'listhooks' 'automods' 'moduleroot:' 'nocolor' 'allpresets' - 'preset:' 'skiphooks:' 'save' 'builddir:' 'version' 'verbose' 'compress:') + 'preset:' 'skiphooks:' 'save' 'targetdirectory:' 'builddir:' 'version' 'verbose' 'compress:')
parseopts "$_opt_short" "${_opt_long[@]}" -- "$@" || exit 1 set -- "${OPTRET[@]}" @@ -327,6 +328,10 @@ while :; do -s|--save) _optsavetree=1 ;; + -T|--targetdirectory)
The name of the flag is a bit weird. One might consider that this is similar to -g but with a different output format. Just a suggestion, maybe use -d, --generatedir? Related: we probably want to make -g and this option mutually exclusive.
+ shift + _opttargetdir=$1 + ;; -g|--generate) shift [[ -d $1 ]] && die "Invalid image path -- must not be a directory" @@ -414,8 +419,12 @@ KERNELVERSION=$(resolve_kernver "$_optkver") || cleanup 1 _d_kmoduledir=$_optmoduleroot/lib/modules/$KERNELVERSION [[ -d $_d_kmoduledir ]] || die "'$_d_kmoduledir' is not a valid kernel module directory"
-_d_workdir=$(initialize_buildroot "$KERNELVERSION") || cleanup 1 -BUILDROOT=$_d_workdir/root +_d_workdir=$(initialize_buildroot "$KERNELVERSION" $_opttargetdir) || cleanup 1 +if [[ -z $_opttargetdir ]]; then + BUILDROOT=$_d_workdir/root +else + BUILDROOT=$_opttargetdir +fi
BUILDROOT=${_opttargetdir:-$_d_workdir/root}
. "$_f_config" || die "Failed to read configuration \`%s'" "$_f_config"
-- 1.8.4.2
Am 19.11.2013 04:02, schrieb Dave Reisner:
+ [[ -z $buildroot ]] && buildroot=$workdir/root
You could just define buildroot here as:
buildroot=${2:-$workdir/root}
k. ;;
+ -T|--targetdirectory)
The name of the flag is a bit weird. One might consider that this is similar to -g but with a different output format. Just a suggestion, maybe use -d, --generatedir?
I thought about a name quite long and didn't come up with anything better. I'll take your suggestion if that makes you happier.
Related: we probably want to make -g and this option mutually exclusive.
But they work just fine in combination. It seems like an unnecessary restriction.
+if [[ -z $_opttargetdir ]]; then + BUILDROOT=$_d_workdir/root +else + BUILDROOT=$_opttargetdir +fi
BUILDROOT=${_opttargetdir:-$_d_workdir/root}
Your bash magic is better than mine. Sending v2 later.
participants (2)
-
Dave Reisner
-
Thomas Bächler