From: <ar...@sy...> - 2007-07-31 10:57:18
|
Author: arighi Date: 2007-07-31 05:56:47 -0500 (Tue, 31 Jul 2007) New Revision: 4087 Modified: trunk/sbin/si_installbtimage Log: - added compatibilty with old versions of the BitTorrent client This is needed to support the BitTorrent client available in Ubuntu (7.04), without installing/upgrading packages not supported by the distribution. Modified: trunk/sbin/si_installbtimage =================================================================== --- trunk/sbin/si_installbtimage 2007-07-18 13:50:04 UTC (rev 4086) +++ trunk/sbin/si_installbtimage 2007-07-31 10:56:47 UTC (rev 4087) @@ -7,6 +7,7 @@ use lib "USR_PREFIX/lib/systemimager/perl"; use strict; use POSIX; +use File::Basename; use Getopt::Long; use SystemImager::Config; use vars qw($config $VERSION); @@ -121,7 +122,7 @@ } # Find available BitTorrent binaries. -chomp(my $maketorrent = `(which maketorrent-console || which btmaketorrent) 2>/dev/null`); +chomp(my $maketorrent = `(which maketorrent-console || which btmaketorrent || which btmakemetafile) 2>/dev/null`); unless ($maketorrent) { print "ERROR: cannot find a valid binary to make torrents.\n"; exit(1); @@ -176,17 +177,23 @@ '/standard/boel_binaries.tar.gz', $boel_binaries) if (! -e $boel_binaries); # Make .torrent file. -system "$maketorrent --target $TORRENT_DIR/boel_binaries.tar.gz.torrent http://$image_server:$tracker_port/announce $boel_binaries"; +if ($maketorrent =~ "btmakemetafile") { + system "$maketorrent $boel_binaries http://$image_server:$tracker_port/announce --target $TORRENT_DIR/boel_binaries.tar.gz.torrent"; +} else { + system "$maketorrent http://$image_server:$tracker_port/announce $boel_binaries --target $TORRENT_DIR/boel_binaries.tar.gz.torrent"; +} if ($?) { die "ERROR: cannot create BOEL binaries torrent file!\n"; } +# symlink is required by old versions of BitTorrent. +symlink($boel_binaries, $TORRENT_DIR . "/" . basename($boel_binaries)); print "done.\n"; # Starting first image seeder. print "Starting first image server seeder...\n"; if ($quiet) { $PIDFILE = '/var/run/systemimager-server-btseeder.pid'; - open(PID, "$launchmany --max_upload_rate 0 --rerequest_interval 1 $twisted $trackerless $upnp --bind $image_server --save_in $TARBALL_DIR $TORRENT_DIR 0</dev/null 1>/dev/null 2>&1 & echo \$!|"); + open(PID, "$launchmany $TORRENT_DIR --max_upload_rate 0 --rerequest_interval 1 $twisted $trackerless $upnp --bind $image_server 0</dev/null 1>/dev/null 2>&1 & echo \$!|"); my $pid = <PID>; close(PID); open(OUT, ">$PIDFILE") or die("ERROR: cannot open $PIDFILE for writing!\n"); @@ -212,7 +219,7 @@ EOF `; my $bt_ui = ($?) ? $launchmany : $launchmany_curses; - system "$bt_ui --max_upload_rate 0 --rerequest_interval 1 $twisted $trackerless $upnp --bind $image_server --save_in $TARBALL_DIR $TORRENT_DIR"; + system "$bt_ui $TORRENT_DIR --max_upload_rate 0 --rerequest_interval 1 $twisted $trackerless $upnp --bind $image_server"; } print "done.\n"; @@ -293,10 +300,16 @@ $torrent_file = "$TORRENT_DIR/$type-$name.tar.torrent" } unless (-f "$torrent_file") { - system "$maketorrent --target $torrent_file http://$image_server:$tracker_port/announce $tarball_file"; + if ($maketorrent =~ "btmakemetafile") { + system "$maketorrent $tarball_file http://$image_server:$tracker_port/announce --target $torrent_file"; + } else { + system "$maketorrent http://$image_server:$tracker_port/announce $tarball_file --target $torrent_file"; + } if ($?) { die "ERROR: cannot create $type torrent file!\n"; } + # symlink is required by old versions of BitTorrent. + symlink($tarball_file, $TORRENT_DIR . "/" . basename($tarball_file)); } print "done.\n"; } |