diff --git a/chain-build.sh b/chain-build.sh index a657542..2d6486a 100755 --- a/chain-build.sh +++ b/chain-build.sh @@ -9,7 +9,7 @@ # ... # fedpkg commit # fedpkg push -# ./chain-build.sh +# ./chain-build.sh # MIT License # @@ -39,14 +39,38 @@ set -o errexit set -o nounset set -o pipefail -set -o xtrace + +function usage { + echo "usage: $BASH_ARGV0 [-P] [-d|-v] [bug-number]" + exit 2 +} + +no_pull_requests= +quiet=-q +while getopts 'dPv' OPT; do + case "$OPT" in + d) + set -o xtrace + quiet= + ;; + P) + no_pull_requests=1 + ;; + v) + quiet= + ;; + *) + usage + ;; + esac +done +shift $((OPTIND - 1)) if (( $# == 1 )); then typeset -i bug=$1 shift; elif (( $# > 1 )); then - echo "usage: $0 [bug-number]" - exit 2 + usage fi function create_authorization_header_file { @@ -92,18 +116,18 @@ koji moshimoshi > /dev/null # Install potential dependencies: if [[ ! -x /usr/bin/crudini \ || ! -x /usr/bin/jq ]]; then - sudo dnf install -y /usr/bin/crudini /usr/bin/jq + sudo dnf $quiet install -y /usr/bin/crudini /usr/bin/jq fi branch="$(git branch --show-current)" # Get a list of packages that require libtree-sitter: packages=($( - dnf repoquery \ + dnf $quiet repoquery \ --repo=fedora --repo=updates \ --releasever="${branch#f}" \ - --whatrequires=libtree-sitter \ - --qf='%{source_name}' \ + --whatrequires='libtree-sitter.so.*' \ + --qf='%{source_name}\n' \ | grep -v '^tree-sitter$' )) @@ -125,34 +149,40 @@ if [[ -z ${side_tag:-} ]]; then | grep --perl-regexp --only-matching "(?<=^Side tag ').*(?=')" )" echo "$side_tag" > .side-tag - koji wait-repo "$side_tag" + koji $quiet wait-repo --no-request "$side_tag" fi # Build tree-sitter in the side tag: verrel="$(fedpkg verrel)" -fedpkg build --target="$side_tag" -koji wait-repo --request --build="$verrel" "$side_tag" +fedpkg $quiet build --target="$side_tag" +koji $quiet wait-repo --request --build="$verrel" "$side_tag" # Try to bump and rebuild the requiring packages: message="Rebuild against $verrel" tmp_dir="$(mktemp -td tree-sitter-chain-build.XXXXXX)" +declare -i i=0 for package in "${packages[@]}"; do - fedpkg clone --branch="$branch" --depth=1 "$package" "$tmp_dir/$package" + fedpkg $quiet clone --branch="$branch" --depth=1 "$package" \ + "$tmp_dir/$package" cd "$tmp_dir/$package" - rpmdev-bumpspec --comment="$message" "$package.spec" + rpmdev-bumpspec --comment="$message" "$package.spec" >/dev/null git add "$package.spec" git commit --allow-empty --message="$message" - if fedpkg push; then + if fedpkg $quiet push; then # Build the requiring package in the side tag: - fedpkg build --target="$side_tag" --nowait + fedpkg $quiet build --target="$side_tag" --nowait + elif [[ -n $no_pull_requests ]]; then + echo "Skipping $package, which would require a pull request" + skipped_packages+=("$package") + unset packages[$i] else # We lack permission for the requiring package, so submit a pull # request instead. - fedpkg fork - git fetch --unshallow + fedpkg $quiet fork + git fetch $quiet --unshallow fas_login="$( git remote -v \ @@ -160,13 +190,14 @@ for package in "${packages[@]}"; do '^(\w+)(?=\s+ssh://(\1)@pkgs\.fedoraproject\.org/forks/\1/rpms/.+ \(push\)$)' )" - git switch --create "$verrel" - git push "$fas_login" "$verrel" + git switch $quiet --create "$verrel" + git push $quiet "$fas_login" "$verrel" create_authorization_header_file distgit response=$( curl \ + ${quiet:+--silent --show-error} \ --fail-with-body \ --header @"$tmp_dir/distgit_authorization" \ --data title="$message" \ @@ -192,8 +223,9 @@ Relates to https://bugzilla.redhat.com/show_bug.cgi?id=$bug. pull_request_urls+=("$response") fi fi - cd - + cd - >/dev/null rm -rf "$tmp_dir/$package" + i=$((i + 1)) done ## If we had permission to push to all of the repos ourselves, we could @@ -212,18 +244,25 @@ There should be builds for each of: ${pull_request_urls:+The following pull requests have been created: ${pull_request_urls[*]} +}${skipped_packages:+The following packages were skipped: + ${skipped_packages[*]} + }When all ${pull_request_urls:+pull requests are merged, and }packages are built, run: bodhi updates new --from-tag ${bug:+--bugs=$bug }... '$side_tag'" -echo "$summary" +echo " -if [[ -n $bug ]]; then +$summary" + +if [[ -n ${bug:-} ]]; then # We could probably use Kerberos here, but # https://bugzilla.redhat.com/docs/en/html/api/core/v1/general.html#authentication # says it's not supported. create_authorization_header_file bugzilla curl \ + ${quiet:+--silent --show-error} \ + ${quiet:+--output /dev/null} \ --fail-with-body \ --header @"$tmp_dir/bugzilla_authorization" \ --variable "summary=$summary" \ diff --git a/sources b/sources index a4d4f43..9599e8c 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (tree-sitter-0.25.2.tar.gz) = 8acdb410c8b5c2552e9dd5524d80ab1d529e418f408d7c495619e6781f3b70ea2d61b6f69b5b3d1ebd753b739c0f9dd744302808d9a3051b5c7dcf68dba30002 +SHA512 (tree-sitter-0.25.10.tar.gz) = f0465a2fabe303c1b62f1f55ed08aa57372ac11370d229adcccd99b5e8067be53e92da281cdfbcd034e2ecefb33ac90a119eeac9035670ac8fbaa4242cb87a11 diff --git a/tree-sitter.spec b/tree-sitter.spec index 2fc2c34..19fac45 100644 --- a/tree-sitter.spec +++ b/tree-sitter.spec @@ -1,7 +1,12 @@ -%global treesitter_so_version 0 +%global tree_sitter_so_version 0 + +# Keep these up-to-date with the values in lib/include/tree_sitter/api.h: +%global tree_sitter_language_version 15 +%global tree_sitter_min_compatible_language_version 13 + Name: tree-sitter -Version: 0.25.2 +Version: 0.25.10 Release: %autorelease Summary: An incremental parsing system for programming tools @@ -28,6 +33,12 @@ edited. Tree-sitter aims to be: %package -n lib%{name} Summary: Incremental parsing library for programming tools +%{lua: + for i = rpm.expand('%tree_sitter_min_compatible_language_version'), + rpm.expand('%tree_sitter_language_version') do + print(string.format("Provides: tree-sitter(:LANGUAGE_VERSION) = %d\n", i)) + end +} %description -n lib%{name} Tree-sitter is a parser generator tool and an incremental parsing @@ -59,11 +70,22 @@ export PREFIX='%{_prefix}' LIBDIR='%{_libdir}' INCLUDEDIR='%{_includedir}' find %{buildroot}%{_libdir} -type f \( -name "*.la" -o -name "*.a" \) -delete -print +install -d %{buildroot}%{_datadir}/tree-sitter/queries + + +%check +grep -q '^#define TREE_SITTER_LANGUAGE_VERSION %tree_sitter_language_version' \ + lib/include/tree_sitter/api.h +grep -q '^#define TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION %tree_sitter_min_compatible_language_version' \ + lib/include/tree_sitter/api.h + %files -n lib%{name} %license LICENSE %doc README.md -%{_libdir}/libtree-sitter.so.%{treesitter_so_version}* +%dir %{_datadir}/tree-sitter +%dir %{_datadir}/tree-sitter/queries +%{_libdir}/libtree-sitter.so.%{tree_sitter_so_version}* %files -n lib%{name}-devel %{_includedir}/tree_sitter