[Galaxy S III General] Kangburra:
#!/usr/bin/perl

use strict;

my $owner = "Simon"; #Your name, your ROM's name up to you

my $romname = "JB Rom"; # The identifier, JB, KLP etc.

my $filelist = "bloat.list"; # This is the file with the apks to remove

my @dirs = qw(tts voicebargeindata); # Directories we do not want, use with care.

my $lsline = "app bin build.prop cameradata csc CSCVersion.txt etc fonts framework hdic lib media SW_Configuration.xml usr vendor voicebargeindata vsc wakeupdata xbin"; # This is a listing to compare to the one retrieved from the ROM

my @outbuild = undef;
my $outline = undef;
my $answer = 0;
my @zips = `ls original_update/*.zip`;

if (@zips) {
foreach my $zip (@zips) {
chomp ($zip);
system "unzip $zip";
unlink $zip;
}
}
my @md5s = `ls | grep md5`;

if (@md5s) {
foreach my $md5 (@md5s) {
chomp ($md5);
my $tar = $md5;
$tar =~ s/\.md5//g;
system "mv $md5 original_update/$tar";
}
}
$answer = 0;
question("\nSet up a new ROM? ");
if ($answer == 1) {
system "bash ./scripts/check_rom";
}

$answer = 0;
question("\nCreate a new Bloat file? ");
if ($answer == 1) {
system "perl ~/bin/bloat.list.gen.editor.pl";
}

my $path = `ls | grep WORKING`;
chomp($path);
my $buildfile = "$path/system/build.prop";
my $outfile = undef;
unless ($path) {
print "Working folder not found, exiting";
&dots;
print "\n\n";
exit;
}

print "\n\n\nThis should be run from the system folder of the ROM\n\n";
print "You should see a listing like this :\n";
print "$lsline\n";
print "\nHere:\n";

system "ls $path/system";

if (-e "$filelist") {
open(BLOAT, "<$filelist"); # open for input
chomp (my @bloat = <BLOAT>); # read file into list
close(BLOAT);

$answer = 0;
question("Remove Bloat list?");
if ($answer == 1) {
print "Removing : ";
foreach my $line (@bloat) {

if (-e "$path/system/app/$line" && $line !~ "keep") {
system "rm -f $path/system/app/$line";
print "$line ";
}
system "cp $filelist $path/system/";
}
print "\n";
}

}
else {

print "Bloat file missing!\n";
&dots;
}

$answer = 0;
question("Update media directory?");
if ($answer == 1) {
system "rm -rfv $path/system/media";
system "cp -rfv RomTweaks/media $path/system/media";
}

$answer = 0;
question("Remove bloat directories?");
if ($answer == 1) {

foreach my $dir (@dirs) {
if (-e "$path/system/$dir") {
system "rm -rfv $path/system/$dir";
}
}

}

$answer = 0;
question("Replace Accuweather widgets?");
if ($answer == 1) {

print "Copying Accuweather files \n";
system "cp -fv RomTweaks/aw/* $path/system/app/";
}

system "bash ./scripts/do_deodex";

$answer = 0;
question("Install dictionary?");
if ($answer == 1) {
unless (-d "$path/system/T9DB") {
print "Copying Keyboard dictionary\n";
system "cp -rfv RomTweaks/T9DB $path/system/";

}
}

$answer = 0;
question("Install Sound Patch?");
if ($answer == 1) {
print " Copying sound patch file\n";
system "cp -fv RomTweaks/default_gain.conf $path/system/etc/";
}

$answer = 0;
question("Install Extended Power Menu?");
if ($answer == 1) {
print "Copying power button menu file\n";
system "cp -fv RomTweaks/android.policy.jar $path/system/framework/";
}

$answer = 0;
question("Install su binary & Superuser?");
if ($answer == 1) {
print "Copying su binary\n";
system "cp -fv RomTweaks/su $path/system/xbin/";
print "Copying Superuser package \n";
system "cp -fv RomTweaks/Superuser.apk $path/system/app/";
}

$answer = 0;
question("Install busybox?");
if ($answer == 1) {
print "Copying busybox binary\n";
system "cp -fv RomTweaks/busybox $path/system/xbin/";
}

$answer = 0;
question("Install ES Filemanager?");
if ($answer == 1) {
system "cp -fv RomTweaks/esfm.apk $path/system/app/";
}

$answer = 0;
question("Install XSA CSC?");
if ($answer == 1) {
print "Copying CSC files \n";
system "cp -fv RomTweaks/SW_Configuration.xml $path/system/";
system "rm -rf $path/system/csc";
system "cp -frv RomTweaks/csc $path/system/";
}

$answer = 0;
question("Install modified SystemUI package?");
if ($answer == 1) {
print "Updating SystemUI package\n";
system "cp -fv RomTweaks/SystemUI.apk $path/system/app/";
#system "cp -fv RomTweaks/QuickPanelSettings.apk $path/system/app/";
#system "cp -fv RomTweaks/lidroid-res.apk $path/system/framework/";
}

$answer = 0;
question("Install modified Settings package (kills blocking icon)?");
if ($answer == 1) {
print "Updating SystemUI package\n";
system "cp -fv RomTweaks/SecSettings.apk $path/system/app/"
}

$answer = 0;
question("Replace the META-INF files?");
if ($answer == 1) {
print "Copying updater-script \n";
system "cp -rfv RomTweaks/META-INF WORKING_*/";
if (-e "$path/META-INF/com/google/android/update-script") {
system "rm $path/META-INF/com/google/android/update-script";
}
}

