[freeside-commits] freeside/rpm/build build-freeside, NONE, 1.1 cvs-check-and-build, NONE, 1.1 enrpm, NONE, 1.1 expect-addsign, NONE, 1.1 expect-signrepo, NONE, 1.1 ovid2flute, NONE, 1.1 refresh-repo, NONE, 1.1

Ivan,,, ivan at wavetail.420.am
Wed Jul 7 10:52:00 PDT 2010


Update of /home/cvs/cvsroot/freeside/rpm/build
In directory wavetail.420.am:/tmp/cvs-serv19579/build

Added Files:
	build-freeside cvs-check-and-build enrpm expect-addsign 
	expect-signrepo ovid2flute refresh-repo 
Log Message:
checking in RPM build system

--- NEW FILE: cvs-check-and-build ---
#!/bin/sh
#
# Copyright 2009, Elirion, Inc.  All rights reserved.
# This software is licensed under the same terms as Freeside itself.
#
# This script wraps other scripts in the build system.  It does a CVS comparison on the vserver
# to determine if the CVS contents have changed.  If so, an SRPM is built.  The script then invokes
# the local build script which pulls down this SRPM and uses mock to build binary RPMs for the
# default targets.  Finally, the repository is updated.
#
# There's currently no testing for failure.

FORCE_FLAG=
QUIET_FLAG=

usage() {
	echo "cvs-check-and-build: check Freeside CVS and build RPMs if changed"
	echo "where:"
	echo " -f: force SRPM rebuild even if CVS contents have not changed"
	echo " -h: print this help message"
	echo " -q: run yum-arch and createrepo in quiet mode"
	exit 0
}

while getopts "fhq" flag
do
        case $flag in
		f)
			echo "Force mode"
			FORCE_FLAG=-f;;
		q)
			echo "Quiet mode"
			QUIET_FLAG=-q;;
		*)
			usage;;
        esac
done

ssh 10.5.4.5 /home/rsiddall/build-from-cvs $FORCE_FLAG
cd /home/rsiddall/buildsys; ./build-freeside; ./refresh-repo $QUIET_FLAG


--- NEW FILE: build-freeside ---
#!/bin/sh
#
# Copyright 2008, Elirion, Inc.  All rights reserved.
# This software is licensed under the same terms as Freeside itself.
#
# This script rebuilds SRPMs of Freeside builds or the required Perl modules on all the target
# distributions and versions using mock.  After a successful build, it signs the resulting RPMs
# and scp's them to the server where the yum repositories are hosted.
# (Of course, koji is supposed to do all this, including updating the repo.)

VERSIONS='1.7 1.9'
REPO=testing
BRANCH=
DISTROS='centos sles'
CENTOSVERS='4 5'
SLESVERS=10
WHICHVERS=
ARCHS='i386 x86_64'
MOCKARGS='--autocache'

BUILDSYSDIR=`dirname $0`

if [ -f $HOME/buildsysrc ]; then
	. $HOME/buildsysrc
fi

usage() {
	echo "build-freeside: build RPMs for all target distros and architectures using mock"
	echo "where:"
	echo " -a <archs>: change architectures (currently: $ARCHS)"
	echo " -b <branch>: change branch (currently: $BRANCH)"
	echo " -d <distros>: change distributions (currently: $DISTROS)"
	echo " -m <arguments>: change arguments passed to 'mock' (currently: $MOCKARGS)"
	echo " -r <repo>: change repositories (currently: $REPO)"
	echo " -s <srpms>: build these SRPMs instead of new ones in staging area"
	echo " -v <versions>: change versions (currently: $VERSIONS)"
	echo " -w <distvers>: change distro version (currently: $WHICHVERS)"
	exit 0
}

