This library contains all sorcery functions which a spell may use. If the function isn't listed here, it may disapear without warning. If you use a funtion which isn't listed here, you'd better have a good reason. Better yet, raise a bug on the topic and the needed function will probably get added.
Copyright (C) 2004 The Source Mage Team
This library must not contain any logic. It is simply a set of wrapper functions.
Defines the Spell-Sorcery Interface
var.lib.sorcery.modules.libsummon.html for more details.
API
Number portion of SOURCE[[:digit:]], eg '', "2", "3", etc.
Get a particular source, check first in $SOURCE_CACHE and respect FORCE_DOWNLOAD. Calls download_src if the file must be downloaded.
var.lib.sorcery.modules.libmisc.html for more details.
Asks user for string, with default answer and timeout (like query) Return variable is also marked as persistent
Example: config_query DETAILED "Detailed questions ?" n; then if [ $DETAILED == y ]; then .... fi echo The reply for last question was: $DETAILED
var.lib.sorcery.modules.libmisc.html for more details.
Asks user for string, with numbered possibilities listed Return variable is also marked as persistent
Example: config_query_list COLOR "What color ?" "red" "white" "blue" echo Your color is $COLOR
var.lib.sorcery.modules.libmisc.html for more details.
Asks user for string, with default answer and timeout (like query) The string is added to the variable If you want to use empty string, place there dummy string and remove it later by list_remove function. Also for one config variable, all option_yes and option_no have to be different. Return variable is also marked as persistent
Example 1: config_query_option OPT "Use X ?" y "--with-x" "--without-x" config_query_option OPT "Use jpeg ?" y "--with-jpeg" "--do-not-use-jpeg" echo All selected options together: $OPT Example 2: CONFIGURE: config_query_option ASK "Use X11 ?" y --with-x11 EMPTY1 config_query_option ASK "Use Alsa ?" y --with-alsa EMPTY2 BUILD: local TEMP="$ASK" list_remove TEMP EMPTY1 EMPTY2 ./configure $TEMP ...
var.lib.sorcery.modules.libmisc.html for more details.
Asks user for string, with default answer and timeout (like query) Return variable is also marked as persistent
Example: config_query_string REAL_NAME "What is your real name ?" "nobody" echo Hi $REAL_NAME
var.lib.sorcery.modules.libdepends.html for more details.
API
If the default answer is anything other than 'y' then 'n' is assumed. returns the given spellname if it is installed
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Used if no BUILD script is found for a spell Default build for BUILD_API==1 is:
./configure --build=$BUILD ## --prefix=/usr ## --sysconfdir=/etc ## --localstatedir=/var ## $OPTS && make && prepare_install && make installDefault build for BUILD_API==2 is:
./configure --build=$BUILD ## --prefix=/usr ## --sysconfdir=/etc ## --localstatedir=/var ## $OPTS && make
var.lib.sorcery.modules.libsummon.html for more details.
API
Default download code, downloads each SOURCE[[:digit:]]*
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Only defined for BUILD_API==2 Used if no INSTALL script is found. Default install is:
make install
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Only defined for BUILD_API==2 Installs configuration files and documentation.
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Only defined for BUILD_API==1 Installs configuration files and documentation. Stops installwatch. Used if no POST_BUILD script is found for a spell. equivalent to default_sorcery_post_install in BUILD_API==2
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Only defined for BUILD_API==2 Puts the spell at the root of the stage root so manipulation of the installed files can happen
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Only defined for BUILD_API==2 Transfers the files from the stage area to the system. Default is transfer_staged_spell
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Creates the source directory and unpacks the source package into it. Used if no PRE_BUILD script is found for a spell.
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Only defined for BUILD_API==2 Used if no PRE_INSTALL script is found. Default pre_install is:
prepare_install
var.lib.sorcery.modules.libdepends.html for more details.
API
Denotes that a spell requires another spell to work.
var.lib.sorcery.modules.libtrack.html for more details.
API
Stops using installwatch
var.lib.sorcery.modules.libtrack.html for more details.
API
Stops using stage root
var.lib.sorcery.modules.libsummon.html for more details.
API
Number portion of SOURCE[[:digit:]], eg '', "2", "3", etc.
Download a file. If the source is a file tree (eg from cvs or svn) then if there is an existing tarball, it will be unpacked, updated and repackaged as a tar.bz2. If the source is a simple file it will be downloaded as usual.
API
Causes a dependent spell to be recast when it might not otherwise be. This is intended to be called on an already enabled dependency. It can be thought of as an inverse of up_trigger (although it is *not* a trigger).
Example 1: depends foo && force_depends foo Example 2: optional_depends foo --enable-foo --disable-foo "for foo support" && if is_depends_enabled $SPELL foo; then force_depends foo fi
var.lib.sorcery.modules.build_api.common.html for more details.
API
Gathers all documentation files from source archive and installs them as part of the spell
var.lib.sorcery.modules.libmisc.html for more details.
API
String to prefix on the results.
Output a list of source numbers associated with the current spell. This is the number portion of SOURCE[[:digit:]], eg '', "2", "3", etc. A prefix may be given and it will be prepended to each result value.
var.lib.sorcery.modules.libstate.html for more details.
API
the provider name(s)
info from the committed ($DEPENDS_STATUS) database. If the uncommited db doesnt exist (maybe we're not casting) use DEPENDS_STATUS instead.
var.lib.sorcery.modules.libunpack.html for more details.
compressor
API
Guesses what program was used to compress a file Return value is always success due to `file' workings
var.lib.sorcery.modules.libresurrect.html for more details.
API
Present the user with the following menu (0) trash $to and install over it (1) backup $to to $to.$savetime, install the new file in its place (2) leave $to in its place, copy the new file to $to.$savetime (3) do nothing (4) see a diff between $to and the new file choice 2 is currently the default, someday there will be a menu to choose what the default will be
var.lib.sorcery.modules.libstate.html for more details.
API
Returns whether or not a given dependency is enabled
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Returns the current version of the given spell
var.lib.sorcery.modules.libresurrect.html for more details.
API
$(date +'%Y%m%d%H%M') Returns the current version of the given spell
var.lib.sorcery.modules.libtrack.html for more details.
API
Starts using installwatch
var.lib.sorcery.modules.libtrack.html for more details.
API
Starts using stage root
var.lib.sorcery.modules.libmisc.html for more details.
Removes from the list string(s). Strings are kept to be unique and are separated by spaces
Example: MY_LIST="--disable-static --enable-dynamic" list_remove MY_LIST "--enable-dynamic"
var.lib.sorcery.modules.libmisc.html for more details.
Puts in the list string(s). Strings are kept to be unique and are separated by spaces
Example: list_add MY_LIST "--with-x" list_add MY_LIST "--with-jpeg" $OTHER_OPTS echo $MY_LIST
var.lib.sorcery.modules.libmisc.html for more details.
return 0 at least one element is in list return 1 none of supplied elements is not in list Finds if at least one of the given elements is in the string. They can be delimited by spaces, tabs or newlines. The search elements must not contain any of these or they won't match. The matching is exact, regular expressions and globbing patterns are not supported. Warning, this function takes a real string, not a variable name as other list_* functions.
Example: if list_find "$MY_LIST" "--with-x"; then ... we have to compile X components in fi
var.lib.sorcery.modules.libmisc.html for more details.
message
API
echo's the given arguments if SILENT is not set.
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Creates a tmpfs filesystem. By default, the size is 1GB. The caller may optionally supply a size argument.
Example1: Create a 2GB mount at $SOURCE_DIRECTORY mk_source_dir $SOURCE_DIRECTORY 2g Example2: Create a mount at /tmp/newdir, defaults to 1GB size mk_source_dir /tmp/newdir
var.lib.sorcery.modules.libtrack.html for more details.
API
var.lib.sorcery.modules.libtriggers.html for more details.
API
Used by spells to make adding triggerse nice.
var.lib.sorcery.modules.libtriggers.html for more details.
API
Used by spells to make adding triggers nice.
var.lib.sorcery.modules.libtriggers.html for more details.
API
Used by spells to make adding triggerse nice.
var.lib.sorcery.modules.libtriggers.html for more details.
API
Used by spells to make adding triggerse nice.
var.lib.sorcery.modules.libdepends.html for more details.
API
Denotes that a spell can use another spell for additional functionality.
var.lib.sorcery.modules.libmisc.html for more details.
Adds variable names to the list of persistent variables
Example: persistent_add MY_VARIABLE
var.lib.sorcery.modules.libmisc.html for more details.
Unsets all persistent variables. Mainly usable as replacement of persistent_save for functions which can be called by nonroot users ( for example from 'gaze what' )
Example: persistent_clear
var.lib.sorcery.modules.libmisc.html for more details.
Loads persistent variables stored in file "$SPELL_CONFIG"
Example: persistent_load
var.lib.sorcery.modules.libmisc.html for more details.
Removes variable names from the list of persistent variables
Example: persistent_remove MY_VARIABLE
var.lib.sorcery.modules.libmisc.html for more details.
Saves variables marked as persistent to file "$SPELL_CONFIG". The File is completely overwritten. Also unsets all persistent variables
Example: persistent_save
finds the persistent var for a spell and sets the upvar to the value of the variable to read returns: 1 if the var doesn't exist in the file 2 if the tablet dir doesn't exist 3 if the persistent config file doesn't exist 4 if the EXPORTS file doesn't exist
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Prepares to install the spell. Writes the boost lock file. If the spell is installed already, the libraries are saved with save_libraries(), the binaries with save_binaries() and the spell is dispelled. Usually called from the BUILD script of a spell.
var.lib.sorcery.modules.libstate.html for more details.
API
SOURCE_DIRECTORY
var.lib.sorcery.modules.libgrimoire.html for more details.
API
Removes the given directory or SOURCE_DIRECTORY if no argument is given.
var.lib.sorcery.modules.libmisc.html for more details.
API
Asks the user a yes/no question. First argument is the question to ask, second argument is the default answer. If a timeout occurs before the question is answered, the given default answer is applied. Returns true or false based on the answer given.
var.lib.sorcery.modules.libmisc.html for more details.
Asks user for string, with default answer and timeout (like query)
Example: query_string YOUR_HOST "What is your hostname ?" "localhost"
var.lib.sorcery.modules.libdepends.html for more details.
API
Denotes that a spell requires another spell to work.
var.lib.sorcery.modules.libmisc.html for more details.
API
First argument is a sed command. Second argument is a file.
sedit performs the sed command on the file, modifiying the
original file. For example,
sedit "s/foo/bar/g" /tmp/somefile
will replace all occurances of foo with bar in /tmp/somefile.
This function is often used in spells to make changes to source
files before compiling. See the sed man page for more information.
var.lib.sorcery.modules.libdepends.html for more details.
API
recursively prints out the spell that depend on the specified spell
var.lib.sorcery.modules.libstate.html for more details.
API
var.lib.sorcery.modules.libstate.html for more details.
API
var.lib.sorcery.modules.libstate.html for more details.
API
var.lib.sorcery.modules.libstate.html for more details.
API
<@function var.lib.sorcery.modules.libdepends
API
var.lib.sorcery.modules.libdepends.html for more details.
API
Denotes that a spell can use another spell for additional functionality.
var.lib.sorcery.modules.libunpack.html for more details.
API
Given a file, uncompress runs the decompression program for that file, Note: zip is a special case because it doesn't work with streams.
var.lib.sorcery.modules.libunpack.html for more details.
API
Given a file, unpack runs the decompression program for that file, as well as untar'ing the file if appropriate and if the MD5 matches. Note: zip is a special case because it doesn't work with streams. Note: This function is deprecated and kept for spells that still use the old verification methods (MD5[0]=).
var.lib.sorcery.modules.libunpack.html for more details.
API
unpack_file takes the SOURCE suffix and figures out if it is supposed to hash or gpg check it -- then it does its dirty work and runs unpack_hash or unpack_gpg depending upon the circumstances. That's the only argument it takes and needs: '' '2' '3', etc. It is run in default_pre_build for the null argument only. Custom unpacking still requires a custom PRE_BUILD. valid formats: vendor-provided gpg, guru-provided gpg, any hash-algorithm provided by gpg (currently md5, sha1, sha256, sha384, sha512, ripemd160 SOURCE=blah SOURCE2=blah.asc SOURCE_URL=http://blah.com/$SOURCE SOURCE2_URL=http://blah.com/$SOURCE2 SOURCE_GPG=blah.gpg:$SOURCE2:UPSTREAM_KEY SOURCE2_IGNORE=signature # for auditing purposes SOURCE=blah SOURCE_URL=http://blah.com/$SOURCE SOURCE_GPG=swoolley.gpg:$SOURCE.asc:WORKS_FOR_ME SOURCE=blah SOURCE_URL=http://blah.com/$SOURCE MD5[0]=d41d8cd98f00b204e9800998ecf8427e SOURCE=blah SOURCE_URL=http://blah.com/$SOURCE SOURCE_HASH=md5:d41d8cd98f00b204e9800998ecf8427e:WORKS_FOR_ME In GPG mode: Validates the verification level (the third parameter) and the hash algorithm against user defined lists. It finds the public key and signature using locate_spell_file, Then it validates it at the beginning. see unpack_gpg() In HASH mode: Validates the verification level (the third parameter) and the hash algorithm against user defined lists. It uses gpg to calculate the hash value except for md5 and sha1, which coreutils provides. see unpack_hash() In IGNORE mode: It checks for the following text: volatile (for cvs/svn/any-other-scm) unversioned (the source file changes frequently, but not a direct scm) signature (for gnupg signatures) as reasons for ignoring the source code validation. Signatures are silently ignored. Everything else respects MD5SUM_DL. see unpack_ignore Otherwise, it falls back to MISSING mode, see unpack_missing (or for now) Otherwise, it falls back to old uncompressed md5sum check with MD5[n]. see real_unpack() The default verification level is "WORKS_FOR_ME" Verification levels are, these indicate how much effort was put into validating the integrity of the source from the upstream vendor. WORKS_FOR_ME No verification was done. UPSTREAM_HASH Checked the upstream hash file UPSTREAM_KEY Checked upstream (gpg) key, signature matched, but the key was not validated ESTABLISHED_UPSTREAM_KEY Upstream key was not validated against multiple independent sources, but has been in use for several years VERIFIED_UPSTREAM_KEY Upstream key id was verified against multiple independent sources. ID_CHECK_UPSTREAM_KEY Key was verified in person with a photo id check. Also if you want to include more than one signature, hash, etc, just put a 2, 3, 4, etc on the end of the variable like so: SOURCE2_HASH2=... For cascading, currently it will still ask abort questions: a no abort will make it fail over all cascades; a yes abort will have it skip to the next cascades. Missing binaries or other failures like that (error 200 below) will silently fail over to the next check. The cascade order is: GPG, HASH, IGNORE, MISSING The cascade setup allows you to place a higher bit checksum earlier in the cascade and even if the binary doesn't work it will just print out an abort query which can be said no to and it will continue to fail over to the lower bit checksum that should be available in coreutils (like sha1/md5). That's if you're not using gpg, which is preferred. If multiple hashes are included of different ciphers, the user can abort on either that go bad, so it can be considered a security increase to have more than one, but only if the harder cipher is first in the cascade order, as the first successful hash match will go ahead and prompt an untarball. It may change later, but for now we think the first successful match skipping the rest is least intrusive, and I'd need to add an interface element to let the user choose to run all checks on a single source.
var.lib.sorcery.modules.libunpack.html for more details.
API
Name of a file to unpack
Interface to unpack a file without any verification.
var.lib.sorcery.modules.libunpack.html for more details.
API
verify_file takes the SOURCE suffix and verifies the file without unpacking it. It does not work with the old 'MD5[0]=...' style. Only with the "new" SOURCEn_(GPG|HASH|IGNORE) style.
var.lib.sorcery.modules.libgcc.html for more details.
to the passed version installed gcc is at least "version" Checks if the system gcc version is equal to the passed version or when the version ends with a + marker, if it the system version is greater or equal to it. The gcc version is of the major.minor.patchlevel form, but trailing digits can be omitted and will default to 0 in the comparison.
Example: if using_gcc 4.3+; then # same as 4.3.0+ patch -p1 < $SPELL_DIRECTORY/gcc43-compilation-fixes.patch elif using_gcc 4.0.0; then # gcc 4.0.0 triggers a memleak when -O3 is used CFLAGS=${CFLAGS/-O3/-O2} fi
var.lib.sorcery.modules.libdepends.html for more details.
API
Only allowed from UP_TRIGGERS file. Specify that the current spell should trigger the specifed action on the target spell. This is a shortcut for the TRIGGERS file in the target spell, this lets you specify lots of triggers easily.
var.lib.sorcery.modules.libtrack.html for more details.
API
list of files to track manually
Given a list of files it will notify installwatch of them. Useful for spells whose components are not dynamicly linked to glibc. Installwatch must be running for this to work.