Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master binary grimoire by George Sherwood (3f8edd3fc622e2a98f201f14a0529e3a3bfd4138)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: George Sherwood <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master binary grimoire by George Sherwood (3f8edd3fc622e2a98f201f14a0529e3a3bfd4138)
  • Date: Tue, 21 Oct 2008 15:30:27 -0500

GIT changes to master binary grimoire by George Sherwood
<gsherwood AT sourcemage.org>:

API_VERSION | 1
ChangeLog | 4
FUNCTIONS | 617
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gurus.gpg |binary
libaccount | 267 +++++++++++++++++++++++++
libcompat | 67 ++++++
libgcc | 106 ++++++++++
7 files changed, 1062 insertions(+)

New commits:
commit 3f8edd3fc622e2a98f201f14a0529e3a3bfd4138
Author: George Sherwood <gsherwood AT sourcemage.org>
Commit: George Sherwood <gsherwood AT sourcemage.org>

Added grimoire files from z-rejected.

diff --git a/API_VERSION b/API_VERSION
new file mode 100755
index 0000000..844885a
--- /dev/null
+++ b/API_VERSION
@@ -0,0 +1 @@
+BUILD_API=2
diff --git a/ChangeLog b/ChangeLog
index d782446..4efc9ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-21 George Sherwood <gsherwood AT sourcemage.org>
+ * API_VERSION, gurus.gpg, libcompat, libaccount, libggc:
+ Added files from z-rejected.
+
2008-10-19 George Sherwood <gsherwood AT sourcemage.org>
* bin-http/firefox-obstcp: Added new spell

