view contrib/buildrpm @ 5377:756a43a30e34

convert: readd --filemap To handle merges correctly, this revision adds a filemap_source class that wraps a converter_source and does the work necessary to calculate the subgraph we're interested in. The wrapped converter_source must provide a new getchangedfiles method that, given a revision rev, and an index N, returns the list of files that are different in rev and its Nth parent. The implementation depends on the ability to skip some revisions and to change the parents field of the commit objects that we returned earlier. To make the conversion restartable, we assume the revisons in the revmapfile are topologically sorted.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Thu, 04 Oct 2007 23:21:37 -0300
parents 6def53be19fb
children
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>){($tag,$id)=/^(\S+)\s+(\d+)/;if($tag eq "tip"){$tip = $id}elsif($tag=~/^\d/){print $tip-$id+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

cat <<EOF >> $tmpspec
%changelog
* `date +'%a %b %d %Y'` `hg showconfig ui.username` $version-$release
- Automatically built via $0

EOF
hg log \
     --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \
     .hgtags \
  | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \
        -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \
   >> $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