Friday, June 22, 2007

Writing Spells

If you are interested in becoming a Source Mage developer you should learn how to write spells. If not an apprentice, you may want to learn how to write your own spells because you couldn't find a program you need in Source Mage. Here are a couple of ways to get started.

There is a wiki page on sourcemage.org called Spell Writing For Dummies. This is a good way to start to learn the intricacies of spell writing. The good part is you can do this on your local machine without affecting anyone else. So you can make all the mistakes you want while you learn.

Another way to start writing spells is to use a tool that has been created just for that purpose. The tool is called Quill. It has been created and updated by the Source Mage developers to make it easier to write spells. If you want to know when and what things have been added to Quill, here is the location of the changelog. To obtain a better explanation of Quill and all of it's features, I did a "gaze what quill" in my shell. Here is the result.

quill:
An interactive spell generator and updater script. It's meant to eventually become the be-all for spell manipulation. It has support for moving the working copy of the spell around, so any lacking features can easily be circumvented manually (the old way).

Current set of features:
* spell creation with different levels of complexity (see quill -h)
* full fledged update mode that checks new urls and downloads the sources
* freshmeat metadata fetching for quicker work
* perl cpan metadata fetching for quicker work
* ruby-raa metadata fetching for quicker work
* copying the spell from and back to the grimoire
* copying the spell from and back to a local git grimoire (any scm actually)
* casting of the spell
* creating a tarball out of it for easy submission
* SOURCE and SOURCE_URL unexpansion, so later updates will be easy
* substitution of source urls with known mirror and spell variables
* dumping of default_build and similar functions for custom spell files
* sudo support for the copying cases where root privileges are required

Update mode highlights:
* url checking that also tries substituting the suffixes on failure (bz2<->gz)
* some multiversion support
* automatic HISTORY updates
* simple and automatically style-conformant adding of arbitrary HISTORY entries
* automatic removal of deprecated variables like UPDATED and MD5
* automatic removal of old signature files and PATCHLEVEL
* hash and gpg verification support on spell udpates
* patchlevel handling

If you want to use Quill, just cast it like you would any other program and your ready to go. Hopefully this will at least point you in the right direction to begin writing your own spells for Source Mage. As always, you can get answers to any questions you might have in the #SourceMage IRC channel on Freenode or on the SM-Discuss mailing list. Now go forth young mage and conjure spells!

2 comments:

Anonymous said...

A better explanation of what spell files do and what is available can be found here.

Paul J. Beel said...

Excellent! Thank you for the link!