diff --git a/FUNCTIONS b/FUNCTIONS
new file mode 100755
index 0000000..979f710
--- /dev/null
+++ b/FUNCTIONS
@@ -0,0 +1,617 @@
+. $GRIMOIRE/libaccount
+. $GRIMOIRE/libgcc
+
+#---------------------------------------------------------------------
+## Replaces sorcerys default_pre_build with a custom version using
+## the invoke_gcc function from libgcc #10641
+#---------------------------------------------------------------------
+function default_pre_build () {
+ invoke_gcc &&
+ real_default_pre_build
+}
+
+#---------------------------------------------------------------------
+## @return 0 if glibc was compiled with NPTL
+## @return 1 otherwise
+##
+## Detects if the current glibc includes NPTL support.
+##
+#---------------------------------------------------------------------
+function glibc_is_nptl ()
+{
+ if getconf GNU_LIBPTHREAD_VERSION | grep -q NPTL; then
+ return 0
+ fi
+ return 1
+}
+
+#---------------------------------------------------------------------
+# Runs update-desktop-database if it is installed
+#---------------------------------------------------------------------
+function update_desktop_database ()
+{
+ if test -x /usr/bin/update-desktop-database; then
+ message "${MESSAGE_COLOR}Updating application mime type
database.${DEFAULT_COLOR}"
+ /usr/bin/update-desktop-database
+ fi
+}
+
+#---------------------------------------------------------------------
+## this function installs the *.desktop, start* files and qingy links
+## this function is intended to be used by spells for windowmanagers
+#---------------------------------------------------------------------
+function install_wmfiles ()
+{
+ local wm_desktopfile_dir="${INSTALL_ROOT}/usr/share/xsessions"
+ local wm_startwm_dir="${INSTALL_ROOT}/usr/bin"
+
+ # install the start* file for the windowmanager if it's not
+ # installed already
+ if [ -f ${SCRIPT_DIRECTORY}/start${SPELL} ] ; then
+ if ! [ -e ${wm_startwm}/start${SPELL} ] ; then
+ install -m 755 ${SCRIPT_DIRECTORY}/start${SPELL} \
+ ${wm_startwm_dir}
+ fi
+ fi
+
+ # making sure the destination directory exists
+ if ! [ -d ${wm_desktopfile_dir} ] ; then
+ mkdir ${wm_desktopfile_dir}
+ fi &&
+
+ # install the windowmanagers desktop file
+ if [ -f ${SCRIPT_DIRECTORY}/${SPELL}.desktop ] ; then
+ if ! [ -e ${wm_desktopfile_dir}/${SPELL}.desktop ]; then
+ install -m 755 ${SCRIPT_DIRECTORY}/${SPELL}.desktop \
+ ${wm_desktopfile_dir}
+ fi
+ fi
+
+ if ( spell_ok qingy ); then
+ if [ -x ${wm_startwm_dir}/start${SPELL} ] ; then
+ if [ ! -d ${INSTALL_ROOT}/etc/qingy/xsessions ]; then
+ install -d -m 755 ${INSTALL_ROOT}/etc/qingy/xsessions
+ fi &&
+ ln -s ${wm_startwm_dir}/start${SPELL} \
+ ${INSTALL_ROOT}/etc/qingy/xsessions/${SPELL}
+ fi
+ fi
+}
+
+#---------------------------------------------------------------------
+## Sets the current script to run only one make job
+#---------------------------------------------------------------------
+
+function make_single ()
+{
+ JOBS_PER_HOST=0 &&
+ MAKE_NJOBS=1
+}
+
+#---------------------------------------------------------------------
+## Re-enables the normal Sorcery make (cancels single_make)
+#---------------------------------------------------------------------
+
+function make_normal ()
+{
+ source $COMPILE_CONFIG
+}
+
+#---------------------------------------------------------------------
+## @param shellname
+## @param full path to shell
+##
+## Adds a shell to /etc/shells and optionally to qingy's sessions
+#---------------------------------------------------------------------
+function install_shell ()
+{
+ local qingy_session_dir="${INSTALL_ROOT}/etc/qingy/sessions"
+
+ if [ -z "$1" ] ; then
+ message "${PROBLEM_COLOR}no shell name specified,
aborting${DEFAULT_COLOR}"
+ return 1
+ fi &&
+ if [ ! -e "$2" ] ; then
+ message "${PROBLEM_COLOR} $2 isn't executable, no use adding it as a
shell${DEFAULT_COLOR}"
+ return 1
+ fi &&
+
+ #installing shell into /etc/shells
+ message "installing $1 into /etc/shells"
+ if ! ( grep -q "^${2}$" ${INSTALL_ROOT}/etc/shells ) ; then
+ echo "$2" >> ${INSTALL_ROOT}/etc/shells
+ fi || return 1
+
+ #installing shell into qingy's session dir if it's installed
+ if ( spell_ok qingy ) && ! [ -f ${qingy_session_dir}/$1 ] ; then
+ message "installing $1 into $qingy_session_dir"
+ echo "$2" > ${qingy_session_dir}/$1 &&
+ chmod 0755 ${qingy_session_dir}/$1
+ fi
+}
+
+#---------------------------------------------------------------------
+## @param shellname
+## @param full path to shell
+##
+## Removes a shell from /etc/shells and optionally from qingy's sessions
+#---------------------------------------------------------------------
+function remove_shell ()
+{
+ local qingy_session_dir="${INSTALL_ROOT}/etc/qingy/sessions"
+
+ if [ -z "$1" ] ; then
+ message "${PROBLEM_COLOR}no shell name specified,
aborting${DEFAULT_COLOR}"
+ return 1
+ fi &&
+ if [ -z "$2" ] ; then
+ message "${PROBLEM_COLOR}no shell path specified,
aborting${DEFAULT_COLOR}"
+ return 1
+ fi &&
+
+ #removing shell from /etc/shells
+ if [ -f /etc/shells ] ; then
+ sedit "\:^$2$:d" /etc/shells
+ fi
+
+ # and optionally from qingy's session dir
+ if [ -f ${qingy_session_dir}/$1 ] ; then
+ message "removing $1 from $qingy_session_dir"
+ rm -f ${qingy_session_dir}/$1
+ fi
+}
+
+
+#---------------------------------------------------------------------
+## replacement for config_query_string to work around a short timeout
+## when entering long strings (hostnames, organisation names)
+#---------------------------------------------------------------------
+function config_query_long_string() {
+ local ANSWER
+ local DELAY=5
+ if config_get_option "$1" ANSWER; then
+ # option allready answered in config
+ echo -e "[[ ${QUERY_COLOR}$2${DEFAULT} ->
'${QUERY_COLOR}$ANSWER${DEFAULT}' ]]"
+ else
+ query_string ANSWER "$2" "$3"
+ read -t $DELAY -n 1 ANSWER_first
+ if [[ $ANSWER_first ]] ; then
+ read ANSWER_rest
+ fi
+ ANSWER="${ANSWER_first}${ANSWER_rest}"
+ config_set_option "$1" "$ANSWER"
+ fi
+ return 0
+}
+
+#---------------------------------------------------------------------
+## @param Directory with files we might want to install
+## @param Destination directory (optional)
+##
+## Installs files to WWW_DEST ($INSTALL_ROOT/usr/share/www/$SPELL) and
+## sets up proper www-data permissions
+## Optionally the second parameter will override WWW_DATA (and make
+## sure INSTALL_ROOT exists only once in the WWW_DATA)
+#---------------------------------------------------------------------
+function install_www_files ()
+{
+ if [ ! -z $2 ]; then
+ #
+ # Just in case the destination already includes INSTALL_ROOT, remove it
+ #
+ local WWW_DEST="$INSTALL_ROOT/${2/\$INSTALL_ROOT/}"
+ else
+ local WWW_DEST="$INSTALL_ROOT/usr/share/www/$SPELL"
+ fi &&
+
+ #
+ # Make sure WWW_DEST exists
+ #
+ if [ ! -d "$WWW_DEST" ]; then
+ if [ ! -d "${WWW_DEST/\/$SPELL/}" ]; then
+ mkdir -p "${WWW_DEST/\/$SPELL/}" &&
+ chmod 0755 "${WWW_DEST/\/$SPELL/}" &&
+ chown www-data:www-data "${WWW_DEST/\/$SPELL/}"
+ fi &&
+
+ mkdir -p "$WWW_DEST" &&
+ chmod 0755 "$WWW_DEST" &&
+ chown www-data:www-data "$WWW_DEST"
+ fi &&
+
+ # find $@ | while read file; do install ... $file ...; done
+ # find $1 -type -f | while read file; do
+ for www_file in `find $1 -type f`; do
+ if install_config_file "$www_file" "$WWW_DEST/$www_file"; then
+ chmod 0644 "$WWW_DEST/$www_file" &&
+ chown www-data:www-data "$WWW_DEST/$www_file"
+ fi
+ done
+ #
+ # Warning message about new location for www files
+ # Remove around 2005-08-02 (one month in test, another in stable,
supposedly)
+ #
+ message "${MESSAGE_COLOR}Your web files have been moved out of the"
\
+ "APACHE specific locations (apache2/htdocs, httpd/htdocs, etc.)"
\
+ "and into a shared, non-DocumentRoot $INSTALL_ROOT/usr/share/www"
\
+ "directory. You can modify your web server to point there for"
\
+ "these files now.${DEFAULT_COLOR}"
+}
+
+#---------------------------------------------------------------------
+## Removes traces of NSPR and NSS from Mozilla-based software
+## TODO move patch to a central place
+#---------------------------------------------------------------------
+function mozilla_remove_nspr_nss() {
+ message 'Checking Mozilla source code...' &&
+ [[ "$(basename $(pwd))" == mozilla ]] &&
+ message 'Checking the spell...' &&
+ [[ -f $SCRIPT_DIRECTORY/security_manager_makefile.diff ]] &&
+ patch -p1 < $SCRIPT_DIRECTORY/security_manager_makefile.diff &&
+ rm -fr dbm nsprpub security/nss &&
+ # exclude DBM for top-level modules and don't build it
+ sedit 's@\<dbm\>@@g' Makefile.in &&
+ sedit 's@\<dbm\>@@g' build/unix/modules.mk &&
+ # don't define NSS libraries as dependencies and don't look for them in
the tree
+ sedit
's@$(DIST)/lib/$(LIB_PREFIX)\(crmf\|dbm\|nss3\|softokn3\|smime3\|ssl3\)\.$(LIB_SUFFIX)@-l\1@g'
config/config.mk &&
+ sedit 's@NSS_DEP_LIBS\s*=@__undefine_\0@g' config/config.mk &&
+ # align the makefile-s
+ find -name Makefile.in | while read __MAKEFILE; do
+ # use system NSPR's and NSS's headers
+ # option `--with-system-nspr' doesn't do it everywhere
+ sedit 's@-I\S*\(nss\|nspr\)\>@-I/usr/include/\1@g' $__MAKEFILE
+ done
+}
+
+#---------------------------------------------------------------------------
+## Invokes the unamechange spell any spell that uses this should depend on
+## unamechange otherwise this function does nothing.
+## to use this function simply call then change the variables listed ro have
+## any call to uname return that value
+#--------------------------------------------------------------------------
+function invoke_uname_change()
+{
+ if [[ $(installed_version unamechange) ]] ; then
+ export UNAME_CHANGE_SYSNAME=$(uname -s)
+ export UNAME_CHANGE_NODENAME=$(uname -n)
+ export UNAME_CHANGE_RELEASE=$(uname -r)
+ export UNAME_CHANGE_VERSION=$(uname -v)
+ export UNAME_CHANGE_MACHINE=$(uname -m)
+ export UNAME_CHANGE_DOMAINNAME=$(uname -o)
+
+ export LD_PRELOAD="${LD_PRELOAD} /usr/lib/unamechange.so"
+ fi
+}
+
+#-------------------------------------------------------------------------
+## Returns the state of the system back to normal after calling
+## invoke_uname_change unset's all environmental vars and returns
+## LD_PRELOAD back to normal
+#-------------------------------------------------------------------------
+function devoke_uname_change()
+{
+ if [[ $(installed_version unamechange) ]] ; then
+ unset UNAME_CHANGE_SYSNAME
+ unset UNAME_CHANGE_NODENAME
+ unset UNAME_CHANGE_RELEASE
+ unset UNAME_CHANGE_VERSION
+ unset UNAME_CHANGE_MACHINE
+ unset UNAME_CHANGE_DOMAINNAME
+
+ export LD_PRELOAD="${LD_PRELOAD/\/usr\/lib\/unamechange.so/}"
+ fi
+}
+
+#-------------------------------------------------------------------------
+## Compatibility code for gracefully failing if the user uses an older
+## version of sorcery with a spell that calls unpack_file.
+#-------------------------------------------------------------------------
+declare -f unpack_file &> /dev/null ||
+function unpack_file() {
+ message "This spell uses a function only available in sorcery 1.12.2 or
newer, please update."
+ return 1
+}
+
+#-------------------------------------------------------------------------
+## Default build for Python spell.
+#-------------------------------------------------------------------------
+function default_build_python() {
+ python setup.py build
+}
+
+#-------------------------------------------------------------------------
+## Default install for Python spell.
+## INSTALL_ROOT is used here only if not empty, because some spells can't
+## install with "--root '/'" option.
+#-------------------------------------------------------------------------
+function default_install_python() {
+ python setup.py install ${INSTALL_ROOT:+--root "$INSTALL_ROOT/"}
+}
+
+#-------------------------------------------------------------------------
+## Compatibility code for gracefully failing if the user uses an older
+## version of sorcery with a spell that calls unpack_file.
+#-------------------------------------------------------------------------
+declare -f unpack_file &> /dev/null ||
+function unpack_file() {
+ message "This spell uses a function only available in sorcery 1.12.2 or
newer, please update."
+ return 1
+}
+
+#-------------------------------------------------------------------------
+## compatibility code for stable and test sorcery
+## this should be removed when SMGL_COMPAT_ARCHS reaches stable sorcery
+#-------------------------------------------------------------------------
+if [[ -z $SMGL_COMPAT_ARCHS ]] ; then
+ local SPECFILE
+ local specdir
+ for specdir in ${ARCH_SPECS[@]} ; do
+ SPECFILE=$(find -L ${specdir} -perm -400 -type f -name
"$ARCHITECTURE" -print -quit 2>/dev/null);
+ [ $SPECFILE ] && break
+ done
+ explode "${SPECFILE#$specdir/}" '/' SMGL_COMPAT_ARCHS
+
+ unset ARCHITECTURE
+ # Reverse the array so that the most specific arch is first
+ j=0
+ for(( i=${#SMGL_COMPAT_ARCHS[@]}-1; i>=0; i--)) ; do
+ ARCHITECTURE[j++]=${SMGL_COMPAT_ARCHS[i]}
+ done
+fi
+
+
+#---
+## disable_pic
+## A function to smartly disable -DPIC and -fPIC flags
+## has one optional parameter: force which forces disable
+#---
+
+disable_pic() {
+ if [[ "${SMGL_COMPAT_ARCHS[1]}" != "x86_64" ]] &&
+ [[ "${SMGL_COMPAT_ARCHS[1]}" != "alpha" ]] ||
+ [[ "$1" == "force" ]]
+ then
+ CFLAGS=${CFLAGS/-fPIC} &&
+ CFLAGS=${CFLAGS/-DPIC} &&
+ CXXFLAGS=${CXXFLAGS/-fPIC} &&
+ CXXFLAGS=${CXXFLAGS/-DPIC}
+ fi
+}
+#
+## Function to check if we're using xorg-modular libs or not
+#
+
+function check_if_xorg_modular_libs()
+{
+ if [[ "$(get_spell_provider ${1:-$SPELL} X11-LIBS)" == "xorg-server"
]] ||
+ [[ "$(get_spell_provider ${1:-$SPELL} X11-LIBS)" == "xorg-libs"
]]
+ then
+ return 0
+ fi
+ return 1
+}
+
+#
+## Function to check if we're using xorg-modular server or not
+#
+
+function check_if_xorg_modular_server()
+{
+ if [[ "$(get_spell_provider ${1:-$SPELL} X11-SERVER)" ==
"xorg-server" ]]
+ then
+ return 0
+ fi
+ return 1
+}
+
+#---
+## @Synopsis a parse_iw clone function
+#---
+
+function grimoire_parse_iw() {
+ local INPUT=$1
+
+ # it is EXTREMELY IMPORTANT that this variable contains an actual
+ # tab character and not some number of spaces. Otherwise BAD THINGS
+ # will happen.
+ local TAB=" "
+ OMIT_IN="${TAB}rename\|${TAB}symlink\|${TAB}unlink"
+
+ grep -v "$OMIT_IN" $INPUT | cut -f3 | grep "^/"
+ cat $INPUT | cut -f4 | grep "^/"
+}
+
+#---
+## @Synopsis an exists clone function
+#---
+function grimoire_exists() {
+ while read ITEM; do [ -e "$ITEM" ] && echo "$ITEM"; done;
+}
+
+#---
+## @Synopsis default_games_build function to replace
+## @Synopsis all the duplication of the same stuff in games-grimoire
+#---
+
+function default_games_build() {
+ OPTS="$OPTS --bindir=${INSTALL_ROOT}/usr/games \
+ --datadir=${INSTALL_ROOT}/usr/share/games \
+ --localstatedir=${INSTALL_ROOT}/var/games" &&
+ default_build
+}
+
+#---
+## @Synopsis A function to find all dirs and files and set them to
+## @Synopsis proper permissions.
+#---
+
+function find_and_scam() {
+ find ./ -type d -print0 | xargs -r -0 -n 1 chmod 0750
+ find ./ -type d -print0 | xargs -r -0 -n 1 chown root:games
+ find ./ -type f -print0 | xargs -r -0 -n 1 chmod 0640
+ find ./ -type f -print0 | xargs -r -0 -n 1 chown root:games
+}
+
+#---
+## @Synopsis games_make_proper_binary function to make all
+## @Synopsis binaries in /usr/games chown root:games and
+## @Synopsis chmod 0750.
+#---
+
+function games_make_proper_binary() {
+if grep -q "usr/games/" $IW_LOG > /dev/null 2>&1
+then
+ grimoire_parse_iw $IW_LOG | grimoire_exists | sort | grep "usr/games/" |
xargs -r -n 1 chmod -f 0750
+ grimoire_parse_iw $IW_LOG | grimoire_exists | sort | grep "usr/games/" |
xargs -r -n 1 chown -f root:games
+elif [[ $STAGED_INSTALL == on ]]
+then
+ echo "doing the stage root thing"
+ find $STAGE_DIRECTORY/TRANSL/ | sed "s#$STAGE_DIRECTORY/##" | grep
'^TRANSL/usr/games' | xargs -r -n 1 chmod -f 0750
+ find $STAGE_DIRECTORY/TRANSL/ | sed "s#$STAGE_DIRECTORY/##" | grep
'^TRANSL/usr/games' | xargs -r -n 1 chown -f root:games
+else
+message "${QUERY_COLOR}If you see this message and you're not \n \
+installing a data spell then report this at the following url: \n \
+http://bugs.sourcemage.org/enter_bug.cgi?product=Codex&bug_status=NEW&version=games%20grimoire&component=games%20grimoire&re
+p_platform=Other&op_sys=other&priority=P2&bug_severity=minor&assigned_to=games%40sourcemage.org&cc=&bug_file_loc=http%3A%2F%
+2F&short_desc=${SPELL}%20not%20installing%20binaries%20properly&comment=&dependson=&blocked=9312&maketemplate=Remember%20val
+ues%20as%20bookmarkable%20template&form_name=enter_bug \
+${DEFAULT_COLOR}"
+fi
+}
+
+#---
+## @Synopsis default_games_post_install function to
+## @Synopsis clean out any empty share/games/SPELL dirs
+## @Synopsis clean out any empty gather docs dirs
+## @Synopsis and run the real_default_post_install afterwards
+#---
+
+function default_games_post_install() {
+ games_make_proper_binary &&
+ if [[ $STAGED_INSTALL == on ]]; then
+ rmdir --ignore-fail-on-non-empty
${STAGE_DIRECTORY}/TRANSL/usr/share/games/${SPELL} &&
+ rmdir --ignore-fail-on-non-empty
${STAGE_DIRECTORY}/TRANSL/usr/share/games &&
+ rmdir --ignore-fail-on-non-empty
${STAGE_DIRECTORY}/TRANSL/usr/share/doc/${SPELL} &&
+ rmdir --ignore-fail-on-non-empty ${STAGE_DIRECTORY}/TRANSL/usr/share/doc
&&
+ rmdir --ignore-fail-on-non-empty ${STAGE_DIRECTORY}/TRANSL/usr/share
+ else
+ rmdir --ignore-fail-on-non-empty
${INSTALL_ROOT}/usr/share/games/${SPELL} &&
+ rmdir --ignore-fail-on-non-empty ${INSTALL_ROOT}/usr/share/games
&&
+ rmdir --ignore-fail-on-non-empty ${INSTALL_ROOT}/usr/share/doc/${SPELL}
&&
+ rmdir --ignore-fail-on-non-empty ${INSTALL_ROOT}/usr/share/doc
&&
+ rmdir --ignore-fail-on-non-empty ${INSTALL_ROOT}/usr/share
+ fi
+ real_default_post_install
+}
+
+#-------------------------------------------------------------------------
+## Print the version of the running kernel.
+#-------------------------------------------------------------------------
+function get_running_kernel_version()
+{
+ # Try the proc interface first because it returns the version of the
+ # running kernel even when unamechange is invoked.
+ [[ -f /proc/sys/kernel/osrelease ]] && cat /proc/sys/kernel/osrelease ||
+ uname -r
+}
+
+#-------------------------------------------------------------------------
+## Print the version of the installed linux spell or, lacking that, "-1".
+## This is just a wrapper for 'installed_version linux' with the exception
+## that this will always print something and not return false.
+#-------------------------------------------------------------------------
+function get_sorcery_kernel_version()
+{
+ installed_version linux || echo "-1"
+}
+
+#-------------------------------------------------------------------------
+## Print the version of the kernel defined in USE_KERNEL_VERSION or,
+## lacking that, the version of either the installed linux spell or the
+## running kernel.
+#-------------------------------------------------------------------------
+function get_kernel_version()
+{
+ if [[ $USE_KERNEL_VERSION ]]
+ then
+ echo "$USE_KERNEL_VERSION"
+ else
+ installed_version linux || get_running_kernel_version
+ fi
+}
+
+#-----------------------------------------------------------------------
+## Print the kernel config status of the running kernel for the option
+## defined in $1.
+## If a configure file is found print the requested config status (if
+## any) and return 0, otherwise return 1.
+#-----------------------------------------------------------------------
+function get_running_kernel_config()
+{
+ if [[ -f /proc/config.gz ]]
+ then
+ zgrep "^$1=" /proc/config.gz | cut -d= -f2
+ else
+ local KVER="$(get_running_kernel_version)"
+ if [[ -f "/boot/config-$KVER" ]]
+ then
+ grep "^$1=" "/boot/config-$KVER" | cut -d= -f2
+ elif [[ -f "/usr/src/linux-$KVER/.config" ]]
+ then
+ grep "^$1=" "/usr/src/linux-$KVER/.config" | cut -d= -f2
+ else
+ return 1
+ fi
+ fi
+}
+
+#-----------------------------------------------------------------------
+## Print the kernel config status of the installed linux spell for the
+## option defined in $1.
+## If the linux spell is installed and a configure file is found print
+## the requested config status (if any) and return 0, otherwise return
+## 1.
+#-----------------------------------------------------------------------
+function get_sorcery_kernel_config()
+{
+ local KVER="$(installed_version linux)"
+ if [[ $KVER ]]
+ then
+ if [[ -f "/boot/config-$KVER" ]]
+ then
+ grep "^$1=" "/boot/config-$KVER" | cut -d= -f2
+ elif [[ -f "/usr/src/linux-$KVER/.config" ]]
+ then
+ grep "^$1=" "/usr/src/linux-$KVER/.config" | cut -d= -f2
+ else
+ return 1
+ fi
+ else
+ return 1
+ fi
+}
+
+#-----------------------------------------------------------------------
+## Print the kernel config status for the option defined in $1 from the
+## kernel defined in USE_KERNEL_VERSION or, lacking that, from either
+## the installed linux spell or the running kernel.
+## If a configure file is found print the requested config status (if
+## any) and return 0, otherwise return 1.
+#-----------------------------------------------------------------------
+function get_kernel_config()
+{
+ if [[ $USE_KERNEL_VERSION ]]
+ then
+ if [[ -f "/boot/config-$USE_KERNEL_VERSION" ]]
+ then
+ grep "^$1=" "/boot/config-$USE_KERNEL_VERSION" | cut -d= -f2
+ elif [[ -f "/usr/src/linux-$USE_KERNEL_VERSION/.config" ]]
+ then
+ grep "^$1=" "/usr/src/linux-$USE_KERNEL_VERSION/.config" | cut -d= -f2
+ else
+ return 1
+ fi
+ else
+ get_sorcery_kernel_config "$1" || get_running_kernel_config "$1"
+ fi
+}
diff --git a/gurus.gpg b/gurus.gpg
new file mode 100644
index 0000000..c6d1142
Binary files /dev/null and b/gurus.gpg differ
diff --git a/libaccount b/libaccount
new file mode 100755
index 0000000..1c3261b
--- /dev/null
+++ b/libaccount
@@ -0,0 +1,267 @@
+#!/bin/bash
+#---------------------------------------------------------------------
+##
+## @Synopsis Functions for dealing with account and group generation etc.
+## @Copyright Copyright (C) 2004 The Source Mage Team
<http://www.sourcemage.org>
+## A library to help deal with managing accounts, particularly creating
+## new accounts.
+##
+#---------------------------------------------------------------------
+
+ACCOUNT_LIST=$GRIMOIRE/accounts
+GROUP_LIST=$GRIMOIRE/groups
+
+#---------------------------------------------------------------------
+## Tests account and group list if there are no duplicate ID's. In
+## case there are, exits since this is serious problem
+#---------------------------------------------------------------------
+function sanity_checks() {
+ local COUNT1=$( cut -d : -f2 "$ACCOUNT_LIST" | wc -l )
+ local COUNT2=$( cut -d : -f2 "$ACCOUNT_LIST" | sort -u | wc -l )
+ if [ $COUNT1 != $COUNT2 ]; then
+ message "${PROBLEM_COLOR}Fatal error, $ACCOUNT_LIST contains duplicate
UID's${DEFAULT_COLOR}"
+ exit 1
+ fi
+
+ COUNT1=$( cut -d : -f2 "$GROUP_LIST" | wc -l )
+ COUNT2=$( cut -d : -f2 "$GROUP_LIST" | sort -u | wc -l )
+ if [ $COUNT1 != $COUNT2 ]; then
+ message "${PROBLEM_COLOR}Fatal error, $GROUP_LIST contains duplicate
GID's${DEFAULT_COLOR}"
+ exit 1
+ fi
+}
+
+#---------------------------------------------------------------------
+## @param system account
+## @param [home directory] - default used when not defined or empty
+## @param [shell] - default used when not defined or empty
+## @param [secondary gids] - comma separated list with
+## no intervening whitespace
+##
+## Creates account (if account has been defined).
+## @return 0 if success (or account already exists).
+## @return 1 if failed (or account has not been defined).
+##
+#---------------------------------------------------------------------
+function create_account() {
+
+# sanity_checks
+
+ local HOME_DIR=/var/run/$1
+ if [ -n "$2" ]; then
+ HOME_DIR="$2"
+ fi
+
+ local USER_SHELL=/bin/false
+ if [ -n "$3" ]; then
+ USER_SHELL="$3"
+ fi
+
+ local SECONDARY_GIDS=''
+ if [ -n "$4" ]; then
+ SECONDARY_GIDS="-G $4"
+ fi
+
+ if ! exists_account "$1" ; then
+ debug "libgrimoire" "create_account() - $1 not defined!"
+ return 0 # should return 0 to gracefully continue casting.
+ fi
+
+ local ACCOUNT_UID=`get_uid_for_account $1`
+ local PRIMARY_GID=`get_primary_gid_for_account $1`
+ local PRIMARY_GNAME=`get_group_name $PRIMARY_GID`
+
+ debug "libgrimoire" "create_account() - $1, UID=$ACCOUNT_UID,
GID=$PRIMARY_GID:$PRIMARY_GNAME, HOME=$HOME_DIR, SHELL=$USER_SHELL,
SECONDARY_GIDS=$4"
+
+ groupadd -g $PRIMARY_GID -f $PRIMARY_GNAME
+
+ # check for adding user problems and try to notify user.
+ useradd -u $ACCOUNT_UID -g $PRIMARY_GNAME $SECONDARY_GIDS -d "$HOME_DIR"
-s "$USER_SHELL" $1
+ local USERADD_RETURN=$?
+ debug "libgrimoire.create_account()" "useradd return code was:
$USERADD_RETURN"
+
+ if [ $USERADD_RETURN == 0 ] ; then
+ message "${MESSAGE_COLOR}The user id $ACCOUNT_UID
created!${DEFAULT_COLOR}"
+ elif [ $USERADD_RETURN == 4 ] ; then
+ message "${MESSAGE_COLOR}The user id $ACCOUNT_UID already exists, so
continuing...${DEFAULT_COLOR}"
+ return 0
+ elif [ $USERADD_RETURN == 9 ] ; then
+ message "${MESSAGE_COLOR}The user name $1 already exists, so
continuing...${DEFAULT_COLOR}"
+ return 0
+ else
+ debug "libgrimoire.create_account()" "useradd fails with strange code :
$USERADD_RETURN"
+ message "${MESSAGE_COLOR}Something went wrong with adding the user $1
with uid $ACCOUNT_UID"
+ message "and gid $PRIMARY_GNAME so going to stop here...${DEFAULT_COLOR}"
+ return 1
+ fi
+}
+
+#---------------------------------------------------------------------
+## @param system group
+##
+## Creates group (if group has been defined).
+## @return 0 if success (or group already exists).
+## @return 1 if failed (or group has not been defined).
+##
+#---------------------------------------------------------------------
+function create_group() {
+
+# sanity_checks
+
+ if ! exists_group "$1" ; then
+ debug "libgrimoire" "create_group() - $1 not defined!"
+ return 0 # should return 0 to gracefully continue casting.
+ fi
+
+ local GROUP_GID=`get_gid_for_group $1`
+
+ debug "libgrimoire" "create_group() - $1, GID=$GROUP_UID "
+
+ groupadd -g $GROUP_GID $1 > /dev/null 2>&1
+
+ local GROUPADD_RETURN=$?
+ debug "libgrimoire.create_group()" "groupadd return code was:
$GROUPADD_RETURN"
+
+ if [ $GROUPADD_RETURN == 0 ] ; then
+ message "${MESSAGE_COLOR}The group name $1 with id $GROUP_GID has been
created!${DEFAULT_COLOR}"
+ elif [ $GROUPADD_RETURN == 4 ] ; then
+ message "${MESSAGE_COLOR}The group id $GROUP_GID already exists,
stopping here...${DEFAULT_COLOR}"
+ return 1
+ elif [ $GROUPADD_RETURN == 9 ] ; then
+ message "${MESSAGE_COLOR}The group name $1 already exists, so
continuing...${DEFAULT_COLOR}"
+ return 0
+ else
+ debug "libgrimoire.create_group()" "groupadd fails with strange code :
$GROUPADD_RETURN"
+ message "${MESSAGE_COLOR}Something went wrong with adding the group $1
with gid $GROUP_GID"
+ message "so going to stop here...${DEFAULT_COLOR}"
+ return 1
+ fi
+}
+
+
+#---------------------------------------------------------------------
+## @param gid
+##
+## @Stdout group name
+## returns that name assigned to a group id.
+##
+#---------------------------------------------------------------------
+function get_group_name() {
+
+ if grep -q ":$1:" $GROUP_LIST; then
+ grep ":$1:" $GROUP_LIST | cut -d : -f1
+ fi
+
+}
+
+
+#---------------------------------------------------------------------
+## @param system account
+##
+## @Stdout group ids
+## Return list of group id's assigned to account name.
+## All except primary
+##
+#---------------------------------------------------------------------
+function get_gids_for_account() {
+
+ if grep -q "^$1:" $ACCOUNT_LIST; then
+ ENTRY=`grep "^1:" $ACCOUNT_LIST`
+ i=4
+ while [[ `echo $ENTRY | cut -d : -f$i` ]] ; do
+ NEW=`echo $ENTRY | cut -d : -f$i`
+ GROUPS="$GROUPS $NEW"
+ let i++
+ done
+ fi
+ return $GROUPS
+}
+
+
+#---------------------------------------------------------------------
+## @param system account
+## @return 0 if exists
+## @return 1 if not
+##
+#---------------------------------------------------------------------
+function exists_account() {
+
+ grep -q "^$1:" $ACCOUNT_LIST
+
+}
+
+
+#---------------------------------------------------------------------
+## @param named system account
+## @Stdout UID
+## Outputs the UID for the named system account
+##
+#---------------------------------------------------------------------
+function get_uid_for_account() {
+
+ if grep -q "$1:" $ACCOUNT_LIST; then
+ grep "^$1:" $ACCOUNT_LIST | cut -d : -f2
+ fi
+
+}
+
+#---------------------------------------------------------------------
+## @param named system group
+## @Stdout GID
+## Outputs the GID for the named system group
+##
+#---------------------------------------------------------------------
+function get_gid_for_group() {
+
+ if grep -q "$1:" $GROUP_LIST; then
+ grep "^$1:" $GROUP_LIST | cut -d : -f2
+ fi
+
+}
+
+#---------------------------------------------------------------------
+## @param named system account
+## @Stdout GID
+##
+## Outputs the GID for the named system account
+##
+#---------------------------------------------------------------------
+function get_primary_gid_for_account() {
+
+ if grep -q "$1:" $ACCOUNT_LIST; then
+ grep "^$1:" $ACCOUNT_LIST | cut -d : -f3
+ fi
+
+}
+
+#---------------------------------------------------------------------
+## @param system group
+## @return 0 if exists
+## @return 1 if not
+##
+#---------------------------------------------------------------------
+function exists_group() {
+
+ grep -q "^$1:" $GROUP_LIST
+
+}
+
+#---------------------------------------------------------------------
+## @License
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#---------------------------------------------------------------------
+
diff --git a/libcompat b/libcompat
new file mode 100755
index 0000000..b654e6e
--- /dev/null
+++ b/libcompat
@@ -0,0 +1,67 @@
+# ignore sub_depends if not supported by sorcery
+declare -f sub_depends &> /dev/null ||
+{
+ function sub_depends() {
+ :
+ }
+
+ function depends() {
+ [[ $1 == "-sub" ]] && shift 2
+ real_depends "$@"
+ }
+
+ function optional_depends() {
+ [[ $1 == "-sub" ]] && shift 2
+ real_optional_depends "$@"
+ }
+}
+
+# ignore force_depends if not supported by sorcery
+declare -f force_depends &> /dev/null ||
+function force_depends() {
+ :
+}
+
+#-------------------------------------------------------------------------
+## Grimoire gaze depends alternative
+## Uses gaze depends if the internal sorcery function isn't available
+#-------------------------------------------------------------------------
+declare -f show_up_depends &> /dev/null ||
+function show_up_depends() {
+ gaze -q depends --fast "$@"
+}
+
+# fall back to optional_depends if suggest_depends isn't implemented
+# OR fall back to true - this is needed to avoid some circular dependencies
+# see #13244 for an example
+if declare -f suggest_depends &> /dev/null; then
+ function suggest_depends_2() {
+ suggest_depends "$@"
+ }
+else
+ function suggest_depends() {
+ optional_depends "$@"
+ }
+
+ function suggest_depends_2() {
+ true
+ }
+fi
+
+# fall back to depends if runtime_depends isn't implemented
+declare -f runtime_depends &> /dev/null ||
+function runtime_depends() {
+ depends "$@"
+}
+
+declare -f is_depends_enabled &>/dev/null ||
+function is_depends_enabled() {
+ local dep_status
+ if [[ $3 ]] ; then
+ dep_status=$DEPENDS_STATUS
+ else
+ dep_status=$(hash_get uncommitted_hash $1)
+ [[ $dep_status ]] || dep_status=$DEPENDS_STATUS
+ fi
+ grep -q "^[[:space:]]*$1:$2:on" $dep_status
+}
diff --git a/libgcc b/libgcc
new file mode 100755
index 0000000..7a516f9
--- /dev/null
+++ b/libgcc
@@ -0,0 +1,106 @@
+#!/bin/bash
+#---------------------------------------------------------------------
+##
+## @Synopsis Set of functions for dealing with the problem of having to
+## @Synopsis use different version of the gcc compilers.
+##
+## The basic usage is as follows:
+## <pre>
+## - If a spell works with the latest version of gcc, do nothing.
+## - To change the compiler version for a spell, add a GCC_VERSION field
+## to the spells DETAILS specifying major.minor version of gcc it needs,
+## e.g. GCC_VERSION=3.4
+## - add a 'depends gccXX' to the spell where XX == majorminor,
+## e.g. 'depends gcc34'
+## - add 'invoke_gcc' to the top of PRE_BUILD if the spell has a
+## custom PRE_BUILD file
+## </pre>
+##
+## @Implementation These functions were added to allow the use of
+## @Implementation several versions of gcc in parallel.
+##
+##
+## @Copyright Copyright 2005 by the Source Mage Team
+##
+##
+#---------------------------------------------------------------------
+
+
+#---------------------------------------------------------------------
+## @param gcc version
+## @return 0 if that gcc version is being used
+## @return 1 otherwise
+#---------------------------------------------------------------------
+function use_gcc() {
+
+ gcc -dumpversion | grep -q $(esc_str $1) > /dev/null
+
+}
+
+#---------------------------------------------------------------------
+## @param new path to add
+## @param old path
+## @Stdout new path
+## Echos the old path with new path prepended, separated with a ':'
+#---------------------------------------------------------------------
+function gcc_prepend_path() {
+
+ if test -z $2
+ then echo $1
+ else echo $1:$2
+ fi
+
+}
+
+
+#---------------------------------------------------------------------
+## @param path
+##
+## Alters the environment so that the gcc in the specified directory
+## will be used for compiling
+##
+#---------------------------------------------------------------------
+function gcc_add_paths() {
+
+ export PATH=$( gcc_prepend_path $1/bin $PATH )
+ export LD_LIBRARY_PATH=$( gcc_prepend_path $1/lib $LD_LIBRARY_PATH )
+ export LD_RUN_PATH=$( gcc_prepend_path $1/lib $LD_RUN_PATH )
+ export INFOPATH=$( gcc_prepend_path $1/info $INFOPATH )
+ export CPPFLAGS="-I $1/include $CPPFLAGS"
+
+}
+
+
+#---------------------------------------------------------------------
+##
+## Determines if the spell specifies a gcc version to use. If so, it
+## alters the environment so that that gcc version is used for compilation.
+##
+#---------------------------------------------------------------------
+function invoke_gcc() {
+
+ if [[ "$GCC_VERSION" ]] && ! use_gcc $GCC_VERSION; then
+ gcc_add_paths /opt/gcc${GCC_VERSION//.}
+ echo "Overriding gcc version: `gcc -dumpversion`"
+ fi
+
+}
+
+
+#---------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#---------------------------------------------------------------------



  • [SM-Commit] GIT changes to master binary grimoire by George Sherwood (3f8edd3fc622e2a98f201f14a0529e3a3bfd4138), George Sherwood, 10/21/2008

Archive powered by MHonArc 2.6.24.

Top of Page