| version 1.1, 2005/03/22 01:14:11 |
version 1.3, 2005/03/22 23:07:23 |
|
|
| #!/usr/bin/perl -T |
#!/usr/bin/perl -T |
| |
#$Id$ |
| use strict; |
use strict; |
| use warnings; |
use warnings; |
| use diagnostics; |
use diagnostics; |
|
|
| |
|
| my $BaseDir = '/home/ftp/pub'; |
my $BaseDir = '/home/ftp/pub'; |
| my $BaseName = 'OpenBSD'; |
my $BaseName = 'OpenBSD'; |
| my $OutDir = '/home/andrew'; |
my $OutDir = '/home/andrew/torrents'; |
| my $BTMake = '/usr/local/bin/btmake'; |
my $BTMake = '/usr/local/bin/btmake'; |
| my $Tracker = 'http://OpenBSD.somedomain.net/announce.php'; |
my $Tracker = 'http://OpenBSD.somedomain.net/announce.php'; |
| |
|
| |
my $MinFiles = 5; |
| |
|
| # These are regexes that tell what files to skip; |
# These are regexes that tell what files to skip; |
| my $SkipDirs; |
my $SkipDirs = qr/\/patches$/; |
| my $SkipFiles = qr/^\./; |
my $SkipFiles = qr/^\./; |
| |
|
| |
|
| my $StartDir = shift || $BaseName; |
my $StartDir = shift || $BaseName; |
| $StartDir =~ s#/$##; |
$StartDir =~ s#/$##; |
| |
|
|
|
| if (@$files) { |
if (@$files) { |
| Make_Torrent($basedir, $files); |
Make_Torrent($basedir, $files); |
| } |
} |
| |
|
| |
# don't recurse if we were called on a specific directory |
| |
return 1 if $StartDir ne $BaseName; |
| |
|
| foreach my $subdir (@$dirs) { |
foreach my $subdir (@$dirs) { |
| #next if $subdir eq '.'; |
#next if $subdir eq '.'; |
| #next if $subdir eq '..'; |
#next if $subdir eq '..'; |
|
|
| my $basedir = shift; |
my $basedir = shift; |
| my $files = shift; |
my $files = shift; |
| |
|
| if ($basedir =~ /^([\w\/\.-]+)$/) { |
if ($#files < $MinFiles) { |
| |
print "Too few files in $basedir, skipping . . .\n"; |
| |
return undef; |
| |
} |
| |
|
| |
if ($basedir !~ /\.\./ && $basedir =~ /^([\w\/\.-]+)$/) { |
| $basedir = $1; |
$basedir = $1; |
| } else { |
} else { |
| die "Invalid characters in dir '$basedir'"; |
die "Invalid characters in dir '$basedir'"; |
| } |
} |
| |
|
| foreach (@$files) { |
foreach (@$files) { |
| if (/^([\w\.-]+)$/) { |
if (/^([^\/]+)$/) { |
| $_ = "$basedir/$1"; |
$_ = "$basedir/$1"; |
| } else { |
} else { |
| die "Invalid characters in file '$_' in '$basedir'"; |
die "Invalid characters in file '$_' in '$basedir'"; |
| } |
} |
| } |
} |
| |
|
| |
my $date = Torrent_Date(); |
| |
|
| my $torrent = $basedir; |
my $torrent = $basedir; |
| $torrent =~ s/\W/_/g; |
$torrent =~ s/\W/_/g; |
| $torrent .= '-' . Torrent_Date(); |
$torrent .= '-' . $date; |
| $torrent .= '.torrent'; |
$torrent .= '.torrent'; |
| |
|
| print Dump $torrent, $basedir, $files; |
#print Dump $torrent, $basedir, $files; |
| print "Creating $torrent\n"; |
print "Creating $torrent\n"; |
| |
|
| |
my $comment = "Files from $basedir\n" . |
| |
"Created by andrew fresh (andrew\@mad-techies.org)\n" . |
| |
"http://OpenBSD.somedomain.net/", |
| |
|
| system($BTMake, |
system($BTMake, |
| |
'-C', |
| |
'-c', $comment, |
| '-n', $BaseName, |
'-n', $BaseName, |
| '-o', "$OutDir/$torrent", |
'-o', "$OutDir/$torrent", |
| '-a', $Tracker, |
'-a', $Tracker, |
| @$files |
@$files |
| );# || die "Couldn't system $BTMake $torrent: $!"; |
);# || die "Couldn't system $BTMake $torrent: $!"; |
| } |
} |
| |
|
| |
|
| sub Get_Files_and_Dirs |
sub Get_Files_and_Dirs |
| { |
{ |