# updateJEdit.pl - a script to update jEdit and plugins from source control and build them $JEDIT_DIR_NAME = "jedit"; $JEDIT_INSTALL_DIR = "/usr/share/jedit"; $COPY_JEDIT_COMMAND = "sudo cp"; opendir(DIR, ".") or die "Can't read current directory\n"; @entries = readdir(DIR); closedir(DIR); @entries = grep !/^\.\.?$/, @entries; @entries = grep -d, @entries; for (@entries) { update($_); processProps($_); } buildJEdit(); buildPlugins(@entries); print "Done\n"; sub buildJEdit { if (chdir($JEDIT_DIR_NAME)) { print "*** Building $JEDIT_DIR_NAME ... "; my @output = `ant`; chomp @output; @output = grep /^BUILD/, @output; system("$COPY_JEDIT_COMMAND build/jedit.jar $JEDIT_INSTALL_DIR"); chdir(".."); print "@output\n"; $built{$entry} = 1; } else { print "********* ERROR: Could not chdir $entry\n"; } } sub buildPlugins { my (@entries) = @_; foreach (@entries) { buildSingle($_) if ($_ !~ /^$JEDIT_DIR_NAME$/); } } sub buildSingle { my $entry = shift @_; return if ($built{$entry} || ($entry =~ /^$JEDIT_DIR_NAME$/)); $building{$entry} = 1; my @deps = @{$depends{$entry}}; foreach (@deps) { my $name = $classes{$_}; if ($name) { next if ($building{$name}); buildSingle($name); } } if (chdir($entry)) { print "*** Building $entry ... "; my @output = `ant`; chomp @output; @output = grep /^BUILD/, @output; chdir(".."); print "@output\n"; $built{$entry} = 1; } else { print "********* ERROR: Could not chdir $entry\n"; } } sub processSingleProps { my ($entry, $props) = @_; open(PROPS, $props) or die "Can't read $props\n"; @lines = ; chomp @lines; close(PROPS); for (@lines) { if (/^plugin\.([^=]+)\.name=(\w+)/) { $classes{$1} = $entry; } elsif (/^plugin\.([^=]+)\.depend\.\d+=.*plugin\s+(\S+)\s+/) { $depends{$entry} = [] if (! $depends{$entry}); push @{$depends{$entry}}, $2; } } } sub processProps { my $entry = shift @_; my @props = `find $entry -name '*.props'`; return if (! @props); chomp @props; foreach (@props) { processSingleProps($entry, $_); } } sub update { my $entry = shift @_; my $cmd = ""; if (-d "$entry/.git") { $cmd = "git pull"; } elsif (-d "$entry/.svn") { $cmd = "svn update"; } if ($cmd) { if (chdir($entry)) { print "Updating $entry ... "; system($cmd); chdir(".."); } else { print "Could not chdir into $entry, skipping.\n"; } } }