From 03203669f4006f64632def1216c83b09fbcec81e Mon Sep 17 00:00:00 2001 From: Daniel Vetter <daniel.vetter@ffwll.ch> Date: Tue, 21 Aug 2018 14:06:18 +0200 Subject: [PATCH] dim: sanity-check config settings 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. Cc: Shashank Sharma <shashank.sharma@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> --- dim | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/dim b/dim index a1c1943..5040d6b 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 -- GitLab