[svn:parrot] r39228 - in trunk: lib/Parrot tools/dev
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Thu May 28 23:00:38 UTC 2009
Author: jkeenan
Date: Thu May 28 23:00:35 2009
New Revision: 39228
URL: https://trac.parrot.org/parrot/changeset/39228
Log:
Move most description of MANIFEST to lib/Parrot/Manifest.pm and improve it. wayland++
Modified:
trunk/lib/Parrot/Manifest.pm
trunk/tools/dev/install_dev_files.pl
trunk/tools/dev/install_files.pl
Modified: trunk/lib/Parrot/Manifest.pm
==============================================================================
--- trunk/lib/Parrot/Manifest.pm Thu May 28 20:45:21 2009 (r39227)
+++ trunk/lib/Parrot/Manifest.pm Thu May 28 23:00:35 2009 (r39228)
@@ -1,11 +1,58 @@
# $Id$
# Copyright (C) 2007, Parrot Foundation.
+=head1 NAME
+
+Parrot::Manifest - Re-create MANIFEST and MANIFEST.SKIP
+
+=head1 SYNOPSIS
+
+ use Parrot::Manifest;
+
+ $mani = Parrot::Manifest->new($0);
+
+ $manifest_lines_ref = $mani->prepare_manifest();
+ $need_for_files = $mani->determine_need_for_manifest($manifest_lines_ref);
+ $mani->print_manifest($manifest_lines_ref) if $need_for_files;
+
+ $print_str = $mani->prepare_manifest_skip();
+ $need_for_skip = $mani->determine_need_for_manifest_skip($print_str);
+ $mani->print_manifest_skip($print_str) if $need_for_skip;
+
+ $print_str = $mani->prepare_gitignore();
+ $mani->print_gitignore($print_str) if $need_for_skip;
+
+=cut
+
package Parrot::Manifest;
use strict;
use warnings;
use Carp;
+=head1 METHODS
+
+=head2 new
+
+ $mani = Parrot::Manifest->new({
+ script => $0,
+ file => $filename,
+ skip => $skipfilename,
+ gitignore => $gitignoresfilename,
+ })
+
+Creates a Parrot::Manifest object by asking C<svn status> for verbose output,
+and parsing the results.
+
+C<file> is the name of the file that the manifest will eventually be written
+to, and defaults to F<MANIFEST>. C<skip> is the name of the file that will
+hold the list of files to be skipped, and defaults to F<MANIFEST.SKIP>.
+C<gitignore> contains the same information as F<MANIFEST.SKIP> in a different
+format. It defaults to F<.gitignore>. The C<script> parameter is the name of
+the program invoking Parrot::Manifest, for use in messages.
+
+=cut
+
+# ...the results go into $self->{dirs} and $self->{versioned_files}
sub new {
my $class = shift;
my $argsref = shift;
@@ -55,6 +102,16 @@
return $self;
}
+=head2 prepare_manifest
+
+ $manifest_lines_ref = $mani->prepare_manifest();
+
+Prepares the manifest from the read in by the C<new()> method, and returns a
+hash of the files. The keys of the hash are the filenames, and the values are
+strings representing the package and a list of the meta flags.
+
+=cut
+
sub prepare_manifest {
my $self = shift;
@@ -66,6 +123,32 @@
return \%manifest_lines;
}
+=head2 determine_need_for_manifest
+
+ $need_for_files =
+ $mani->determine_need_for_manifest($manifest_lines_ref);
+
+Determines the need for the manifest. The checks are:
+
+=over 4
+
+=item *
+
+If there's no manifest yet, we need one.
+
+=item *
+
+If there's a difference between what's already there and what's in the list,
+we need a new one.
+
+=back
+
+If a new manifest is needed, the return value is C<1>; otherwise it is
+undefined. The value passed in is the hash as returned from I<e.g.>,
+C<prepare_manifest()>.
+
+=cut
+
sub determine_need_for_manifest {
my $self = shift;
my $proposed_files_ref = shift;
@@ -84,6 +167,15 @@
$different_patterns_count ? return 1 : return;
}
+=head2 print_manifest
+
+ $mani->print_manifest($manifest_lines_ref) if $need_for_files;
+
+Writes the manifest to a file. The example above does so only if an update is
+needed.
+
+=cut
+
my $text_file_coda = <<'CODA';
# Local variables:
# mode: text
@@ -101,8 +193,8 @@
#
# generated by $self->{script} $self->{time} UT
#
-# See tools/dev/install_files.pl for documentation on the
-# format of this file.
+# See below for documentation on the format of this file.
+#
# See docs/submissions.pod on how to recreate this file after SVN
# has been told about new or deleted files.
END_HEADER
@@ -119,6 +211,9 @@
return 1;
}
+# Gets the package and the meta flags for the given file. This function does
+# it based on the directory the file is in. If a particular file is needed,
+# then _get_special (below) provides that functionality.
sub _get_manifest_entry {
my $file = shift;
@@ -156,6 +251,7 @@
return $loc;
}
+# See comments for _get_manifest_entry, above
sub _get_special {
my %special = qw(
LICENSE [main]doc
@@ -191,6 +287,7 @@
return \%special;
}
+# Gets files currently listed in manifest, and returns a hash
sub _get_current_files {
my $self = shift;
@@ -212,6 +309,15 @@
return \%current_files;
}
+=head2 prepare_manifest_skip
+
+ $print_str = $mani->prepare_manifest_skip();
+
+Gets a list of the files that SVN ignores, and returns a string that can be
+put into F<MANIFEST.SKIP>.
+
+=cut
+
sub prepare_manifest_skip {
my $self = shift;
@@ -220,6 +326,15 @@
return $self->_compose_manifest_skip($ignores_ref);
}
+=head2 prepare_gitignore
+
+ $print_str = $mani->prepare_gitignore();
+
+Gets a list of the files that SVN ignores, and then writes it to the
+F<.gitignore> file.
+
+=cut
+
sub prepare_gitignore {
my $self = shift;
@@ -228,6 +343,27 @@
return $self->_compose_gitignore($ignores_ref);
}
+=head2 determine_need_for_manifest_skip
+
+ $need_for_skip =
+ $mani->determine_need_for_manifest_skip($print_str);
+
+Determines whether F<MANIFEST.SKIP> is needed. The tests used are:
+
+=over 4
+
+=item *
+
+If the file doesn't exist, we need one.
+
+=item *
+
+If the proposed and existing contents differ, we need one.
+
+=back
+
+=cut
+
sub determine_need_for_manifest_skip {
my $self = shift;
my $print_str = shift;
@@ -250,6 +386,14 @@
}
}
+=head2 print_manifest_skip
+
+ $mani->print_manifest_skip($print_str) if $need_for_skip;
+
+Writes F<MANIFEST.SKIP> to a file. The example above does so only if needed.
+
+=cut
+
sub print_manifest_skip {
my $self = shift;
my $print_str = shift;
@@ -264,6 +408,14 @@
return 1;
}
+=head2 print_gitignore
+
+ $mani->print_gitignore($print_str) if $need_for_skip;
+
+Writes the F<.gitignore> file. The example above does so only if needed.
+
+=cut
+
sub print_gitignore {
my $self = shift;
my $print_str = shift;
@@ -278,6 +430,7 @@
return 1;
}
+# Gets a list of files that SVN ignores
sub _get_ignores {
my $self = shift;
@@ -305,6 +458,7 @@
return \%ignores;
}
+# Turns the list of ignored files into .gitignore format
sub _compose_gitignore {
my $self = shift;
my $ignores_ref = shift;
@@ -337,6 +491,7 @@
return $print_str;
}
+# Turns list of ignored files into F<MANIFEST.SKIP> format
sub _compose_manifest_skip {
my $self = shift;
my $ignore_ref = shift;
@@ -378,6 +533,7 @@
return $print_str;
}
+# Gets a list of the currently skipped files from F<MANIFEST.SKIP>
sub _get_current_skips {
my $self = shift;
@@ -395,6 +551,7 @@
return \%current_skips;
}
+# Gets list of files we're proposing to skip
sub _get_proposed_skips {
my $print_str = shift;
@@ -411,28 +568,61 @@
1;
-#################### DOCUMENTATION ####################
+=head1 MANIFEST FORMAT
-=head1 NAME
+The format of the F<MANIFEST> (currently F<MANIFEST> and F<MANIFEST.generated>
+are used) is:
-Parrot::Manifest - Re-create MANIFEST and MANIFEST.SKIP
+ source_path <whitespace> [package]meta1,meta2,...
-=head1 SYNOPSIS
+or you may optionally specify a different destination path:
- use Parrot::Manifest;
+ source_path <whitespace> [package]meta1,meta2,... <whitespace> destination
- $mani = Parrot::Manifest->new($0);
+Additionally, there may be a C<*> in front of the whole line to designate
+a generated file:
- $manifest_lines_ref = $mani->prepare_manifest();
- $need_for_files = $mani->determine_need_for_manifest($manifest_lines_ref);
- $mani->print_manifest($manifest_lines_ref) if $need_for_files;
+ source_path <whitespace> *[package]meta1,meta2,... <whitespace> destination
- $print_str = $mani->prepare_manifest_skip();
- $need_for_skip = $mani->determine_need_for_manifest_skip($print_str);
- $mani->print_manifest_skip($print_str) if $need_for_skip;
+The square brackets around C<package> are literal. C<package> gives
+the name of the RPM that the given file will be installed for, and is
+only used by this script to skip files that are not members of any
+package.
- $print_str = $mani->prepare_gitignore();
- $mani->print_gitignore($print_str) if $need_for_skip;
+The various meta flags recognized are:
+
+=over 4
+
+=item C<doc>
+
+Tag this file with C<%doc> in the RPM, and omit the leading path (because
+F<rpm> will put it into a directory of its choosing).
+
+=item C<include>
+
+Write this file to the location given by the C<--includedir> option.
+
+=item C<lib>
+
+Write this file to the location given by the C<--libdir> option.
+
+=item C<bin>
+
+Write this file to the location given by the C<--bindir> option.
+
+=back
+
+The optional C<destination> field provides a general way to change
+where a file will be written to. It will be applied before any
+metadata tags.
+
+Example: if this line is in the F<MANIFEST.generated> file
+
+ languages/snorkfest/snork-compile [main]bin
+
+and the C<--bindir=/usr/parroty/bin>, then the generated
+F<parrot-E<lt>VERSIONE<gt>-1.E<lt>archE<gt>.rpm> file will contain the file
+C</usr/parroty/bin/snork-compile>.
=head1 SEE ALSO
@@ -450,9 +640,3 @@
=cut
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
Modified: trunk/tools/dev/install_dev_files.pl
==============================================================================
--- trunk/tools/dev/install_dev_files.pl Thu May 28 20:45:21 2009 (r39227)
+++ trunk/tools/dev/install_dev_files.pl Thu May 28 23:00:35 2009 (r39228)
@@ -46,9 +46,9 @@
=back
-=head2 See Also
+=head1 SEE ALSO
-See F<tools/dev/install_files.pl> for a detailed description of the MANIFEST
+See F<lib/Parrot/Manifest.pm> for a detailed description of the MANIFEST
format.
=cut
Modified: trunk/tools/dev/install_files.pl
==============================================================================
--- trunk/tools/dev/install_files.pl Thu May 28 20:45:21 2009 (r39227)
+++ trunk/tools/dev/install_files.pl Thu May 28 23:00:35 2009 (r39228)
@@ -46,64 +46,11 @@
=back
-=head2 MANIFEST Format
-
-The format of the MANIFEST (currently MANIFEST and MANIFEST.generated
-are used) is:
-
- source_path <whitespace> [package]meta1,meta2,...
-
-or you may optionally specify a different destination path:
-
- source_path <whitespace> [package]meta1,meta2,... <whitespace> destination
-
-Additionally, there may be a * in front of the whole line to designate
-a generated file:
-
- source_path <whitespace> *[package]meta1,meta2,... <whitespace> destination
-
-The square brackets around C<package> are literal. C<package> gives
-the name of the RPM that the given file will be installed for, and is
-only used by this script to skip files that are not members of any
-package.
-
-The various meta flags recognized are:
-
-=over 4
-
-=item C<doc>
-
-Tag this file with %doc in the RPM, and omit the leading path (because
-rpm will put it into a directory of its choosing)
-
-=item C<include>
-
-Write this file to the location given by the C<--includedir> option
-
-=item C<lib>
-
-Write this file to the location given by the C<--libdir> option
-
-=item C<bin>
-
-Write this file to the location given by the C<--bindir> option
-
-=back
-
-The optional C<destination> field provides a general way to change
-where a file will be written to. It will be applied before any
-metadata tags.
-
-Example: if this line is in the MANIFEST.generated file
-
- languages/snorkfest/snork-compile [main]bin
-
-and the --bindir=/usr/parroty/bin, then the generated
-parrot-<VERSION>-1.<arch>.rpm file will contain the file
-/usr/parroty/bin/snork-compile.
-
=head1 SEE ALSO
+See F<lib/Parrot/Manifest.pm> for a detailed description of the MANIFEST
+format.
+
F<tools/dev/mk_manifests.pl>
=cut
More information about the parrot-commits
mailing list