prevent overwriting existing initramfs
This commit is contained in:
parent
def645a883
commit
5fe452bcfc
22
tinyramfs
22
tinyramfs
@ -10,8 +10,10 @@ msg() {
|
|||||||
printf "info >> %s\n" "$2" >&2
|
printf "info >> %s\n" "$2" >&2
|
||||||
;;
|
;;
|
||||||
warn)
|
warn)
|
||||||
printf "warning >> %s\n" "$2" >&2
|
printf "warning >> %s\n" "$2" \
|
||||||
printf "do you want to continue? press enter or ctrl+c to exit\n"
|
"are you sure you want to continue?" \
|
||||||
|
"press enter to continue or ctrl+c to exit" >&2
|
||||||
|
|
||||||
read -r _
|
read -r _
|
||||||
;;
|
;;
|
||||||
panic)
|
panic)
|
||||||
@ -418,16 +420,16 @@ create_initramfs() {
|
|||||||
msg info "creating initramfs image"
|
msg info "creating initramfs image"
|
||||||
|
|
||||||
# TODO add uncompressed option
|
# TODO add uncompressed option
|
||||||
# TODO remove grouping
|
|
||||||
|
|
||||||
{
|
# check if image already exist
|
||||||
|
[ -e "$initramfs" ] &&
|
||||||
|
msg warn "looks like you already have initramfs image"
|
||||||
|
|
||||||
(
|
(
|
||||||
cd "$workdir"
|
cd "$workdir"
|
||||||
find . | cpio -oH newc | ${compress:-gzip -9}
|
find . | cpio -oH newc | ${compress:-gzip -9}
|
||||||
|
|
||||||
) | tee "$initramfs"
|
) > "$initramfs" 2> /dev/null ||
|
||||||
|
|
||||||
} > /dev/null 2>&1 ||
|
|
||||||
msg panic "failed to generate initramfs image"
|
msg panic "failed to generate initramfs image"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,14 +439,14 @@ create_initramfs() {
|
|||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
parse_conf
|
parse_conf
|
||||||
|
|
||||||
# remove workdir on exit or unexpected error
|
# remove workdir on exit
|
||||||
trap remove_workdir EXIT INT
|
trap remove_workdir EXIT
|
||||||
|
|
||||||
[ "$debug" = 1 ] && {
|
[ "$debug" = 1 ] && {
|
||||||
# debug shell commands
|
# debug shell commands
|
||||||
set -x
|
set -x
|
||||||
# don't remove anything
|
# don't remove anything
|
||||||
trap - EXIT INT
|
trap - EXIT
|
||||||
}
|
}
|
||||||
|
|
||||||
create_workdir
|
create_workdir
|
||||||
|
Loading…
Reference in New Issue
Block a user