mozilla_tools

mozilla_tools is a set of programs designed to make typical Mozilla development tasks easier.  Things like patch management, surgically rebuild, and manipulate cvs.  Every program in the .tgz supports the --help parameter and will give you help if you do not use it correctly.  The are all designed to work out of the box: if you have sufficient tools to build Mozilla now, you can run mozilla_tools.

4/30/2003 - 1.1 - made installation easier, updated BuildDirs.pm to track changes in the build system, got roaming scripts working better
2/1/2003 - 1.0 - all the tools I need, I don't know about you

Installation

1. Download http://www.johnkeiser.com/mozilla/mozilla_tools.tgz.
2. Untar to a location of your choice.
3. Ensure that location is in your PATH and PERLLIB.

Documentation

Here are docs on the most useful programs:

builddirs.pl - Surgically Rebuild Mozilla

builddirs.pl <directories or files> - takes the list of files or directories specified and does "make" in those directories, as well as determining where it needs to "make" in order to link those directories so that Mozilla is immediately runnable after you make your change.

fixes.pl - Manage, Import, and Commit Patches In Your Tree

fixes.pl <action> <fixname> - fixes.pl is a suite of tools to help you keep track of what patches you have in your tree and perform operations on them such as committing, temporarily (or permanently) removing them from the tree, rebuilding them. It allows you to import patches from the web or Bugzilla, as well, if you have the wget program (comes with cygwin and most Linux installs).  I typically name fixes the same as the bug # so that I can reference them later.  The script remembers what is in the tree by storing patches in a special directory under mozilla/ called "fixes/".

These utilities are designed to be safe.  They ensure several things to make sure nothing goes wrong: (a) atomicity: if a patch does not apply, no part of the patch will be applied; (b) no conflicts: the utility will never allow two patches to affect the same file, and will furthermore check cvs and not apply if you have personally modified the file.  This makes it safe to apply someone else's patch pretty much blindly (with a lot fewer worries).  With this utility I have been able to easily keep track of 11 or 12 patches at the same time.

Additionally, like all other utilities here, this utility is able to automatically perform cvs adds and cvs removes so you never miss anything in your cvs diffs or commits.

"fixname," which you will see throughout this, is a name you give to identify a patch so you can do things with it.

Certain common development routines become pretty simple with fixes.pl:

Try out a patch

1. fixes.pl import somefix http://bugzilla.mozilla.org/attachment.cgi?id=xxxx
2. fixes.pl build somefix
3. dist/bin/mozilla
4. fixes.pl remove somefix
5. fixes.pl build somefix
You are now back to the state you were at at the beginning.

Develop your own patch

1. Modify the files
2. fixes.pl define myfix <files>
3. fixes.pl build myfix
4. Modify files more
5. fixes.pl update myfix
6. Upload mozilla/fixes/myfix.patch to Bugzilla
7. fixes.pl commit --message="Commit message" myfix

Quickly move a fix out of the way so you can do something else

1. fixes.pl update myfix
2. fixes.pl remove myfix
3. Do your thing
4. fixes.pl resurrect myfix (when you are done)

Here is a list of the more useful commands. 

Category
Command
Description
Defining and Naming Fixes
fixes.pl import fixname <patchfile|url>
Import a fix from a patchfile, either locally or from a remote server (this is how I try out Bugzilla attachments--just supply the attachment URL).  This will apply the patch and remember that it is applied.  It also figures out where in the tree the patch was made so it can just apply it without bothering you.

fixes.pl define fixname <directories or files>
Define a fix based on files already in your tree.   Files that are not changed will not be included in the fix, so that you can specify directories and it will automatically include just your changes.

fixes.pl forget fixname
Forget that the fix existed but don't touch the tree

fixes.pl rename fixname newfixname
Rename a fix
Viewing Fixes
fixes.pl list
List the fixes in the tree

fixes.pl list_saved
List saved fixes (patches that were removed with fixes.pl remove)

fixes.pl showfiles [fixname]
List all the files in the tree that are affected by a fix (leave off the fix to show all files affected by all fixes)

fixes.pl whichfix [files]
Show which fix a particular file is in

fixes.pl findnew [directories | files]
Find other files in your tree that you have modified but are not in any defined fix

fixes.pl showdiff fixname
Show the stored patch for a fix

fixes.pl diff fixname
Show the difference between the patch and what you have in your tree.  Really useful when you make changes to a patch and want to know what you did so you can make bug comments.
Manipulating Fixes
fixes.pl update fixname [new files]
Update the patch for a fix, adding any new files specified in [new files]

fixes.pl build fixname Surgically rebuild all the files in a fix with builddirs.pl so that you can run Mozilla with the fix.

fixes.pl commit --message="..." fixname Commit the fix to the Mozilla tree.  This checks to ensure that the fix is up to date and ensures that all necessary files have been cvs added and cvs removed; and even cooler, it checks the tree for you before checking in.  Use --ignoretree if the tree is red or closed and you have permission to check in.

fixes.pl remove fixname
Remove a fix from your tree but save the patch

fixes.pl resurrect fixname
Bring back a fix you removed earlier

cleantree.pl - Revert Files To CVS

cleantree.pl <directories or files> - removes changes you have made to a set of directories or files.  This utility is especially useful because it does not do a "cvs update" and therefore potentially make your tree out of synch.

Roaming Scripts

roaming_upload.pl [--dir=... | --ssh_loc=... --ssh_dir=...] profilename
Uploads pertinent parts of your profile to a remote server (or directory).  Currently only does bookmarks.
roaming_update.pl [--dir=... | --ssh_loc=... --ssh_dir=...] profilename
Brings down pertinent parts of your profile to a remote server (or directory).  Currently only does bookmarks.

Other Programs

upgrade_tools.pl
This will go back to the server, grab the .tgz and install it in the location where the upgrade_tools.pl script resides.
dos2unix.pl <files>
Convert \r\n to \n in a set of files.
uuid.pl
Generate a UUID and print it in two forms (one for .idls and one for .h).
applypatch.pl <patch>
Fixes up a patch to fit the mozilla/ root and atomically applies it to the tree (if the apply fails, no part of the patch is applied).  You must be in the mozilla/ dir for this to work.
commitpatch.pl --message="..." <patch>
Performs same function as "fixes.pl commit"
lxrfile.pl <file>, lxrtext.pl <text>
Search lxr for a file or text, output in convenient text format
modifiedfiles.pl <dir>
Show what files were modified in a directory
rediff.pl <patch>
Remake a patch with the same files (and any new ones) against the current tree
diffpatch.pl <patch1> <patch2>
diff two patches to see what changed between them (this is sophisticated cvs stuff)
switchroot.pl [-a|-w]
switch cvs root to anonymous or writable (this switches the root in all directories at and under the current directory).

Copyleft 2003 John Keiser (jkeiser@netscape.com)