if (-e "$path/modem.bin") {
$answer = 0;
question("Install modem?");
if ($answer == 1) {
print "Setting up modem\n";
system "cp -fv RomTweaks/flash_image $path/";
system "cp -fv RomTweaks/modem-updater-script $path/META-INF/com/google/android/updater-script";
}
}

$answer = 0;
question("Replace the boot.img?");
if ($answer == 1) {
print "Copying boot image \n";
system "cp -rfv RomTweaks/boot.img WORKING_*/";
}

print "Bloat removed\n\n";
system "cat RomTweaks/build.prop >> $path/system/build.prop";
#print "Now edit the build.prop file";
#&dots;
#system "gedit -w $path/system/build.prop";
&doprop;
#print "Sending you back to the kitchen to build the ROM";
#&dots;
if (-e "nul") { unlink "nul"; }
system "bash ./scripts/build_rom";
&movezip;
exit;

sub dots {

for (my $a=0; $a<3; $a++) {
system "ping -c 2 127.0.0.1 > nul";
print ".";
}
}

sub question {
my $ask = @_[0];
print "\n\n$ask\n";
chomp(my $response = <STDIN>);
my $result = uc($response);
if ($result eq "Y") {$answer = 1;}
print "\n\n";
return $answer;
}

sub doprop {
my $countfile = "romcount";
my $romcount;

if (-e "$countfile") {
open(COUNT, "<$countfile"); # open for input
chomp (my @count = <COUNT>); # read file into list
$romcount = $count[0] + 1 ;
close(COUNT);
open(COUNT, ">$countfile"); # open for input
print COUNT "$romcount" ;
close(COUNT);

}

my $version = "v" . "$romcount";

open(BUILD, "<$buildfile"); # open for input
chomp (my @build = <BUILD>); # read file into list
close(BUILD);

my $ver = undef;
foreach my $check (@build) {
if ($check =~ "ro.build.version.incremental") { $ver = substr($check, -4) ; }
}
while(@build) {
my $line = shift(@build);
if ($line =~ "ro.config.ringtone") { $outline = "ro.config.ringtone=Silent.ogg" ; }
elsif ($line =~ "ro.config.notification_sound") { $outline = "ro.config.notification_sound=Silent.ogg" ; }
elsif ($line =~ "ro.config.alarm_alert") { $outline = "ro.config.alarm_alert=Ticktac.ogg" ; }
elsif ($line =~ "ro.config.media_sound") { $outline = "ro.config.media_sound=Silent.ogg" ; }
elsif ($line =~ "ro.build.display.id") { $outline = "ro.build.display.id=$owner" ."\'s $romname $version based on $ver" ;}
else { $outline = $line ; }
push (@outbuild, $outline);
}
open(BUILD, ">$buildfile"); # open for writing
foreach my $line (@outbuild) {
print BUILD "$line\n";
}
close(BUILD);
}

sub movezip {

my $zipfile = `ls OUTPUT_ZIP/m0*` ;
chomp($zipfile);
unless (-e "$zipfile") {print "\n\n\nExiting zip file not found\n\n\n" ; &dots; exit; }
my $outfile;
if (-e "$buildfile") {
open(BUILD, "<$buildfile"); # open for input
chomp (my @build = <BUILD>); # read file into list
close(BUILD);

foreach my $line (@build) {
if ($line =~ "$owner") {
$outfile = $line;
}

}
my @parts = split(/=/, $outfile);
my $filename = "$parts[1].zip";
$filename =~ s/\ /_/g;
$filename =~ s/'//g;
system "mv -f $zipfile OUTPUT_ZIP/$filename";
system "cp -p OUTPUT_ZIP/$filename /media/sf_Simon/$filename";
}
}

The reference to RomTweaks is a directory in the kitchen which has the su binary and SuperUser.apk etc. Just ignore those or remove them from the script. It will generate a file called bloat.list which is the basis for the apk removal, it also packs that file into the Rom in case you want to go back to it.

Finally the last line is a copy from Virtualbox into Windows because I never got MTP working in virtual Linux.

It unpacks any zip files and copies the tar back into the original_update dir.

At the end of the build, choose option 2 as the Rom is renamed anyway.

You need a text file called romcount in the kitchen directory which keeps track of the number of builds and add it into the build.prop so it shows in the status screen.

You could also use the bloat.list.gen.editor script which is called from the one above.

#!/usr/bin/perl
use strict;
my $bloatfile = "bloat.list";
my $path = `ls | grep WORKING`;
chomp($path);
$path .= "/system/app";

my @newbloat = undef;
my $answer = 0;
my $last = undef;
my $same = undef;

unless ( -e "$path") {print "Unable to find \"$path\"" ; exit ; }

my @bloat = `ls $path`;
chomp (@bloat);
@bloat = sort(@bloat);
foreach my $line (@bloat) {

$same = 0;

if ($line eq "$last") {
$same = 1;
}
else {
$answer = 0;
}

$last = $line;
$last =~ s/apk/odex/g;

if ($same == 0) {
question("\nMark \"$line\" for removal?");
}

if ($answer == 0) {
$line .= " keep";
}
push (@newbloat, $line);
}

open(BLOAT, ">$bloatfile"); # open for input
foreach my $line (@newbloat) {
if ($line =~ /[a-z]/) {
print BLOAT "$line\n" ; }
}
close(BLOAT);

sub question {
my $ask = @_[0];
system "clear";
print "\n\n$ask\n";
chomp(my $response = <STDIN>);
my $result = uc($response);
if ($result eq "Y") {$answer = 1;}
print "\n\n";
return $answer;
}