mcsnap 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #! /bin/sh
  2. # This script takes the compiled tarball, makes an RPM package and
  3. # a patch against the latest released version, then uploads
  4. # everything over ssh and removes old snapshots.
  5. # Run this script in the directory where mc was built.
  6. # TODO:
  7. # build tarball, select level of testing
  8. # (dist, distcheck, warning checks)
  9. # $1 - file to upload, $2 - shell mask to erase
  10. upload() {
  11. echo "Uploading $1 to $SITE"
  12. name="`basename $1`"
  13. scp "$1" "$SITE:$DIR/.in.$name"
  14. ssh $SITE "rm -f $DIR/$2; mv $DIR/.in.$name $DIR/$name"
  15. }
  16. set -e
  17. # Version to make patches against.
  18. # The source tree should be available in uncompressed form
  19. BASE_VERSION="4.6.1"
  20. # Version of the snapshot
  21. MCVERSION=`date "+%Y-%m-%d-%H" --utc`
  22. # Local directories
  23. MC_BASE_DIR="$HOME/src/mc-$BASE_VERSION"
  24. MC_CVS_DIR="$HOME/src/mc"
  25. MC_BUILD_DIR="$HOME/src/mc.snap"
  26. RPM_SRC_DIR="$MC_BUILD_DIR/rpm"
  27. # Location of the snapshot directory
  28. SITE="login.ibiblio.org"
  29. DIR="/public/ftp/pub/Linux/utils/file/managers/mc/snapshots"
  30. # DIR="/public/html/mc/snapshots"
  31. # Command for building RPM
  32. RPMBUILD=lsb-rpm
  33. cd "$MC_CVS_DIR"
  34. cvs up -dPA
  35. test -d "$MC_BUILD_DIR" && chmod -R u+rwx "$MC_BUILD_DIR"
  36. rm -rf "$MC_BUILD_DIR"
  37. cp -a "$MC_CVS_DIR" "$MC_BUILD_DIR"
  38. cd "$MC_BUILD_DIR"
  39. # Sanity check
  40. if ! test -f ./autogen.sh || ! test -f src/screen.c; then
  41. echo "Not in the MC CVS working directory"
  42. exit 1
  43. fi
  44. # Remove old tarballs and build the new one
  45. rm -f "mc*.tar.gz"
  46. cp -f configure.ac configure.ac.cvs
  47. sed "s/AM_INIT_AUTOMAKE([^)]*)/AM_INIT_AUTOMAKE(mc, $MCVERSION)/" \
  48. configure.ac.cvs >configure.ac
  49. ./autogen.sh
  50. make all
  51. make distcheck
  52. # Make sure that the new tarball exists
  53. MCTARBALL="mc-$MCVERSION.tar.gz"
  54. if test ! -f "$MCTARBALL"; then
  55. echo "No tarball found!!!"
  56. exit 1
  57. fi
  58. # Make an RPM package
  59. rm -rf $RPM_SRC_DIR
  60. mkdir "$RPM_SRC_DIR"
  61. mkdir "$RPM_SRC_DIR/BUILD"
  62. mkdir "$RPM_SRC_DIR/RPMS"
  63. mkdir "$RPM_SRC_DIR/RPMS/i386"
  64. mkdir "$RPM_SRC_DIR/SPECS"
  65. $RPMBUILD -tb --define="_topdir $RPM_SRC_DIR" \
  66. --define="_with_included_slang 1" "$MCTARBALL"
  67. MC_RPM_VERSION=`echo $MCVERSION | sed s/-//g`
  68. MC_RPM=$RPM_SRC_DIR/RPMS/i386/mc-$MC_RPM_VERSION-1.i386.rpm
  69. if test ! -f $MC_RPM; then
  70. echo "Failed to compile package!!!"
  71. exit 1
  72. fi
  73. # Make a patch against the latest released version
  74. MC_PATCH="mc-$BASE_VERSION-$MCVERSION.diff"
  75. MC_PATCH_BZ2="$MC_PATCH.bz2"
  76. if test ! -d $MC_BASE_DIR; then
  77. echo "Cannot find unpacked base version!!!"
  78. exit 1
  79. fi
  80. rm -f $MC_PATCH $MC_PATCH_BZ2
  81. rm -rf mc-$MCVERSION
  82. gzip -cd $MCTARBALL | tar xf -
  83. # GNU diff should return 0 or 1. 2 means failure or incomplete diff.
  84. diff -urN -x '*.gmo' -x pc $MC_BASE_DIR mc-$MCVERSION/ >$MC_PATCH || test $? = 1
  85. bzip2 $MC_PATCH
  86. upload "$MCTARBALL" "mc*.tar.gz"
  87. upload "$MC_RPM" "mc*.i386.rpm"
  88. upload "$MC_PATCH_BZ2" "mc*.diff.bz2"
  89. echo "Done"