view contrib/buildrpm @ 5440:f9b0e4f023c4

findcopies: fix rename bug We've fiddled with this line several times, and an old bug has reappeared from it. Let's take a peek at the history. The original "or" (rev 3674, in 0.9.2 and 0.9.3): http://www.selenic.com/hg/rev/9103dab96093 Then I changed it to an "and" to fix a bug (rev 4304): http://www.selenic.com/hg/rev/4787e2b0dd03 Then for reasons now lost in the mists of time, I dropped half (rev 4399): http://www.selenic.com/hg/rev/93652499bed3 Then we added back the "or" (rev 4416, in 0.9.4): http://www.selenic.com/hg/rev/bb1800a7d7e1 So it seems it ought to be "and".
author Matt Mackall <mpm@selenic.com>
date Mon, 08 Oct 2007 18:47:22 -0500
parents ced5f5ceb172
children e5e6dd8ba6bb
line wrap: on
line source

#!/bin/sh
#
# Build a Mercurial RPM in place.
#
# Bryan O'Sullivan <bos@serpentine.com>

root="`hg root 2>/dev/null`"
specfile=contrib/mercurial.spec

if [ -z "$root" ]; then
    echo 'You are not inside a Mercurial repository!' 1>&2
    exit 1
fi

rpmdir=/tmp/"`basename $root | sed 's/ /_/'`"-rpm

cd "$root"
rm -rf $rpmdir
mkdir -p $rpmdir/RPMS
hg clone "$root" $rpmdir/BUILD

if [ ! -f $specfile ]; then
    echo "Cannot find $specfile!" 1>&2
    exit 1
fi

tmpspec=/tmp/`basename "$specfile"`.$$
# Use the most recent tag as the version.
version=`hg tags | perl -e 'while(<STDIN>){if(/^(\d\S+)/){print$1;exit}}'`
# Compute the release number as the difference in revision numbers
# between the tip and the most recent tag.
release=`hg tags | perl -e 'while(<STDIN>){/^(\S+)\s+(\d+)/;if($1eq"tip"){$t=$2}else{print$t-$2+1;exit}}'`
tip=`hg -q tip`

# Beat up the spec file
sed -e 's,^Source:.*,Source: /dev/null,' \
    -e "s,^Version:.*,Version: $version," \
    -e "s,^Release:.*,Release: $release," \
    -e "s,^%prep.*,Changeset: $tip\n\0," \
    -e 's,^%setup.*,,' \
    $specfile > $tmpspec

rpmbuild --define "_topdir $rpmdir" -bb $tmpspec
if [ $? = 0 ]; then
    rm -rf $tmpspec $rpmdir/BUILD
    mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS
    echo
    echo "Packages are in $rpmdir"
fi