ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Michael Shigorin <mike@osdn.org.ua>
To: ALT Linux Team development discussions <devel@lists.altlinux.org>
Subject: Re: [devel] perl packages
Date: Tue, 16 Dec 2008 12:20:40 +0200
Message-ID: <20081216102040.GC10134@osdn.org.ua> (raw)
In-Reply-To: <20081216071956.GC21286@altlinux.org>

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

On Tue, Dec 16, 2008 at 10:19:56AM +0300, Alexey Tourbin wrote:
> > - в каком состоянии сейчас cpan2rpm (в курсе ли он про свежие
> > изменения при упаковки перловых модулей)?
> Не следует использовать cpan2rpm.

1) почему, или "вообще"?
2) а cpan2spec?

-- 
 ---- WBR, Michael Shigorin <mike@altlinux.ru>
  ------ Linux.Kiev http://www.linux.kiev.ua/

[-- Attachment #2: cpan2spec --]
[-- Type: text/plain, Size: 3706 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";
}

  reply	other threads:[~2008-12-16 10:20 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-10  3:45 Денис Смирнов
2008-12-16  7:19 ` Alexey Tourbin
2008-12-16 10:20   ` Michael Shigorin [this message]
2008-12-17  4:52     ` Alexey Tourbin
2008-12-17  6:44       ` Vitaly Lipatov
2008-12-29  9:27       ` Michael Shigorin
2008-12-18 11:24     ` Денис Смирнов
2008-12-18 11:54       ` Vladimir V. Kamarzin
2008-12-29  9:29       ` Michael Shigorin
2008-12-16 20:38   ` Vitaly Lipatov
2008-12-17  4:35     ` Alexey Tourbin
2008-12-17  6:44       ` Vitaly Lipatov
2008-12-17  7:11         ` Alexey Tourbin
2008-12-17  8:10           ` Igor Vlasenko
2008-12-17 19:53             ` [devel] perl packages [JT] Vitaly Lipatov
2008-12-21 12:31               ` Igor Vlasenko
2008-12-21 13:05                 ` Vitaly Lipatov
2008-12-21 13:35                   ` Igor Vlasenko
2008-12-21 13:41                 ` Igor Vlasenko
2008-12-22 17:14                   ` Slava Dubrovskiy
2008-12-17 20:00           ` [devel] perl packages Vitaly Lipatov
2008-12-29  9:21           ` [devel] майнтейнеры бывают разные *и это нормально* Michael Shigorin
2008-12-29  9:28             ` Led
2008-12-29 10:27               ` Michael Shigorin
2008-12-30 15:47             ` Alexey Tourbin
2008-12-30 15:53               ` Mikhail Gusarov
2008-12-30 15:53                 ` Mikhail Gusarov
2008-12-30 16:34                 ` Alexey Tourbin
2008-12-30 16:45                   ` Mikhail Gusarov
2008-12-30 17:25                     ` Alexey Tourbin
2008-12-30 17:38                       ` Mikhail Gusarov
2008-12-31 20:44                       ` Michael Shigorin
2008-12-31  4:30                 ` [devel] [JT] " Alexey Morozov
2008-12-31 20:46                   ` Michael Shigorin
2009-01-07 13:37                 ` [devel] " Led
2009-01-07 13:38                   ` Mikhail Gusarov
2008-12-31 20:39               ` Michael Shigorin
2009-01-01  0:13                 ` Alexey Tourbin
2009-01-01  1:11                   ` Денис Смирнов
2009-01-01 16:55                   ` Michael Shigorin
2009-01-01 17:10                     ` Aleksey Novodvorsky
2009-01-01 17:38                       ` Michael Shigorin
2009-01-01 18:14                         ` Denis Klimov
2009-01-02 11:52                           ` Michael Shigorin
2009-01-07 14:13                           ` Led
2009-01-07 14:24                             ` Mikhail Gusarov
2009-01-07 18:54                               ` Led
2009-01-07 19:37                                 ` Slava Semushin
2009-01-07 20:30                                 ` Michael Shigorin
2009-01-11  9:13                               ` Stanislav Ievlev
2009-01-11 11:51                                 ` Mikhail Gusarov
2009-01-11 12:24                                 ` Ivan A. Melnikov
2009-01-02 11:51                         ` Michael Shigorin
2009-01-12 15:46                       ` Andrii Dobrovol`s`kii
2009-01-12 20:45                         ` Aleksey Novodvorsky
2009-01-13 12:49                           ` Andrii Dobrovol`s`kii
2009-01-13 13:56                             ` Led
2009-01-13 15:38                               ` Денис Смирнов
2009-01-13 16:03                                 ` Led
2009-01-13 16:08                                 ` Alexey I. Froloff
2009-01-13 16:10                                   ` Led
2009-01-14  6:32                                     ` Денис Смирнов
2009-01-13 16:36                                   ` Kirill A. Shutemov
2009-01-14  6:32                                   ` Денис Смирнов
2009-01-13 16:54                               ` Andrii Dobrovol`s`kii
2009-01-01 17:20                   ` Wartan Hachaturow
2009-01-07 14:15                     ` Led
2008-12-29  9:17       ` [devel] perl packages Michael Shigorin

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=20081216102040.GC10134@osdn.org.ua \
    --to=mike@osdn.org.ua \
    --cc=devel@lists.altlinux.org \
    /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