+
+ &sync_tarballs();
+}
+
+sub sync_tarballs {
+ my $localpath;
+ my $localdirectory;
+ my $localfilename;
+ my $actualpath;
+ my $actualfilename;
+ my $remotepath;
+ my $path;
+ my @tarballs;
+ my %localtarballs;
+ my ($repo_base, $checked_out_tree) = getrepo();
+
+ message "== Syncing tarballs";
+
+ open IN, "< tarballs" or die "Can't open packages file";
+ @tarballs = <IN>;
+ close IN;
+
+ foreach (@tarballs) {
+ chomp;
+ if (m@^([^# ]+)/([^#/ ]+) +([^ ]+)$@) {
+ $localdirectory = $1;
+ $localfilename = $2;
+ $remotepath = $3;
+ $localpath = "$localdirectory/$localfilename";
+
+ $localtarballs{$localdirectory}{$localfilename} = 1;
+
+ if (! -e $localpath) {
+ if ($checked_out_tree) {
+ $path = "$repo_base/$localpath";
+ }
+ else {
+ $path = "$repo_base/$remotepath";
+ }
+ &download($path, $localpath);
+ }
+ }
+ elsif (! /^(#.*)?$/) {
+ die "Bad line: $_";
+ }
+ }
+
+ foreach $localdirectory (keys %localtarballs) {
+ FILE: foreach $actualpath (glob "$localdirectory/*.tar.gz $localdirectory/*.tar.bz2") {
+ $actualfilename = $actualpath;
+ $actualfilename =~ s#.*/##;
+ if (! defined($localtarballs{$localdirectory}{$actualfilename})) {
+ message "== Deleting $actualpath";
+ unlink $actualpath;
+ }
+ }
+ }