Crafting Spells Quickly

Copyright 2008 by Kyle Sallee


Writing Spells is Easy but Copying is Faster

  1. Make a local grimoire directory.

  2. Copy a spell to edit

  3. In this example the old spell for dialog
    becomes the new spell for cdk.
    Edit the new spell.

  4. Change this:

        stable 1.1-20080316 1.1-20071028 1.1-20070930 1.1-20070704 1.1-20070604
       require ncurses
      category utility
     attribute console solo
        source ftp://invisible-island.net/dialog/dialog-$VERSION.tgz
      homepage http://invisible-island.net/dialog/
          opts --bindir=/bin
      estimate 200
          desc 'dialog allows shell scripts to provide fancy text dialog with users.'
    

  5. Into this:

        stable 5.0-20060507
       require ncurses
      category development
     attribute console library
        source ftp://invisible-island.net/cdk/cdk-$VERSION.tgz
      homepage http://invisible-island.net/cdk/
      estimate 1200
          desc 'cdk is a library of curses widgets similar to dialog.'
    
    build(){
    default_build &&
    make cdkshlib &&
    make installCDKSHLibrary
    }
    

  6. Save the modified spell.
    Then, merge grimoires.
    Finally, cast it.

  7. For many sources, sorcery can detect and apply
    the proper method to compile and install.
    Consequently, the dialog spell does not require a build function.
    However, the cdk spell requires additional steps beyond what is typical.
    Therefore, the cdk spell does have a build() function.

    Common build methods are stored in /usr/libexec/sorcery/cast.d/
    Changes made to files in /usr/libexec/sorcery/cast.d/ are lost when sorcery updates.
    Therefore place custom build functions directly into spells.
    Alternatively, new build methods can be installed in
    /usr/local/libexec/sorcery/cast.d/

Anatomy of Spell

  1. Version Information

        stable 1.3.9 1.3.8 1.3.7 1.3.6 1.3.5
      unstable 1.4svn-r7893 1.4svn-r7844 1.4svn-r7796
        secure 1.3.7
    

    Available versions are specified using stable, unstable and secure.
    Releases that fix security issues receive secure.
    Trial and developmental releases are listed using unstable.
    Newer versions are listed to the left of older versions.
    At least one stable version must be specified in each spell.

  2. Requirements:

  3. Category and Attribute
    Spells can be locatd by any combination of
    name, description, category and attirbute
    Listings can be generated by augur using commands like:


    Spells can have multiple categories and attributes.
    However, unlike cateogires which may have a subcategory appended with a slash,
    attributes never have subattributes.

  4. The name of the source file is specified with source.
    It should probably also contain the full URL,
    where the file can be acquired.
    When more than one URL can be used to acquire a file
    list the source filename once and last and
    list the separate URLs ending with / separated by spaces

        source ftp://ftp.cwru.edu/pub/bash/ ftp://ftp.gnu.org/pub/gnu/bash/ bash-${VERSION:0:3}.tar.gz
    

  5. Contents of a spell not described above are optional
    However, a description is recommended.
    The estimate value can be provided by augur check
    after a source has been compiled and installed.

The best method for creating complex spells
is to find a similar spell then copy and edit.
With over 3000 examples in /root/sorcery/grimoire/
there is sure to be a nearly perfect spell to use as a template.
I copy and edit everytime I write a spell.