version 1.11, 2005/04/07 00:10:06 |
version 1.17, 2005/05/20 01:18:24 |
|
|
use warnings; |
use warnings; |
use diagnostics; |
use diagnostics; |
|
|
use BT::MetaInfo; |
|
|
|
use lib 'lib'; |
use lib 'lib'; |
|
use BT::MetaInfo::Cached; |
use OpenBSDTorrents; |
use OpenBSDTorrents; |
|
|
%ENV = (); |
%ENV = (); |
|
|
{ |
{ |
my $basedir = shift; |
my $basedir = shift; |
|
|
|
#return undef if $basedir =~ /packages/; |
|
|
my ($dirs, $files) = Get_Files_and_Dirs($basedir); |
my ($dirs, $files) = Get_Files_and_Dirs($basedir); |
if (@$files) { |
if (@$files) { |
my $torrent = Make_Torrent($basedir, $files); |
my $torrent = Make_Torrent($basedir, $files); |
} |
} |
|
|
# don't recurse if we were called on a specific directory |
# don't recurse if we were started with a specific directory |
return 1 if $StartDir ne $OBT->{BASENAME}; |
return 1 if $StartDir ne $OBT->{BASENAME}; |
|
|
foreach my $subdir (@$dirs) { |
foreach my $subdir (@$dirs) { |
|
|
|
|
eval { btmake($torrent, $comment, $files); }; |
eval { btmake($torrent, $comment, $files); }; |
if ($@) { |
if ($@) { |
print "Error creating $torrent\n"; |
print "Error creating $torrent\n$@\n"; |
} |
} |
|
|
# system($BTMake, |
# system($BTMake, |
|
|
my $announce = $OBT->{URL_TRACKER}; |
my $announce = $OBT->{URL_TRACKER}; |
my $piece_len = 2 << ($OBT->{PIECE_LENGTH} - 1); |
my $piece_len = 2 << ($OBT->{PIECE_LENGTH} - 1); |
|
|
$torrent = $OBT->{DIR_TORRENT} . "/$torrent"; |
my $torrent_with_path = $OBT->{DIR_NEW_TORRENT} . "/$torrent"; |
|
|
my $t = BT::MetaInfo->new(); |
my $t = BT::MetaInfo::Cached->new( |
|
{ |
|
cache_root => |
|
$OBT->{DIR_HOME} . '/FileCache' |
|
} |
|
); |
|
|
$t->name($name); |
$t->name($name); |
$t->announce($announce); |
$t->announce($announce); |
unless ($announce =~ m!^http://[^/]+/!i) { |
unless ($announce =~ m!^http://[^/]+/!i) { |
|
|
# } |
# } |
#} |
#} |
$t->piece_length($piece_len); |
$t->piece_length($piece_len); |
$t->creation_date(time); |
$t->creation_date(gmtime); |
print "Checksumming files. This may take a little while...\n"; |
print "Checksumming files. This may take a little while...\n"; |
$t->set_files(@$files); |
$t->set_files(@$files); |
|
|
|
|
return 0; |
return 0; |
} |
} |
|
|
$t->save("$torrent"); |
my $hash = $t->info_hash; |
print "Created: $torrent\n"; |
$hash = unpack("H*", $hash); |
#system("btinfo $torrent") if ($::opt_I); |
|
|
$t->save($torrent_with_path); |
|
print "Created: $torrent_with_path\n"; |
} |
} |
|
|