# HG changeset patch # User mpm@selenic.com # Date 1120255660 28800 # Node ID ced5f5ceb17205fad94afa6b98e2c03083b2c14a # Parent 42a6a41ab76b3f95465ea441c7317f83f5f7539f [PATCH] Add contrib/buildrpm script -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [PATCH] Add contrib/buildrpm script From: Bryan O'Sullivan Just run "buildrpm", and it builds an RPM for you. No funky monkey business required. manifest hash: b8fde5108b5cc8f49ce248d14ac2ee7ad004c91c -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCxb6sywK+sNU5EO8RApQZAJ94VD6NQr9l4Xx6w3S8EdpCIUuiIACfdoHA qnQWtMM+kqAzi3LnO92UYWE= =SWIO -----END PGP SIGNATURE----- diff -r 42a6a41ab76b -r ced5f5ceb172 contrib/buildrpm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/buildrpm Fri Jul 01 14:07:40 2005 -0800 @@ -0,0 +1,49 @@ +#!/bin/sh +# +# Build a Mercurial RPM in place. +# +# Bryan O'Sullivan + +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(){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(){/^(\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