simplify create_tmpdir
This commit is contained in:
parent
2683375cc5
commit
9baf5880bd
11
generate
11
generate
@ -24,17 +24,13 @@ msg() {
|
|||||||
create_tmpdir() {
|
create_tmpdir() {
|
||||||
if [ -n "$XDG_CACHE_HOME" ]; then
|
if [ -n "$XDG_CACHE_HOME" ]; then
|
||||||
tmpdir="${XDG_CACHE_HOME}/initramfs.$$"
|
tmpdir="${XDG_CACHE_HOME}/initramfs.$$"
|
||||||
mkdir "$tmpdir"
|
|
||||||
printf "%s\n" "$tmpdir"
|
|
||||||
elif [ -n "$TMPDIR" ]; then
|
elif [ -n "$TMPDIR" ]; then
|
||||||
tmpdir="${TMPDIR}/initramfs.$$"
|
tmpdir="${TMPDIR}/initramfs.$$"
|
||||||
mkdir "$tmpdir"
|
|
||||||
printf "%s\n" "$tmpdir"
|
|
||||||
else
|
else
|
||||||
tmpdir="/tmp/initramfs.$$"
|
tmpdir="/tmp/initramfs.$$"
|
||||||
mkdir "$tmpdir"
|
|
||||||
printf "%s\n" "$tmpdir"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mkdir "$tmpdir" || msg panic "failed to create working directory"
|
||||||
}
|
}
|
||||||
|
|
||||||
# remove tmpdir
|
# remove tmpdir
|
||||||
@ -403,6 +399,8 @@ create_initramfs() {
|
|||||||
# check root
|
# check root
|
||||||
[ "$(id -u)" = 0 ] || msg panic "must be run as root"
|
[ "$(id -u)" = 0 ] || msg panic "must be run as root"
|
||||||
|
|
||||||
|
create_tmpdir
|
||||||
|
|
||||||
# remove tmpdir on exit or unexpected error
|
# remove tmpdir on exit or unexpected error
|
||||||
trap remove_tmpdir EXIT INT
|
trap remove_tmpdir EXIT INT
|
||||||
|
|
||||||
@ -420,7 +418,6 @@ check_currentdir
|
|||||||
}
|
}
|
||||||
|
|
||||||
# variables
|
# variables
|
||||||
tmpdir="$(create_tmpdir)" || msg panic "failed to create working directory"
|
|
||||||
kernel="${kernel:-$(uname -r)}"
|
kernel="${kernel:-$(uname -r)}"
|
||||||
moddir="/lib/modules"
|
moddir="/lib/modules"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user