while getopts "a:b:d:hm:r:s:v:w:" flag
do
	case $flag in
		a)
			echo "Changing architectures from $ARCHS to $OPTARG"
			ARCHS=$OPTARG;;
		b)
			echo "Changing branch from $BRANCH to $OPTARG"
			BRANCH=$OPTARG;;
		d)
			echo "Changing distros from $DISTROS to $OPTARG"
			DISTROS=$OPTARG;;
		m)
			echo "Changing mock arguments from $MOCKARGS to $OPTARG"
			MOCKARGS=$OPTARG;;
		r)
			echo "Changing repository from $REPO to $OPTARG"
			REPO=$OPTARG;;
		s)
			echo "Changing SRPMS from $SRPMS to $OPTARG"
			SRPMS=$OPTARG;;
		v)
			echo "Changing versions from $VERSIONS to $OPTARG"
			VERSIONS=$OPTARG;;
		w)
			echo "Changing which distro versions from $WHICHVERS to $OPTARG"
			WHICHVERS=$OPTARG;;
		*)
			usage;;
	esac
done

if [ "${SRCFOLDER}x" = "x" ]; then
	echo "No source folder defined!"
	exit
fi

if [ "${REFFOLDER}x" = "x" ]; then
	echo "No reference folder defined!"
	exit
fi

if [ "${SRPMS}x" = "x" ]; then
	# Work out the new SRPMs on grosbeak
	SRPMS=`/usr/bin/rsync -Cavz --dry-run $SRCFOLDER/ $REFFOLDER | grep .src.rpm | grep -v safecat | tr '\n' ' '`

	# Go and get the SRPMs
	/usr/bin/rsync -Cavz $SRCFOLDER/ $REFFOLDER
fi

# Make sure the SRPMs are there
for srpm in ${SRPMS}
do
	if [ ! -f $REFFOLDER/${srpm} ]
	then
		echo "No such file: $REFFOLDER/${srpm}"
		exit
	fi
done

# Build all the SRPMs
for srpm in ${SRPMS}
do
	for distro in $DISTROS
	do
		if [ "${WHICHVERS}x" = "x" ]; then
			if [ "$distro" = "centos" ]; then
				DISTVERS=$CENTOSVERS
			fi
			if [ "$distro" = "sles" ]; then
				DISTVERS=$SLESVERS
			fi
		else
			DISTVERS=$WHICHVERS
		fi
		for distver in $DISTVERS
		do
			os=${distro}-${distver}
			for arch in $ARCHS
			do
				echo "$os - $arch: $srpm"
				time mock $MOCKARGS -r ${os}-${arch} $REFFOLDER/${srpm}
				if [ -f /var/lib/mock/${os}-${arch}/state/status ] && grep done /var/lib/mock/${os}-${arch}/state/status
				then
					for VERSION in $VERSIONS
					do
						DEST=$VERSION
						if [ "${BRANCH}x" != "x" ]
						then
							DEST=$BRANCH
						fi
						# Copy freeside RPMs for this version only
						FILES=`ls -1 /var/lib/mock/${os}-${arch}/result/freeside*-${VERSION}-*.rpm | grep -v .src.rpm | tr '\n' ' '`
						echo $FILES
						if [ "${FILES}x" != "x" ]
						then
							for FILE in $FILES
							do
								$BUILDSYSDIR/expect-addsign $FILE
							done
							if [ "${REPOMACHINE}x" != "x" ]
							then
								scp -p $FILES $REPOUSER@$REPOMACHINE:$REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
							else
								cp -p $FILES $REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
							fi
						fi
						# Copy non-freeside RPMs to all versions
						FILES=`ls -1 /var/lib/mock/${os}-${arch}/result/*.rpm | grep -v freeside | grep -v .src.rpm | tr '\n' ' '`
						echo $FILES
						if [ "${FILES}x" != "x" ]
						then
							for FILE in $FILES
							do
								$BUILDSYSDIR/expect-addsign $FILE
							done
							if [ "${REPOMACHINE}x" != "x" ]
							then
								scp -p $FILES $REPOUSER@$REPOMACHINE:$REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
							else
								cp -p $FILES $REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
							fi
						fi
					done
				fi
			done
		done
	done
done

