Ignore:
Timestamp:
Oct 19, 2016, 4:59:57 PM (9 years ago)
Author:
dmik
Message:

rpmbuild-bot: Automatically commit SPEC files to SVN on upload.

This is necessary to ensure cosnistency between published RPMs
and their published SPEC files. It also provides a standard
commit message for easier tracking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rpmbuild-bot/rpmbuild-bot.sh

    r862 r867  
    112112# repositories. When REPO is not given, the default repository is used
    113113# (usually experimental or similar).
     114#
     115# The upload command also requires the spec file to be under SVN vesrion control
     116# and will try to commit it before uploading the RPMs to the repository with the
     117# automatic commit message that says "spec: PROJECT: Release version VERSION."
     118# (where PROJECT is the spec file name and VERSION is the full version,
     119# excluding the distribution mark, as specified by the spec file). If the commit
     120# operation fails, uploading will be aborted. This to ensure that the spec file
     121# are published at the same time the RPMs are published - to guarantee their
     122# consisnency and simplify further maintenance. Note that the auxiliary source
     123# directory named SPEC and located near the spec file (see the "build" command),
     124# if it exists, will also be committed.
    114125#
    115126# Note that the "upload" command needs log files from the "build" command
     
    555566You may need to build the packages using the 'build' command."
    556567
     568  # Prepare for committing the SPEC and auxiliary source files.
     569  local ver_list=
     570  [ -L "$spec_list" ] && ver_list=`readlink "$spec_list"`
     571  [ -z "$ver_list" ] && die "File '$spec_list' is not a valid symbolic link."
     572
     573  local ver_full="${ver_list#${spec_name}.}"
     574  ver_full="${ver_full%.*}"
     575  [ -n "$dist_mark" ] && ver_full="${ver_full%${dist_mark}}"
     576
     577  [ -n "$ver_full" ] || die "Full version string is empty."
     578
     579  local commit_items="$spec_full"
     580  # Commit the auxiliary source directory, if any, as well.
     581  [ -d "${spec_full%.spec}" ] && commit_items="$commit_items ${spec_full%.spec}"
     582
     583  local commit_msg="spec: $spec_name: Release version $ver_full."
     584
     585  echo \
     586"Uploading requires the following items to be committed to SPEC repository:
     587  $commit_items
     588With the following commit message:
     589  $commit_msg
     590You will now be presented a diff for careful inspection. Type YES to continue."
     591
     592  local answer=
     593  read answer
     594  if [ "$answer" = "YES" ] ; then
     595    local pager=`which less`
     596    if [ ! -x "$pager" ] ; then
     597      pager="more"
     598      # OS/2 more doesn't understand LF, feed it through sed.
     599      [ -x `which sed` ] && pager="sed -e '' | $pager"
     600    fi
     601    echo
     602    svn diff "$commit_items" | "$pager"
     603    echo "
     604Type YES if the diff is okay to be committed."
     605    read answer
     606  fi
     607
     608  [ "$answer" = "YES" ] || die "Your answer is not YES, upload is aborted."
     609
     610  # First, copy RPM files over to the repository.
    557611  local files=
    558612  read_file_list "$spec_list" files
     
    575629    run rm -f "$f"
    576630  done
     631
     632  # And finally commit the SPEC file.
     633  run svn commit "$commit_items" -m "$commit_msg"
    577634
    578635  # Note: versioned .list file will remain in archive forever (for further reference).
     
    753810
    754811# Query all rpmbuild macros in a single run as it may be slow.
    755 eval `rpmbuild.exe --eval='rpmbuild_dir="%_topdir" ; spec_dir="%_specdir" ; src_dir="%_sourcedir"' | tr '\\\' /`
     812eval `rpmbuild.exe --eval='rpmbuild_dir="%_topdir" ; spec_dir="%_specdir" ; src_dir="%_sourcedir" ; dist_mark="%dist"' | tr '\\\' /`
    756813
    757814[ -n "$rpmbuild_dir" -a -d "$rpmbuild_dir" ] || die "Falied to get %_topdir from rpmbuild or not directory ($rpmbuild_dir)."
Note: See TracChangeset for help on using the changeset viewer.