head	1.4;
access;
symbols
	rpm-4_4_8-release:1.4
	rpm-4_4_7-release:1.4
	rpm-4_4_6-release:1.4
	rpm-4_4_5-release:1.4
	rpm-4_4_4-release:1.4
	rpm-4_4_3-release:1.4
	jbj_before_tklcpatches:1.4
	rpm-4_4_2-release:1.4
	pjones-sparse-experiment:1.4.0.10
	rpm-4_4_1-release:1.4
	rpm-4_4-release:1.4
	rpm-4_4:1.4.0.8
	rpm-4_3_1-start:1.4
	rpm-4_3:1.4.0.6
	rpm-4_2_1-release:1.4
	rpm-4_1_1-release:1.4
	rpm-4_2-release:1.4
	rpm-4_2:1.4.0.4
	rpm-4_1-release:1.4
	rpm-4_1:1.4.0.2
	rpm-4_0_4-release:1.3.8.1
	jbj-before-beecrypt:1.3.8.1
	rpm-4_0_3-release:1.3.8.1
	jbj_b4_rollback:1.3.8.1
	rpm-4_0_2-release:1.3
	rpm-4_0_1-release:1.3
	rpm-3_0_6-release:1.3
	rpm-4_0-release:1.3
	rpm-3_0_6:1.3
	rpm-4_0:1.3.0.8
	rpm-3_0_5:1.3.0.6
	jbj_sparc64:1.3.0.4
	rpm-3_0_4:1.3.0.2;
locks; strict;
comment	@# @;


1.4
date	2001.04.22.08.58.22;	author jbj;	state Exp;
branches;
next	1.3;

1.3
date	2000.02.16.03.02.44;	author jbj;	state Exp;
branches
	1.3.8.1;
next	1.2;

1.2
date	2000.02.16.00.33.16;	author jbj;	state Exp;
branches;
next	1.1;

1.1
date	2000.02.15.22.17.44;	author jbj;	state Exp;
branches;
next	;

1.3.8.1
date	2001.04.22.08.58.08;	author jbj;	state Exp;
branches;
next	;


desc
@@