--- NEW FILE: enrpm ---
#!/usr/bin/perl -w
#
# Attempt to build RPMs for Freeside from a tarball or module
#
# Contains portions of "cpanspec" http://cpanspec.sourceforge.net/

=head1 NAME

enrpm - Attempt to build RPMs for Freeside from a tarball or a module

=head1 SYNOPSIS

enrpm [options] [tarball|module-name [...]]

 Options:
   --help       -h      Help message

=head1 DESCRIPTION

B<enrpm> will generate a spec file to build a rpm from a CPAN-style
Perl module distribution, then try to build RPMs from that spec file
under mock, and update the repositories if successful.

B<enrpm> uses the file extension of the tarball or module-name specified
on the command line to determine if the argument is a tarball or a module name.

Modules are downloaded from the CPAN.  You must have initialized CPAN on the machine
for B<enrpm> to be able to do this.

For tarballs B<enrpm> attempts to build a usable .spec file using cpanflute2, and then builds
an SRPM from the .spec file and the tarball.

Once an SRPM has been built, B<enrpm> uses an external script to build binary RPMs under "mock".
It then uses a second script to update the repositories.

=head1 OPTIONS

=over 4

=item B<--help>

Print a brief help message and exit.

=item B<--packager>

Specify the name and e-mail address of the packager.  This winds up in auto-generated .spec files.

=item B<--server>

Specify the host name or IP address of the server on which the SRPM will be built.  This server must be
set up for SRPM building, which means it must have both B<ovid> and B<cpanflute2> installed on it.

=item B<--dry-run>

Just print out commands, don't actually run them.

=back

=head1 BUGS

Currently has little in the way of error detection and diagnostics.

The back-end should be replaced with an existing build system such as koji.

=head1 AUTHOR

Richard Siddall <richard.siddall at elirion.net>

=head1 SEE ALSO

L<perl(1)>, L<cpan2rpm(1)>, L<cpanflute2(1)>

=cut

use strict;
use Getopt::Long;
use Cwd qw/getcwd abs_path/;
use File::Basename;
use Sys::Hostname; # False laziness to get around a real config file...

my %opts;

GetOptions(\%opts, 'packager=s', 'release=s', 'server=s', 'dryrun');

$ENV{PATH} = "/bin:/usr/bin";

sub usage {
	print STDERR "usage: enrpm --packager <Your Name <you\@example.com>> [--release=<rpm-release-string>] --server <server-name> [--dryrun] tarball|module-name\n";
	print STDERR "where:\n\t--packager is the name and e-mail address of the packager for the .spec file\n\t--release is the rpm release number for the .spec file\n\t--server is the server to build the SRPM on\n\t--dryrun means do not actually run the commands\n\n";
	print STDERR "\ttarball is the name of a tarball containing the Perl module to be packaged\n";
	print STDERR "\tmodule-name is the name of a CPAN Perl module to be packaged\n";
	exit;
}

# Feeble excuse for not having a real configuration file
my $user = 'rsiddall';
my $buildsys = '/home/rsiddall/work';
my $rembuild = '/home/rsiddall/work/cvs';
my $remdeps = '/home/rsiddall';
my $rpmtopdir = '/home/rsiddall/work/redhat';
my $packager = 'Richard Siddall <richard.siddall at elirion.net>';
my $server = 'grosbeak';

if (hostname =~ /wavetail/i) {
	$buildsys = '/home/rsiddall/buildsys';
	$rembuild = '/home/rsiddall/buildsys/ref';
	$remdeps = '/home/rsiddall';
	$rpmtopdir = '/home/rsiddall/redhat';
	$packager = 'Ivan Kohler <ivan at freeside.biz>';
	$server = '10.5.4.5';
}

$server = $opts{server} if defined($opts{server});
$user = $1 if $server =~ /(\w+)\@[\w\d\.]+/;

$packager = $opts{packager} if defined($opts{packager});

# Go ahead and build an SRPM...

my $ovidignore = '--ignore ' . join ('--ignore ', qw/libwww/);


for my $file (@ARGV) {
	my ($name,$version,$type);

	if ($file =~ /^(?:.*\/)?(.*)-(?:v\.?)?([^-]+)\.(tar)\.(?:gz|bz2)$/) {
		$name = $1;
		$version = $2;
		$type = $3;
	} elsif ($file =~ /^(?:.*\/)?(.*)-(?:v\.?)?([^-]+)\.tgz$/) {
		$name = $1;
		$version = $2;
		$type = 'tar';
	} elsif ($file =~ /^(?:.*\/)?(.*)-(?:v\.?)?([^-]+)\.(zip)$/) {
		$name = $1;
		$version = $2;
		$type = $3;
	} else {
		# keep things happy if we get "Foo-Bar" instead of "Foo::Bar"
		$file =~ s/-/::/g;
		$name = $file;
		$version = undef;
		$type = 'module';
	}

	if ($type eq 'module') {
		my $fluteopts = '';
		$fluteopts .= "--packager='$packager' " if defined($packager);
		$fluteopts .= "--release='$opts{release}' " if defined($opts{release});
		do_cmd("ssh $user\@$server \"ovid --deps $ovidignore $name | tail -1 | $remdeps/ovid2flute $fluteopts | /bin/sh\"");
	} else {
		my $absfile = abs_path($file);
		my $fname = basename($file);
		die "Packager name and e-mail required" if !defined($packager);
		die "RPM release string required" if !defined($opts{release});
		do_cmd("scp $absfile $user\@$server:/home/$user/$fname");
#		do_cmd("ssh $user\@$server 'cpanflute2 --just-spec --noperlreqs --email=\\\"$packager\\\" --release=$opts{release}  /home/$user/$fname > /home/$user/work/redhat/SPECS/$name.spec;'");
#		do_cmd("ssh $user\@$server 'perl -pi -e \\\"s/perl\(perl\)/perl/g\\\" /home/$user/work/redhat/SPECS/$name.spec;'");
#		do_cmd("ssh $user\@$server 'rpmbuild -bs --nodeps --define \\\"_sourcedir /home/$user/\\\" --define \\\"_srcrpmdir /home/$user/work/redhat/SRPMS\\\" /home/$user/work/redhat/SPECS/$name.spec'");
		open SCRIPT, ">/home/$user/makesrpm" or die "Can't create SRPM construction script: ", $!;
		print SCRIPT "#!/bin/sh\n\n";
		print SCRIPT "cpanflute2 --just-spec --noperlreqs --email='$packager' --release=$opts{release}  /home/$user/$fname > $rpmtopdir/SPECS/$name.spec;\n";
		print SCRIPT "perl -pi -e 's/perl(perl)/perl/g' $rpmtopdir/SPECS/$name.spec\n";
		print SCRIPT "rpmbuild -bs --nodeps --define '_sourcedir /home/$user/' --define '_srcrpmdir $rpmtopdir/SRPMS' $rpmtopdir/SPECS/$name.spec\n";
		close SCRIPT or die "Can't close SRPM construction script: ", $!;
		chmod(0711, "/home/$user/makesrpm");
		do_cmd("scp /home/$user/makesrpm $user\@$server:/home/$user/makesrpm");
		do_cmd("ssh $user\@$server /home/$user/makesrpm");
	}
	my $olddir = getcwd();
	do_cmd("$buildsys/build-freeside");
	if (-x "$buildsys/refresh-repo") {
		do_cmd("$buildsys/refresh-repo");
	} else {
		do_cmd("ssh $user\@$server $rembuild/refresh-repo");
	}
}

sub do_cmd {
	my $cmd = shift;

	print "$cmd\n";
	`$cmd` if !exists($opts{dryrun});
}

1;


--- NEW FILE: expect-signrepo ---
#!/usr/bin/expect
set password "not our actual passphrase"
set key [lindex $argv 0]
set output [lindex $argv 1]
set input [lindex $argv 2]
spawn gpg -sab --yes -u "$key" -o $output $input
expect "Enter passphrase:"
send -- "$password\r"
expect eof

