From d6e1d23c70618211f1c452800ca30b89dbe29eb2 Mon Sep 17 00:00:00 2001 From: illiliti Date: Sun, 1 Mar 2020 16:42:57 +0300 Subject: [PATCH] add force option --- config | 3 +++ tinyramfs | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/config b/config index 8965bb5..c4008fc 100644 --- a/config +++ b/config @@ -5,6 +5,9 @@ # debug mode #debug=0 +# overwrite existing initramfs image +#force=0 + # custom init #init="" diff --git a/tinyramfs b/tinyramfs index 9571ec3..b859a86 100755 --- a/tinyramfs +++ b/tinyramfs @@ -34,6 +34,7 @@ usage: $0 [options] -k, --kernel kernel version -f, --files files directory -d, --debug 0|1 debug mode + -f, --force 0|1 overwrite existing initramfs image EOF } @@ -65,6 +66,10 @@ parse_args() { _debug="${2:?}" shift 2 ;; + -f | --force) + _force="${2:?}" + shift 2 + ;; -h | --help) usage exit 0 @@ -86,6 +91,7 @@ parse_conf() { moddir="${_moddir:-${moddir:-/lib/modules}}" filesdir="${_filesdir:-./files}" debug="${_debug:-${debug:-0}}" + force="${_force:-${force:-0}}" initramfs="${_initramfs:-${initramfs:-./initramfs-${kernel}}}" modker="${moddir}/${kernel}" } @@ -128,8 +134,8 @@ install_requirements() { create_structure() { msg info "creating directory structure" - for dir in dev tmp var run etc usr/lib usr/bin mnt/root proc root sys; do - mkdir -p "${workdir}/${dir}" + for _dir in dev tmp var run etc usr/lib usr/bin mnt/root proc root sys; do + mkdir -p "${workdir}/${_dir}" done } @@ -422,7 +428,7 @@ create_initramfs() { # TODO add uncompressed option # check if image already exist - [ -e "$initramfs" ] && + [ ! "$force" = 1 ] && [ -e "$initramfs" ] && msg warn "looks like you already have initramfs image" (