Skip to content

Commit

Permalink
Update the create_backpan_index.pl program.
Browse files Browse the repository at this point in the history
This is what is used on the Gitpan server, plus some other fixups.
  • Loading branch information
schwern committed Aug 15, 2014
1 parent 5f71d5c commit bf5d5e7
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions create_backpan_index.pl
Original file line number Diff line number Diff line change
@@ -1,17 +1,49 @@
#!/usr/bin/perl

use strict;
use warnings;
use v5.12;
use autodie;
use File::Find::Rule;
use IO::Zlib;
use Path::Tiny;

my $backpan = path(shift)->absolute;
my $outfile = path(shift)->absolute;

my $out = IO::Zlib->new("/vhosts/www.astray.com/site/manatee/root/tmp/backpan.txt.gz", "wb9") || die $!;
# Build in a temp file to avoid serving a half built index while building
my $tmpfile = Path::Tiny->tempfile;
my $out = IO::Zlib->new($tmpfile.'', "wb9") || die $!;

chdir "BACKPAN";
chdir $backpan;
foreach my $filename (sort File::Find::Rule->new->file->in(".")) {
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);
print $out "$filename $mtime $size\n";
my $stat = path($filename)->stat;
say $out join " ", $filename, $stat->mtime, $stat->size;
}
chdir "..";
$out->close;

# Put it in place.
$tmpfile->move($outfile);

# Make extra sure the web server can read it.
$outfile->chmod(0644);


=head1 NAME
create_backpan_index.pl - Create the BackPAN index file
=head1 SYNOPSIS
create_backpan_index.pl path/to/backpan path/to/index.gz
=head1 DESCRIPTION
Creates the index used by BackPAN::Index. Intended to be used on a
BackPAN server.
Each line is space delimited information about a file.
filepath mtime size
=cut

0 comments on commit bf5d5e7

Please sign in to comment.