--- NEW FILE: ovid2flute ---
#!/usr/bin/perl -w
#
# Convert the output from ovid --deps into a list of modules to run through cpanflute2 to get
# better .spec files, and generate SRPMs from these.

use strict;
use Getopt::Long;

# Need to fix up modules where Ovid parses the name incorrectly
my %badparse=(
	'Crypt-PasswdMD-5' => 'Crypt-PasswdMD5',
	'IPC-Run-3' => 'IPC-Run3',
	'Digest-SHA-1' => 'Digest-SHA1',
	'Digest-MD-4' => 'Digest-MD4',
);

my %extra_buildreqs=(
	'File-Rsync' => [ qw/rsync/ ],
	'MIMETools' => [ qw/perl(Mail::Header) perl(Mail::Internet) perl(Mail::Field) perl(IO::Stringy) perl(File::Temp)/ ],
	'HTML::Scrubber' => [ qw/perl(HTML::Parser) perl(HTML::Tagset)/ ],
#	'Time::Duration' => [ qw/perl(Test::Pod) perl(Test::Pod::Coverage)/ ],
);

my %extra_reqs=(
	'File-Rsync' => [ qw/rsync/ ],
);

my %opts;

GetOptions(\%opts, 'packager=s', 'release=s');

$opts{packager} = 'Richard Siddall <richard.siddall at elirion.net>' if !defined($opts{packager});

# Need to process modules that cause Ovid to crash
#my @extramods= qw/Text::CSV_XS Pod::Simple Crypt::SSLeay/;
#my @extramods= qw/Crypt::SSLeay/;
my @extramods= qw/IPC::ShareLite/;

my $specfiledir="/home/rsiddall/work/redhat/SPECS";
my $srpmdir="/home/rsiddall/work/redhat/SRPMS";

foreach (reverse <STDIN>) {
	next if !defined($_);
	#print $_;
	last if $_ !~ /^([-\w:]+) perl-([-\w\.]+)(-\d+[\w\.]+?)$/;
	#print "$1 = $2\n"
	my ($name, $rpm, $ver) = ($1, $2, $3);
	print "# $name ($rpm - $ver)\n";
	foreach my $cand (keys %badparse) {
		if ($rpm =~ /^$cand/) {
			$rpm =~ s/^$cand/$badparse{$cand}/;
			print "# Fixed up $rpm\n";
			last;
		}
	}
	printcmds($name, "$rpm$ver");
	#print "cpanspec -v --packager 'Unknown <nobody\@example.com>' $name\n";
	#print "echo $rpm\n";
	#print "repoquery perl-$rpm\n";
	#touchsrpms($name, "$rpm$ver");
}

exit;

foreach my $name (@extramods) {
	my $rpm = $name;
	$rpm =~ s/::/-/g;
	my $tarball = `find ~/.cpan/sources -name '$rpm-*' -print | tail -1`;
	#print "$name (Extra!)\n"
	if ($tarball =~ /\/($rpm-.*?)(\.tar\.gz|\.tgz)\s*$/) {
		$rpm = $1;
		printcmds($name, $rpm);
	} else {
		die "Can't find full rpm name for $name in \"$tarball\"\n";
	}
}

sub touchsrpms {
	my ($name, $rpm) = @_;
	my $repofolder ="/var/www/html/repo/sles/10/freeside-1.9/stable/x86_64";
	my $srpmfolder ="/home/rsiddall/work/redhat/SRPMS";
	my @files = glob "$repofolder/perl-$rpm-*.rpm";
	if (! scalar(@files)) {
		print "Can't find $rpm in $repofolder\n";
		@files = glob "$srpmfolder/perl-$rpm-*.src.rpm\n";
		if (scalar(@files)) {
			my $file = pop @files;
			print "touch $file\n";
		} else {
			print STDERR "No corresponding SRPM: $srpmfolder/perl-$rpm-*.src.rpm\n";
			printcmds($name, $rpm);
		}
	}
}

