Re: [PATCH 03/20] kbuild: scripts/install.sh: provide a "install" function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman
<gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> Instead of open-coding the "test for file, if present make a backup,
> then copy the file to the new location" in multiple places, make a
> single function, install(), to do all of this in one place.
>
> Note, this does change the default x86 kernel map file saved name from
> "System.old" to "System.map.old".  This brings it into unification with
> the other architectures as to what they call their backup file for the
> kernel map file.  As this is a text file, and nothing parses this from a
> backup file, there should not be any operational differences.
>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
>  scripts/install.sh | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/scripts/install.sh b/scripts/install.sh
> index c183d6ddd00c..af36c0a82f01 100644
> --- a/scripts/install.sh
> +++ b/scripts/install.sh
> @@ -27,6 +27,19 @@ verify () {
>         fi
>  }
>
> +install () {
> +       install_source=${1}
> +       install_target=${2}



You double-quoted all variables in 02/20.

For consistency and safety here,

           install_source="${1}"

or

           install_source="$1"


so that it will work even if $1 contains spaces.





> +
> +       echo "installing '${install_source}' to '${install_target}'"
> +
> +       # if the target is already present, move it to a .old filename
> +       if [ -f "${install_target}" ]; then
> +               mv "${install_target}" "${install_target}".old
> +       fi
> +       cat "${install_source}" > "${install_target}"
> +}
> +
>  # Make sure the files actually exist
>  verify "$2"
>  verify "$3"
> @@ -37,17 +50,8 @@ if [ -x ~/bin/"${INSTALLKERNEL}" ]; then exec ~/bin/"${INSTALLKERNEL}" "$@"; fi
>  if [ -x /sbin/"${INSTALLKERNEL}" ]; then exec /sbin/"${INSTALLKERNEL}" "$@"; fi
>
>  # Default install - same as make zlilo
> -
> -if [ -f "$4"/vmlinuz ]; then
> -       mv "$4"/vmlinuz "$4"/vmlinuz.old
> -fi
> -
> -if [ -f "$4"/System.map ]; then
> -       mv "$4"/System.map "$4"/System.old
> -fi
> -
> -cat "$2" > "$4"/vmlinuz
> -cp "$3" "$4"/System.map
> +install "$2" "$4"/vmlinuz
> +install "$3" "$4"/System.map
>
>  if [ -x /sbin/lilo ]; then
>         /sbin/lilo
> --
> 2.31.1
>


--
Best Regards

Masahiro Yamada



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux