From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=altlinux.org; s=dkim; h=Subject:Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=h2z8gd4j6tztopL3xzD2o+ddV/V58ISsjf7x800tG6o=; b=w50uMHCoV2ATP4r9yXCLa2D/ew +Jdncc/M8cEngt7uTaq5QnpK1Nd0+5UkbT3IdQyqGbHPOrYu9Qj0Vmparp2UPFppwU7uIs9fYLPPp DIVG5PmQSDygP8X0V0D+KsArNBjFwovlbp1lW2dwtANLXqS0XJHpLYouepPNDThLuxGc21K8kLBVU VXy5yPYfVd5Y0002w7AIe5YGiygv98JkUD301aOKb3OTv2C2ff7EXhaHSX3kVyfgIUEoUHi3zZyLb 8ZTPKb5kp6KxLnhKnljiXV5zqzboDhx7d4J2X0BASNu+tQn1hKjbxsJDi6E5DVAMcSSJ9eTaoirBR h7xwNs3Q==; From: "Vladimir D. Seleznev" To: devel@lists.altlinux.org Date: Thu, 26 Nov 2020 17:16:34 +0300 Message-Id: <20201126141636.2742206-1-vseleznv@altlinux.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 46.39.229.3 X-SA-Exim-Mail-From: vseleznv@altlinux.org X-SA-Exim-Version: 4.2.1 X-SA-Exim-Scanned: Yes (on mail.cs.msu.ru) Cc: legion@altlinux.org, "Vladimir D. Seleznev" Subject: [devel] [PATCH 1/3] Introduce nodiff directive for gear-rules X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Nov 2020 14:17:08 -0000 Archived-At: List-Archive: List-Post: The directive specifies a glob pattern that define files that should be excluded from diff generation. Signed-off-by: Vladimir D. Seleznev --- gear | 24 ++++++++++++++++++------ gear-rules.5.in | 19 +++++++++++++++++++ gear-store-tags | 2 +- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/gear b/gear index 6282c92..b4e8426 100755 --- a/gear +++ b/gear @@ -402,13 +402,14 @@ write_git_diff() { local optional="$1" && shift local cmd="$1" && shift + local nodiff_patterns="$1" && shift local old_tree="$1" && shift local old_dir="$1" && shift local new_tree="$1" && shift local new_dir="$1" && shift local name="${1##*/}" && shift - local old_id new_id + local old_id new_id nodiff= old_id="$(traverse_tree "$old_tree" "$old_dir" "$optional")" || { @@ -422,8 +423,13 @@ write_git_diff() exit 1 } + for pattern in $nodiff_patterns; do + [ -n "$pattern" ] ||continue + nodiff="$nodiff $(printf ":^%s" "$pattern")" + done + git diff-tree --patch-with-stat --text --no-renames --no-ext-diff \ - "$old_id" "$new_id" >"$outdir/$name" + "$old_id" "$new_id" -- $nodiff >"$outdir/$name" verbose "Extracted diff: $name" compress_file "$cmd" "$name" '' @@ -436,6 +442,7 @@ make_difference() rules_error 'No old_dir or new_dir specified' local optional="$1" && shift local cmd="$1" && shift + local nodiff_patterns="$1" && shift local old_dir="$1" && shift local new_dir="$1" && shift @@ -456,7 +463,7 @@ make_difference() diff_new_tree="$(resolve_tree_base_name "$diff_new_tree")" || rules_error "Invalid new tree: $diff_new_tree" - write_git_diff "$optional" "$cmd" "$diff_old_tree" "$old_dir" "$diff_new_tree" "$new_dir" "$diff_name" + write_git_diff "$optional" "$cmd" "$nodiff_patterns" "$diff_old_tree" "$old_dir" "$diff_new_tree" "$new_dir" "$diff_name" } extract_pattern() @@ -564,7 +571,7 @@ parse_rules() exclude_pattern_list= lineno=0 - local cmd options + local cmd options nodiff_patterns= while read -r cmd options; do lineno="$((lineno+1))" if [ "$cmd" = 'exclude:' ]; then @@ -572,6 +579,11 @@ parse_rules() rules_error "Invalid exclude pattern specified: $options" exclude_pattern_list="$exclude_pattern_list $options" fi + if [ "$cmd" = 'nodiff:' ]; then + [ -z "$(printf %s "$options" |tr -d '[:alnum:]_.?*-/![]')" ] || + rules_error "Invalid nodiff pattern specified: $options" + nodiff_patterns="$nodiff_patterns $options" + fi done <"$workdir/rules" lineno=0 @@ -601,7 +613,7 @@ parse_rules() eval "set -- $opts" case "$cmd" in - spec|specsubst|exclude|tags) + spec|specsubst|exclude|tags|nodiff) continue ;; tar|tar.gz|tar.bz2|tar.lzma|tar.xz|tar.zst) @@ -613,7 +625,7 @@ parse_rules() rules_error 'Failed to make archive' ;; diff|diff.gz|diff.bz2|diff.lzma|diff.xz|diff.zst) - make_difference "$optional" "$cmd" "$@" || + make_difference "$optional" "$cmd" "$nodiff_patterns" "$@" || rules_error 'Failed to make diff' ;; copy|gzip|bzip2|lzma|xz|zstd) diff --git a/gear-rules.5.in b/gear-rules.5.in index 5469199..347e5c8 100644 --- a/gear-rules.5.in +++ b/gear-rules.5.in @@ -452,6 +452,12 @@ or .I new_tree_path specify non-default base trees, these trees still must be valid. .TP +.BI "nodiff: " glob_pattern\fR +Exclude all the files that matched pattern from diff generation. Affects all +.BR diff -like +directives in the rule file irrespective of the order. Specifying a glob +pattern which does not match any files in the tree is not an error. +.TP .BI "specsubst: " variables... Specify whitespace-separated list of variables that should be substituted in specfile. Variable names may contain letters, digits and underscore @@ -541,6 +547,19 @@ However, if a prerelease version is packaged, parts like \*(lqpreN\*(rq or \*(lqrcN\*(rq should not be included in the package version, therefore the rule file will need some modifications for such versions. +.PP +You can also want to exclude +.BR .gear +subdirectory and spec file from diff generation: +.RS 4 +.PP +.ft CW +.nf +nodiff: .gear/** +nodiff: *.spec +.fi +.RE +.PP . .SS "Archive with unmodified sources and separate patch files" If you prefer to maintain patch files for local modifications instead diff --git a/gear-store-tags b/gear-store-tags index a649b66..a0a60cf 100755 --- a/gear-store-tags +++ b/gear-store-tags @@ -197,7 +197,7 @@ find_tags_in_rules() ;; esac case "$cmd" in - spec|tags|compress|copy|gzip|bzip2|lzma|xz|zstd|exclude) + spec|tags|compress|copy|gzip|bzip2|lzma|nodiff|xz|zstd|exclude) continue ;; tar|tar.gz|tar.bz2|tar.lzma|tar.xz|tar.zst|zip) -- 2.29.2