From: Alexey Tourbin <at@altlinux.ru> To: devel@altlinux.ru Subject: [devel] cpan2spec Date: Thu, 29 Apr 2004 00:37:40 +0400 Message-ID: <20040428203740.GK1895@solemn.turbinal.org> (raw) [-- Attachment #1.1: Type: text/plain, Size: 1185 bytes --] Здравствуйте. У кого-нибудь есть любимые перловые модули, которых нет в сизифе? Нарисовал скрипт для упрощенной генерации spec-файла (наподобие cpan2rpm, но окончательно джина из бутылки выпускать нельзя:)). $ cpan2spec ~/RPM/SOURCES/Bloom-Filter-0.02.tar.bz2 %define dist Bloom-Filter Name: perl-%dist Version: 0.02 Release: alt1 Summary: Sample Perl Bloom filter implementation License: GPL or Artistic Group: Development/Perl URL: %CPAN %dist Source: %dist-%version.tar.bz2 BuildArch: noarch %description A Bloom filter is a probabilistic algorithm for doing existence tests in less memory than a full list of keys would require. The tradeoff to using Bloom filters is a certain configurable risk of false positives. This module implements a simple Bloom filter with configurable capacity and false positive rate. Bloom filters were first described in a 1970 paper by Burton Bloom, see http://portal.acm.org/citation.cfm?id=362692&dl=ACM&coll=portal. %prep %setup -q -n %dist-%version %build %perl_vendor_build %install %perl_vendor_install %files %doc README Changes %perl_vendor_privlib/Bloom* %perl_vendor_man3dir/Bloom* $ [-- Attachment #1.2: cpan2spec --] [-- Type: text/plain, Size: 3847 bytes --] #!/usr/bin/perl # $Id$ use Switch; use Cwd qw(realpath); use ExtUtils::MakeMaker; use File::Find qw(find); use File::Temp qw(tempdir); use sigtrap qw(die normal-signals); use strict; my %spec = ( Name => 'perl-%dist', Release => 'alt1', License => 'GPL or Artistic', Group => 'Development/Perl', URL => '%CPAN %dist', Source => '%dist-%version.tar.bz2', BuildArch => 'noarch', prep => '%setup -q -n %dist-%version', build => '%perl_vendor_build', install => '%perl_vendor_install', ); my @order = ( # name, type, optional [qw[ dist macro ]], [qw[ Name tag ]], [qw[ Version tag ]], [qw[ Release tag ]], [qw[ ]], [qw[ Summary tag ]], [qw[ License tag ]], [qw[ Group tag ]], [qw[ ]], [qw[ URL tag ]], [qw[ Source tag ]], [qw[ ]], [qw[ BuildArch tag 1 ]], [qw[ ]], [qw[ description section ]], [qw[ ]], [qw[ prep section ]], [qw[ ]], [qw[ build section ]], [qw[ ]], [qw[ install section ]], [qw[ ]], [qw[ files section ]], ); @ARGV == 1 or print STDERR <<EOF and exit(1); Usage: 1) go get your module at http://search.cpan.org/ 2) zme <module>.tar.gz 3) $0 <module>.tar.*z* > ~/RPM/SOURES/perl-<module>.spec 4) vim ~/RPM/SOURES/perl-<module>.spec 5) buildreq ~/RPM/SOURES/perl-<module>.spec 6) add_changelog -e 'initial revision' ~/RPM/SOURES/perl-<module>.spec 7) rpm -ba ~/RPM/SOURES/perl-<module>.spec EOF { my $tarball = realpath $ARGV[0]; my $dir = tempdir "cpan2spec.XXXXXXXXXX", TMPDIR => 1, CLEANUP => 1; chdir $dir; my $z = $tarball =~ /\.tar.bz2$/ && 'j' || $tarball =~ /\.tar.gz$/ && 'z' || do { my $exhort = q(shpx gneonyy); $exhort =~ tr/A-Za-z/N-ZA-Mn-za-m/; die "$exhort $tarball\n"; }; system "tar", "xf$z", $tarball; chdir <*>; my $makefile; system $^X, qw(-pi -e s/\bexit\b/return/g Makefile.PL); *ExtUtils::MakeMaker::WriteMakefile = sub { $makefile = { @_ }; bless $makefile, 'MM' } and do './Makefile.PL'; $$makefile{DISTNAME} ||= $$makefile{NAME} and $$makefile{DISTNAME} =~ s/::/-/g; $spec{dist} ||= $$makefile{DISTNAME}; find { wanted => sub { $$makefile{VERSION_FROM} ||= $_ if /\.pm$/ } => no_chdir => 1 } => "."; $spec{Version} ||= $$makefile{VERSION} || $makefile->parse_version($$makefile{VERSION_FROM}); $spec{Summary} ||= $$makefile{ABSTRACT} || $makefile->parse_abstract($$makefile{ABSTRACT_FROM} || $$makefile{VERSION_FROM}); $spec{Summary} ||= do { open my $fh, ($$makefile{ABSTRACT_FROM} || $$makefile{VERSION_FROM}); my @lines = <$fh>; shift @lines while grep { /^=head1\s+name/i } @lines; shift @lines; local $_ = shift @lines; s/^[\w:-]+\s+[^\w\s]+\s+//; $_; }; $spec{description} ||= do { open my $fh, ($$makefile{ABSTRACT_FROM} || $$makefile{VERSION_FROM}); my @lines = <$fh>; shift @lines while grep { /^=head1\s+descr/i } @lines; shift @lines; local $_ = shift @lines; for my $line (@lines) { last unless $line =~ /\S/; $_ .= $line; } $_; }; my $xs; find sub { ++$xs if /\.(xs|c)$/ } => "."; delete $spec{BuildArch} if $xs; my @doc = (<README*>, <Change*>); $spec{files} .= "\%doc @doc\n" if @doc; my %glob; find sub { /\.pm$/ and do { open my $fh, $_; map { /^package\s+(\w+)/ && ++$glob{$1} } <$fh>; }} => "."; foreach my $glob (sort keys %glob) { $spec{files} .= $xs ? "\%perl_vendor_archlib/$glob*\n\%perl_vendor_autolib/$glob*\n" : "\%perl_vendor_privlib/$glob*\n"; $spec{files} .= "\%perl_vendor_man3dir/$glob*\n"; } } for (@order) { print "\n" and next unless @$_; next if not $spec{$$_[0]} and $$_[2]; switch ($$_[1]) { case 'macro' { print "\%define $$_[0] " } case 'tag' { print "$$_[0]: " } case 'section' { print "\%$$_[0]\n" } else { die "$$_[1] \n" } } print $spec{$$_[0]} . "\n"; } [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2004-04-28 20:37 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-04-28 20:37 Alexey Tourbin [this message] 2004-04-28 21:20 ` [devel] cpan2spec Michael Shigorin 2004-04-29 3:59 ` [devel] cpan2spec Alexey I. Froloff 2004-04-29 8:10 ` [devel] cpan2spec Alexey Tourbin 2004-04-29 9:00 ` [devel] cpan2spec Artem Pastukhov 2004-04-29 9:47 ` [devel] cpan2spec Alexey Tourbin 2004-04-29 12:40 ` Alexey Tourbin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040428203740.GK1895@solemn.turbinal.org \ --to=at@altlinux.ru \ --cc=devel@altlinux.ru \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git