prevent overwriting existing initramfs
This commit is contained in:
parent
def645a883
commit
5fe452bcfc
28
tinyramfs
28
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)
|
||||||
@ -157,7 +159,7 @@ install_devmgr() {
|
|||||||
! -path "*hwdb.d*" \
|
! -path "*hwdb.d*" \
|
||||||
-type f |
|
-type f |
|
||||||
|
|
||||||
cpio -pd "$workdir" > /dev/null 2>&1 || msg panic "failed to install udev"
|
cpio -pd "$workdir" > /dev/null 2>&1 || msg panic "failed to install udev"
|
||||||
;;
|
;;
|
||||||
mdev)
|
mdev)
|
||||||
install -m644 "${filesdir}/mdev.conf" "${workdir}/etc/mdev.conf"
|
install -m644 "${filesdir}/mdev.conf" "${workdir}/etc/mdev.conf"
|
||||||
@ -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" ] &&
|
||||||
cd "$workdir"
|
msg warn "looks like you already have initramfs image"
|
||||||
find . | cpio -oH newc | ${compress:-gzip -9}
|
|
||||||
|
|
||||||
) | tee "$initramfs"
|
(
|
||||||
|
cd "$workdir"
|
||||||
|
find . | cpio -oH newc | ${compress:-gzip -9}
|
||||||
|
|
||||||
} > /dev/null 2>&1 ||
|
) > "$initramfs" 2> /dev/null ||
|
||||||
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