1.4
log
@- cpanflute perl dependency needs explicit epoch (#37034).
@
text
@#!/usr/bin/perl

# need this for hostname()
use File::Basename;
use Sys::Hostname;
use Getopt::Long;
use strict;

my $MainDir = '/tmp/cpan';

# set default options, then get options
my %options=();
$options{'email'}=(getpwuid($<))[0] . "\@@redhat.com" ;
GetOptions(\%options, "email=s", "n=s", "create") || exit 1;

my $InputFile = $ARGV[0];
my $create = '';

if ($options{'create'}) {
  $create = '-c';
}

my $tarball = basename($InputFile);
$tarball =~ /(\S+)\-(\S+)\.tar\.gz/;
my $clm_name=$1;
my $clm_version=$2;

my $class = dirname($InputFile);
$class =~ s/^\.\/[0-9][0-9]_//;
if ($class ne '.') {
  $class = "($class)";
} else {
  $class = "";
}

# Change ::'s to -'s
$clm_name =~ s/::/-/g;

my $clm_changelog = get_changelog();

# complain if either parameter is missing
($clm_name eq "") && die "Module name not specified\n";
($clm_version eq "") && die "Module version not specified\n";

# Create and Open file to create SPEC files.
mkdir($MainDir, 0755);
system("cp $InputFile $MainDir");
my $filename = $clm_name . '.spec'; 
open (FILE, "> $MainDir/$filename");

# Print the spec file. Lots of substitutions here.
print FILE "Summary: $clm_name module for perl $class
Name: perl-$clm_name
Version: $clm_version
Release: 7
Copyright: distributable
Group: Applications/CPAN
Source0: $clm_name-$clm_version.tar.gz
Url: http://www.cpan.org
BuildRoot: %{_tmppath}/perl-$clm_name-buildroot/
BuildRequires: perl >= 0:5.00503
Requires: perl >= 0:5.00503

%description
$clm_name module for perl

# Provide perl-specific find-{provides,requires}.
%define __find_provides /usr/lib/rpm/find-provides.perl
%define __find_requires /usr/lib/rpm/find-requires.perl

%prep
%setup -q -n $clm_name-%{version} $create

%build
CFLAGS=\"\$RPM_OPT_FLAGS\" perl Makefile.PL
make

%clean 
rm -rf \$RPM_BUILD_ROOT

%install
rm -rf \$RPM_BUILD_ROOT
eval `perl '-V:installarchlib'`
mkdir -p \$RPM_BUILD_ROOT/\$installarchlib
make PREFIX=\$RPM_BUILD_ROOT/usr install

[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress

find \$RPM_BUILD_ROOT/usr -type f -print | \
	sed \"s\@@^\$RPM_BUILD_ROOT\@@\@@g\" | \
	grep -v perllocal.pod | \
	grep -v \"\\.packlist\" > $clm_name-$clm_version-filelist
if [ \"\$(cat $clm_name-$clm_version-filelist)X\" = \"X\" ] ; then
    echo \"ERROR: EMPTY FILE LIST\"
    exit -1
fi

%files -f $clm_name-$clm_version-filelist
%defattr(-,root,root)

%changelog
* $clm_changelog
- Spec file was autogenerated. 
";
close(FILE);

# Now build the rpm
create_rcfiles();

open (LOG, "> $MainDir/LogFile");
build_rpm();
close LOG;

sub cleanup {
  unlink "$MainDir/$filename";
  unlink "$MainDir/$tarball";
}

sub build_rpm {
  my $retval;

  # First, make sure it unpacks cleanely
  system("rpm --rcfile $MainDir/rpmrc -bp $MainDir/$filename");
  $retval = $? >> 8;
  if ($retval != 0) {
    print "RPM test unpacking failed!\n";
    print LOG "PREP failed: $filename\n";
    return;
  }

  system("rpm --rcfile $MainDir/rpmrc -bs --rmsource --rmspec --clean $MainDir/$filename");
  $retval = $? >> 8;
  if ($retval != 0) {
    print "RPM building failed!\n";
    print LOG "SOURCE failed: $filename\n";
    return;
  }
  cleanup();
}

sub create_rcfiles {
    open(MACROS, "> $MainDir/macros");
    print MACROS qq{
%_topdir        $MainDir
%_builddir      %{_topdir}/junk
%_rpmdir        %{_topdir}
%_sourcedir     %{_topdir}
%_specdir       %{_topdir}
%_srcrpmdir     %{_topdir}/temp
};
    close(MACROS);
  
    open(RPMRC, "> $MainDir/rpmrc");
    print RPMRC qq{
include: /usr/lib/rpm/rpmrc
macrofiles: /usr/lib/rpm/macros:$MainDir/macros
};
    close(RPMRC);
}

sub get_changelog {
  # generate the changelog entry from available system info
	my ($name);

	$name = (getpwuid($<))[6];
	$name = (split(",", $name))[0];
  return ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")[(localtime)[6]] . " " .
    ("Jan", "Feb", "Mar", "Apr", "May", "Jun",
     "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[(localtime)[4]] . " " .
    (localtime)[3] . " " . (1900+(localtime)[5]) . " " .
		$name . " <" . $options{'email'} . ">";
}

@


1.3
log
@Compress man pages early.
@
text
@d55 1
a55 1
Release: 6
d60 3
a62 3
BuildRoot: /var/tmp/perl-$clm_name-buildroot/
BuildRequires: perl >= 5.00503
Requires: perl >= 5.00503
@


1.3.8.1
log
@- cpanflute perl dependency needs explicit epoch (#37034).
@
text
@d55 1
a55 1
Release: 7
d60 3
a62 3
BuildRoot: %{_tmppath}/perl-$clm_name-buildroot/
BuildRequires: perl >= 0:5.00503
Requires: perl >= 0:5.00503
@


1.2
log
@Improvements from Tim Powers.
@
text
@d86 3
@


1.1
log
@add scripts for autogenerating CPAN dependencies.
@
text
@d13 1
a13 1
$options{'email'}=(getpwuid($<))[0] . "\@@" . hostname();
d55 1
a55 1
Release: 2
d160 1
d162 2
d168 1
a168 1
    (getpwuid($<))[6] . " <" . $options{'email'} . ">";
@

