Sorcery
C. Cast
Source Mage GNU/Linux is based on "a Sorcery metaphor of 'casting' and 'dispelling' programs." Thus the commands used in it's package management have a sorcerous ring to it. One of these commands is the cast script. Casting a spell basically means installing (casting) a package (spell). Casting a spell does more than just downloading a package, extracting and installing the contents in pre-defined locations like binary Linux distributions. Since Source Mage is a source-based distro, it allows you to customize and optimize almost every aspect of the installation.
The basic form of the cast command is: cast <spell>
1. The Process of Casting
Casting a spell involves a couple of stages:
Stage 1. Preparation and Configuration
The first stage of casting involves setting up the environment for the spell that's being cast. At this point, two things are being done. Preparing the environment usually asks the caster which version of the spell is to be cast, given a choice between stable or development versions. Running the configuration asks the user whether certain built-in features of the program should be enabled or disabled. This usually involves options that can be turned on or off in the configuration script of the package.
Stage 2. Resolving Dependencies
Like all good package managers, Source Mage makes life easier for you by handling dependencies. Source Mage does this interactively and very differently from other distributions, showing Source Mage's power and uniqueness. Sorcery lets you choose the features that you want or need, depending on what dependencies you enable. Sorcery recognizes two kinds of dependencies: required dependencies and optional dependencies.
a. Required dependency
Required dependencies are other spells that are absolutely necessary for the spell that you are casting to compile and run. You will not be asked any question about required dependencies, because you cannot disable them. There is one exception, as we'll see later. Required dependencies are announced while casting:
Spell1 depends on Spell2
qt-x11 depends on g++
b. Optional dependency
This is where things can get a bit tricky. At the same time, this is one of the areas where Source Mage shows it's magic. As the name suggests, optional dependencies are not absolutely necessary. However, they are needed to enable some of the features of the spell that is being cast. In order to enable a certain feature, you need to enable the optional dependency for that feature by casting the spell for it. Optional dependencies are shown like this:
Spell3 is an optional dependency for Spell1 (for feature)
arts is an optional dependency for krusader (for aRts sound daemon)
You will be asked two different kind of questions, depending on whether the optional dependency is already installed.
Do you want to use arts? [y]
Appears if the optional dependency has been installed already. The default answer in this situation is always 'y'
Do you want to cast arts? [n]
Appears if the optional dependency isn't installed yet. The answer defaults to 'n'.
c. Stepping through the dependencies
Now it gets a bit tricky. Once cast has finished asking you about the optional dependencies of the spell. If the dependency is already installed, cast indicates that there is nothing to do and proceeds to the next dependency in the list.
qt-x11 No work to do.
For dependencies that haven't been cast yet, it goes on to do the same for each spell. It also goes through the same process for each of the enabled dependencies of those spells. Think of it as an inverted tree of spells to be cast.
cast Spell1
|
|----Spell1 depends on Spell2
|----Spell3 is an optional dependency of Spell1
| |----Spell3 depends on Spell5
| | |----
| |----Spell6 is an optional dependency of Spell3
| |----
| |----
|----Spell4 is an optional dependency of Spell1
|----Spell7 is an optional dependency of Spell4
|----
Of course cast doesn't do all these to infinity. It stops once all the dependencies have either been configured or installed already. In which case, cast proceeds to the next dependency.
Notes:
You can view a spells dependencies, in a tree-like view, using the gaze command: gaze dependencies
d. Providers
At one point or another, you might have noticed that a spell will depend on what seems to be a spell whose name is in all caps.
qt-x11 requires some X11-LIBS
qt-x11 optionally requires some CUPS (for Common Unix Printing System support).
X11-LIBS and CUPS are not spells (which would be obvious if you tried to cast them). These are called providers, and as the name implies, provides a generic functionality rather than a single specific spell. Providers will list what possible spells provide that functionality and asks you which one to use. Spells that are already installed are marked with (installed) and the first installed spell is set as the default answer. If none of the spells listed by the provider is installed, option 0 is set as the default answer, which could either be None or some other spell.
Notes: To view which spells provide the functionality, use the gaze command: gaze provides
e. Triggers
There are some cases wherein casting or dispelling a spell will cause an already installed spell to perform some action. These events are called triggers. Simply put, certain spells trigger other installed spells to perform an action at a certain point. There are four basic triggers, depending on when the action should be performed.
- on_cast <spell> - indicates that the action should be triggered after the spell has been cast
- on_pre_cast <spell> - indicates that the action should be triggered before the spell is cast
- on_dispel <spell> - indicates that the action should be triggered after the spell has been dispelled
- on_pre_dispel <spell> - indicates that the action should be triggered before the spell is dispelled
Perhaps more important are the four kinds of actions that the trigger executes on an already installed spell. Note that these actions are performed on an already installed spell that owns the trigger, not the spell that is being cast or dispelled which activates the trigger
- cast_self - the owner of the trigger should cast (or recast) itself
- dispel_self - the owner of the trigger should dispel itself
- check_self - the owner of the trigger should check itself for damages
- run_script
- the script named file should be run
qt-x11 triggers a cast_self on kdebase
Stage 3: Confirmation
Once cast has sifted through all the dependencies, it presents a summary of what spells will be cast and asks the caster for confirmation.
Collating dependencies... Spells are to be cast: --------------------------- Do you want to cast these spells? [y]
The default answer is 'y'.
Stage 4: Downloading and Verification
cast now downloads the source code package, either from the upstream author's own download site or from mirrors provided by the author, ibiblio, or other Source Mage users. If there is more than one spell to be cast in the queue, the source packages for other spells are downloaded while some other spell is compiling. If the source code has previously been downloaded and still exists on the hard drive, casts indicates that it's been found and no longer tries to download it again.
Notes: Source code packages are downloaded to /var/spool/sorcery/ by default. This is also the default place where cast looks if a source code package already exists, unless otherwise directed to another directory.
Found source file krusader-1.80.0.tar.gz for spell krusader in /var/spool/sorcery
cast then tries to verify the integrity of the downloaded source tarball using either GPG, MD5, SHA1 or any other hashes indicated by the spell.
hash checking source file krusader-1.80.0.tar.gz... Algorithm used: sha512 Allowing new hashsha512 Checking spell level WORKS_FOR_ME Spell level is a new allowed level hash verification succeeded
Stage 5: Configure options
The caster is now asked whether he or she wants to add some more options to the the configure script of the program being cast. This lets the caster enable or disable features found in the ./configure script that weren't asked during the Running configuration stage (Stage 0) or by the optional dependencies. The default reply to this question is 'n'.
If the caster chooses to add other options, the default text editor is opened, showing the options provided by the configure script. The default text editor depends on what was chosen during the installation, which is set in the /etc/profile.d/editor.sh script. Additional options should be put at the end of the file. Once the file is saved and you exit the text editor, cast proceeds immediately to compiling the spell.
Notes: The options that you add here are always saved. If you want to remove the option, you have to choose to edit the file again and delete the options you have added.
Stage 6: Compilation
Nothing to do here except wait. You can view the compilation as it happens, which is the default. Like any other option in Sorcery, you can turn it off in the Sorcery Features menu. Regardless whether it's enabled or not, the compilation log is saved in a bzipped tarball which you can view with the Gaze script later on. After compilation has been finished and the the log created, you will be asked if you want to view the compile log. You can also turn this prompting off in the Sorcery Features menu.
Sometimes, some post-installation instructions are given here. Take note of them, because sometimes these instructions are not saved in the log files.
Notes: The compilation log is stored in a bzipped tarball located at /var/log/sorcery/compile/
Stage 7: Installation
Now that the compilation is over, all that's left is to actually install the program. As with the compilation, cast saves an installation log of what files were installed and where. It also creates and MD5 log for every file installed by the spell. This can be used later on for verifying the integrity of the system, checking whether files have been tampered with or are missing. A cache of all installed files are stored in a tarball which can be used to resurrect a spell that has been dispelled, without recompiling. It could also be used to restore a spell to its pristine state, in case the integrity check fails.
As before, the caster is asked if he wants to view the installation log and again, this prompt can be turned on or off in Sorcery.
Notes:
The installation log is stored in a plain text file located in /var/log/sorcery/install/
The MD5 log is stored in a plain text file located in /var/log/sorcery/md5sum/
The install cache is saved in a bzipped tarball located at /var/cache/sorcery/
And that's it! The spell has been cast. To see an actual example of the casting process, see http://wiki.sourcemage.org/New_to_Source_Mage_GNU/Linux.
2. Resurrecting
Resurrecting a spell, that is, recasting a dispelled spell, is very easy thanks to Sorcery's features. cast remembers all the answers you gave the first time you cast the spell, so it no longer asks you the questions again unless you specifically tell it to. It will merely list all the dependencies, both required and optional. For an optional dependency the caster has chosen to enable, it displays
qt-x11 optionally depends on libpng
If the optional dependency is turn off, it displays
qt-x11 has a disabled optional depends on stlport
The -r (--reconfigure) option forces all questions will be asked again, but with the answers you gave the first time as the default answers.
Resurrecting also doesn't involve any recompilation unless cast is instructed to. The contents of the saved install cache tarball are just extracted and installed in their proper locations. Using the -c (--compile) tells cast to compile the spell anyway.
3. Cast options
The man page for the cast command has very clear descriptions on the different options available for cast. Since the documentation for it is already excellent, just a few notes are needed.
Unlike your conventional Linux commands, you can't combine cast options into a single entity. If you want to use -s (download everything first before casting), -d (force downloading), and -r (reconfigure), you can't use -sdr. You have to put each option separately. This goes the same for the whole Sorcery suite.
The options --cflags, --cxxflags, --ldflags, --no-opts, and -V only apply to the particular cast they were used in. It doesn't change the default settings used by Sorcery.
The -r option implies the -c option. But if none of the options have changed to effect a recompilation, the install cache tarball is just used instead of recompiling.
4. A few last notes
...
And now we move to the anti-thesis of casting: dispel