-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the create_backpan_index.pl program.
This is what is used on the Gitpan server, plus some other fixups.
- Loading branch information
Showing
1 changed file
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |