[PATCH 2/2] dim: sanity-check config settings

Rodrigo Vivi rodrigo.vivi at intel.com
Thu Aug 23 00:26:06 UTC 2018


On Tue, Aug 21, 2018 at 02:08:19PM +0200, Daniel Vetter wrote:
> Shashank wanted to reuse his drm-tip repo for DIM_REPO, which doesn't
> work great. Catch this.
> 
> Also group the various check functions all together for a bit of OCD.

I think the OCD could be in a separated patch, but anyways
end result seems right:

Reviewed-by: Rodrigo Vivi <rodrigo.vivi at intel.com>


> 
> Cc: Shashank Sharma <shashank.sharma at intel.com>
> Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
> ---
>  dim | 43 ++++++++++++++++++++++++++-----------------
>  1 file changed, 26 insertions(+), 17 deletions(-)
> 
> diff --git a/dim b/dim
> index a1c194318b56..5040d6b046b2 100755
> --- a/dim
> +++ b/dim
> @@ -316,20 +316,6 @@ function dim_uptodate
>  	fi
>  }
>  
> -function check_for_updates
> -{
> -	local stamp stampfile
> -
> -	stampfile=$HOME/.dim-update-check-timestamp
> -
> -	# daily check for updates based on file timestamp
> -	stamp=$(stat --printf=%Y $stampfile 2>/dev/null || echo -n 0)
> -	if [[ $((stamp + 24*60*60)) -lt $(date +%s) ]]; then
> -		dim_uptodate || true
> -		touch $stampfile
> -	fi
> -}
> -
>  function git_fetch_helper # remote
>  {
>  	local remote
> @@ -373,7 +359,21 @@ function git_committer_email
>  	echo $committer_email
>  }
>  
> -function git_version_check
> +function check_for_updates
> +{
> +	local stamp stampfile
> +
> +	stampfile=$HOME/.dim-update-check-timestamp
> +
> +	# daily check for updates based on file timestamp
> +	stamp=$(stat --printf=%Y $stampfile 2>/dev/null || echo -n 0)
> +	if [[ $((stamp + 24*60*60)) -lt $(date +%s) ]]; then
> +		dim_uptodate || true
> +		touch $stampfile
> +	fi
> +}
> +
> +function check_git_version
>  {
>  	local min_version="git version 2.8"
>  
> @@ -382,6 +382,14 @@ function git_version_check
>  	fi
>  }
>  
> +function check_dim_config
> +{
> +	if [[ "$DIM_REPO" == "drm-tip" || "$DIM_REPO" == "drm-rerere" || "$DIM_REPO" == "maintainer-tools" ]];  then
> +		echoerr "WARNING: setting $DIM_REPO for DIM_REPO not allowed"
> +		exit 1
> +	fi
> +}
> +
>  # get message id from file
>  # $1 = file
>  message_get_id ()
> @@ -2389,6 +2397,8 @@ if [[ -n "${__dim_running:-}" ]]; then
>  fi
>  export __dim_running=1
>  
> +check_dim_config
> +
>  # Commands useful for developers don't need a full dim setup
>  if list_developer_commands | grep -qx $subcmd; then
>  	if [ -r $DIM_PREFIX/drm-rerere/$dim_integration_config ]; then
> @@ -2404,9 +2414,8 @@ else
>  
>  	read_integration_config
>  
> -	# occasional check for dim updates
>  	check_for_updates
> -	git_version_check
> +	check_git_version
>  fi
>  
>  # throw away to not confuse list-aliases
> -- 
> 2.18.0
> 
> _______________________________________________
> dim-tools mailing list
> dim-tools at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dim-tools


More information about the dim-tools mailing list