On Fri, Jan 11, 2019 at 05:06:00PM +0200, Jani Nikula wrote:
> Help the users if they so desire.
> 
> Signed-off-by: Jani Nikula <[email protected]>

Yeah this is nice!

Reviewed-by: Daniel Vetter <[email protected]>

> ---
>  dim | 41 +++++++++++++++++++++++++++++++----------
>  1 file changed, 31 insertions(+), 10 deletions(-)
> 
> diff --git a/dim b/dim
> index e502511f5063..11f38b114e56 100755
> --- a/dim
> +++ b/dim
> @@ -155,6 +155,19 @@ function pause
>       echo
>  }
>  
> +function ask_user
> +{
> +     local prompt="$@ (y/N) "
> +
> +     read -n 1 -rsp "$prompt"
> +     echo
> +     if [[ $REPLY =~ ^[Yy]$ ]]; then
> +             return 0
> +     else
> +             return 1
> +     fi
> +}
> +
>  #
>  # Variable naming convetion:
>  #
> @@ -2109,18 +2122,26 @@ function dim_setup
>       drm_tip_ssh=ssh://git.freedesktop.org/git/drm-tip
>       
> linux_upstream_git=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>  
> -     if [ ! -d $DIM_PREFIX ]; then
> -             echoerr "Directory $DIM_PREFIX doesn't exist."
> -             echoerr "Please set up your repository directory with"
> -             echoerr "    mkdir -p $DIM_PREFIX"
> -             echoerr "or update your configuration (see dimrc.sample)."
> -             exit 1
> +     if [[ ! -d "$DIM_PREFIX" ]]; then
> +             if ask_user "The DIM_PREFIX repository directory '$DIM_PREFIX' 
> doesn't exist. Create?"; then
> +                     mkdir -p "$DIM_PREFIX"
> +             else
> +                     echoerr "Please set up your DIM_PREFIX repository 
> directory with"
> +                     echoerr "    mkdir -p $DIM_PREFIX"
> +                     echoerr "or update your configuration (see 
> dimrc.sample)."
> +                     exit 1
> +             fi
> +     fi
> +
> +     if [[ ! -d "$DIM_PREFIX/$DIM_REPO" ]]; then
> +             if ask_user "The DIM_REPO maintainer kernel repository 
> '$DIM_PREFIX/$DIM_REPO' doesn't exist. Clone upstream?"; then
> +                     git clone "$linux_upstream_git" "$DIM_REPO"
> +             fi
>       fi
> -     cd $DIM_PREFIX
>  
> -     if [ ! -d $(git_dir $DIM_PREFIX/$DIM_REPO) ]; then
> -             echoerr "No git checkout found in $DIM_PREFIX/$DIM_REPO."
> -             echoerr "Please set up your maintainer linux repository at 
> $DIM_PREFIX/$DIM_REPO with"
> +     if [[ ! -d "$(git_dir $DIM_PREFIX/$DIM_REPO)" ]]; then
> +             echoerr "No kernel git checkout found in 
> '$DIM_PREFIX/$DIM_REPO'."
> +             echoerr "Please set up your DIM_REPO maintainer kernel 
> repository at '$DIM_PREFIX/$DIM_REPO' with:"
>               echoerr "    cd $DIM_PREFIX"
>               echoerr "    git clone $linux_upstream_git $DIM_REPO"
>               echoerr "or update your configuration (see dimrc.sample)."
> -- 
> 2.20.1
> 
> _______________________________________________
> dim-tools mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dim-tools

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dim-tools mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dim-tools

Reply via email to