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