sub printcmds {
	my ($name, $rpm) = @_;

	my $tarball = `find ~/.cpan -name '$rpm.tar.gz' -print`;
	$tarball = `find ~/.cpan -name '$rpm.tgz' -print` if ! $tarball;
	chomp($tarball);
#	my $specfile = "$specfiledir/$name.spec";
	my $rpmname = $rpm;
	$rpmname = $1 if $rpm =~ /^(?:.*\/)?(.*)-(?:v\.?)?([^-]+)$/;
	my $specfile = "$specfiledir/perl-$rpmname.spec";
	$specfile =~ s/::/-/g;
	# Work out which version of the SRPM we're going to generate.
	my $rel;
	if (!defined($opts{release})) {
		for ($rel = 1; ; $rel++) {
			my $srpm = "$srpmdir/perl-$rpm-$rel.src.rpm";
			last if ! -e $srpm;
			print "# File exists: $srpm\n";
		}
	} else {
		$rel = $opts{release};
	}
	my $fluteopts = "";
	foreach my $cand (keys %extra_buildreqs) {
		if ($rpm =~ /^$cand/) {
			$fluteopts .= join "", map { "--buildrequires $_ " } @{$extra_buildreqs{$cand}};
			last;
		}
	}
	foreach my $cand (keys %extra_reqs) {
		if ($rpm =~ /^$cand/) {
			$fluteopts .= join "", map { "--requires $_ " } @{$extra_reqs{$cand}};
			last;
		}
	}
	print "cpanflute2 --just-spec --noperlreqs --email='$opts{packager}' --release=$rel $fluteopts $tarball > $specfile;\n";
	# Should fix up the .spec file
	print "perl -pi -e 's/perl\\(perl\\)/perl/g' $specfile;\n";
	my $tarballdir = `dirname $tarball` or die "Can't find tarball for $name: $tarball\n";
	chomp($tarballdir);
	print "rpmbuild -bs --nodeps --define '_sourcedir $tarballdir' --define '_srcrpmdir $srpmdir' $specfile\n";
	print "# Generates: $srpmdir/perl-$rpm-$rel.src.rpm\n";
}


--- NEW FILE: refresh-repo ---
#!/bin/sh
#
# Copyright 2008, Elirion, Inc.  All rights reserved.
# This software is licensed under the same terms as Freeside itself.
#
# This script iterates through all the specified Freeside repositories, running
# both yum-arch and createrepo to update the yum repository meta-data.
# The script should be run after the repository contents are changed.
#
# TBD: Run yum-arch, createrepo, or both, as appropriate for the distro and version
# the repository is targetted for.
#
DISTROS='centos sles'
CENTOSVERS='4 5'
SLESVERS=10
WHICHVERS=
VERSIONS='1.7 1.9'
ARCHS='i386 x86_64'
REPOS='testing stable prerelease'
RPMS=
KEYID=rsiddall
SAVEDIR=$HOME

REPOBASEFOLDER=/var/www/html

QUIET_FLAG=

BUILDSYSDIR=`dirname $0`

if [ -f $HOME/buildsysrc ]; then
	. $HOME/buildsysrc
fi

usage() {
	echo "refresh-repo: refresh yum metadata for all yum repositories"
	echo "where:"
	echo " -a <archs>: change architectures (currently: $ARCHS)"
	echo " -d <distros>: change distributions (currently: $DISTROS)"
	echo " -r <repos>: change repositories (currently: $REPOS)"
	echo " -v <versions>: change versions (currently: $VERSIONS)"
	echo " -w <distvers>: change distro version (currently: $WHICHVERS)"
	exit 0
}

while getopts "a:d:hqr:v:w:" flag
do
        case $flag in
                a)
                        echo "Changing architectures from $ARCHS to $OPTARG"
                        ARCHS=$OPTARG;;
                d)
                        echo "Changing distros from $DISTROS to $OPTARG"
                        DISTROS=$OPTARG;;
		q)
			echo "Quiet mode"
			QUIET_FLAG=-q;;
                r)
                        echo "Changing repository from $REPOS to $OPTARG"
                        REPOS=$OPTARG;;
                v)
                        echo "Changing versions from $VERSIONS to $OPTARG"
                        VERSIONS=$OPTARG;;
                w)
                        echo "Changing which distro versions from $WHICHVERS to $OPTARG"
                        WHICHVERS=$OPTARG;;
		*)
			usage;;
        esac
