X-Git-Url: http://git.pld-linux.org/?p=packages%2Fefi-boot-update.git;a=blobdiff_plain;f=efi-boot-update;h=b031d67fece6af96a607b776276116f6ed66d9a7;hp=cf3aa71581536e9b240f0d426862a6e2693045d2;hb=7a5c96c9301cb4ea8bfb973fbee40553bd828372;hpb=f8b86fe2fe5f08a7b2e236cc54ff8d2315b3124d diff --git a/efi-boot-update b/efi-boot-update index cf3aa71..b031d67 100755 --- a/efi-boot-update +++ b/efi-boot-update @@ -1,7 +1,7 @@ #!/bin/sh _SCRIPT_NAME=efi-boot-update -_SCRIPT_VERSION=0.0 +_SCRIPT_VERSION=0.1 . /etc/rc.d/init.d/functions @@ -15,21 +15,22 @@ usage () { echo " --mount, -m Try to mount /boot/efi first" echo " --verbose, -v Verbose output" echo " --force Force file updates" + echo " --auto Automatic run from packages %post" } msg () { - echo "efi-boot-update: $*" >&2 + echo -E "efi-boot-update: $*" >&2 } verbose () { if is_yes "$VERBOSE" ; then - echo "efi-boot-update: $*" >&2 + echo -E "efi-boot-update: $*" >&2 fi } verbose_cmd () { if is_yes "$VERBOSE" ; then - echo "+$*" >&2 + echo -E "+$*" >&2 fi "$@" } @@ -41,7 +42,7 @@ list_remove () { if [ "$item" = "$2" ] ; then continue fi - echo -n "$item " + echo -nE "$item " done } @@ -65,11 +66,18 @@ update_file () { esac done src="$1"; shift - dst="$2"; shift + dst="$1"; shift if [ -n "$*" ] ; then msg "update_file: unexpected arguments: $*" return 1 fi + if [ -z "$src" ] ; then + msg "update_file: no source file" + return 1 + fi + if [ -z "$dst" ] ; then + dst=`basename "$src"` + fi if [ "${dst#/}" = "${dst}" ] ; then # relative path dst="$DESTDIR/$dst" @@ -132,7 +140,7 @@ add_bootmgr_entry () { binary="$DESTDIR/$binary" fi binary="${binary#/boot/efi}" - binary="$(echo -n "$binary"|sed -e's;/;\\;g')" + binary="$(echo -nE "$binary"|sed -e's;/;\\;g')" if [ -n "$bootnum" ] ; then echo -n "$args" | verbose_cmd $EFIBOOTMGR $EFIBOOTMGR_OPTS --quiet \ @@ -149,14 +157,16 @@ safe_string () { echo -n "$*" | tr -c '[a-zA-Z0-9_]' '_' } +ALLOW_AUTO="no" FORCE_UPDATES="no" MOUNT_EFI_PARTITION="no" LABEL_PREFIX="" -DEFAULT="" VERBOSE="no" [ -e /etc/efi-boot/update.conf ] && . /etc/efi-boot/update.conf +AUTO_RUN=no + while [ -n "$*" ] ; do local arg arg="$1" @@ -179,6 +189,10 @@ while [ -n "$*" ] ; do --force) FORCE_UPDATES="yes" ;; + --auto) + is_yes "$ALLOW_AUTO" || exit 0 + AUTO_RUN=yes + ;; *) usage >&2 exit 2 @@ -284,4 +298,9 @@ if [ -n "$ORDER" -a "$EFIBOOTMGR" != "/bin/true" ] ; then fi fi +if ! is_yes "$ALLOW_AUTO" && ! is_yes "$AUTO_RUN"; then + msg "ALLOW_AUTO is not enabled in /etc/efi-boot/update.conf," + msg "files will not be automatically updated on upgrades." +fi + # vi: ft=sh sw=4 sts=4 et