done

#for DISTRO in ${DISTROS}; do
#	for VERSION in ${VERSIONS}; do
#		for REPO in ${REPOS}; do
#			for ARCH in ${ARCHS}; do
#				# Determine which RPMs need to be signed
#				NEWRPMS=`rpm --checksig $REPOBASEFOLDER/repo/$DISTROS/$DISTVERS/freeside-${VERSION}/${REPO}/${ARCH}/*.rpm | grep -v ' gpg ' | cut -d ':' -f 1 | tr '\n' ' '`
#				RPMS=`echo "$RPMS $NEWRPMS"`
#			done
#		done
#	done
#done
##rpm --addsign $RPMS
#for RPM in $RPMS; do
#	./expect-addsign $RPM
#done
for DISTRO in ${DISTROS}; do
	for VERSION in ${VERSIONS}; do
		for REPO in ${REPOS}; do
			for ARCH in ${ARCHS}; do
				if [ "${WHICHVERS}x" = "x" ]; then
					if [ "$DISTRO" = "centos" ]; then
						DISTVERS=$CENTOSVERS
					fi
					if [ "$DISTRO" = "sles" ]; then
						DISTVERS=$SLESVERS
					fi
				else
					DISTVERS=$WHICHVERS
				fi
				for distver in $DISTVERS
				do
					# Update the repo information
					echo "${DISTRO}-${distver}: $VERSION - $REPO - $ARCH"
					DIR=$REPOBASEFOLDER/repo/$DISTRO/$distver/freeside-${VERSION}/${REPO}/${ARCH}
					if [ -d $DIR ]
					then
						# SLES requires signed repodata.  Save any existing files so we don't regenerate
						for ext in asc key
						do
							if [ -e $DIR/repodata/repomd.xml.${ext} ]
							then
								mv $DIR/repodata/repomd.xml.${ext} $SAVEDIR
							fi
						done
						if [ "$DISTRO" = "sles" ]
						then
							for file in $DIR/freeside-mysql-*.rpm
							do
								mv $file $file.old
							done
							for file in $DIR/freeside-selfservice-*.rpm
							do
								mv $file $DIR/../self-service/$ARCH
							done
						fi
						if [ "$DISTRO-$distver" = "centos-4" ]
						then
							yum-arch $QUIET_FLAG $DIR/
						fi
#						createrepo $QUIET_FLAG --checkts $DIR/
						createrepo $QUIET_FLAG $DIR/
						if [ "$DISTRO" = "sles" ]
						then
							# SLES requires signed repodata...
							if [ -e $SAVEDIR/repomd.xml.asc ]
							then
								mv $SAVEDIR/repomd.xml.asc $DIR/repodata
							fi

#							gpg -sab --yes -u "$KEYID" -o $DIR/repodata/repomd.xml.asc $DIR/repodata/repomd.xml
							./expect-signrepo $KEYID $DIR/repodata/repomd.xml.asc $DIR/repodata/repomd.xml
							if [ -e $SAVEDIR/repomd.xml.key ]
							then
								mv $SAVEDIR/repomd.xml.key $DIR/repodata
							else
								gpg -a --yes -u "$KEYID" --export -o $DIR/repodata/repomd.xml.key
							fi
						fi
					else
						echo "No such folder $DIR - skipping"
					fi
				done
			done
		done
	done
done

--- NEW FILE: expect-addsign ---
#!/usr/bin/expect
set p "not our actual passphrase"
set f [lindex $argv 0]
spawn /bin/rpm --resign $f
expect "Enter pass phrase:"
send -- "$p\r"
expect eof



More information about the freeside-commits mailing list