~sourcemage/sorcery

862ab68831eb6e003f547d8d2e435d015fa31131 — Remko van der Vossen 4 months ago 3a72b84 devel-smgl-base
Allow base spell to be configured
M ChangeLog => ChangeLog +4 -0
@@ 1,3 1,7 @@
2024-01-06 Remko van der Vossen <wich@sourcemage.org>
	* sorcery, cast, libsorcery, libmisc: allow base spell to be
	configured

2023-11-13 Thomas Orgis
	* resurrect: fix old version location if /var/cache/sorcery is a symlink


M etc/sorcery/config => etc/sorcery/config +4 -1
@@ 53,7 53,7 @@ SHOW_GAZE_SHORT_QUERY=${SHOW_GAZE_SHORT_QUERY:=on}
                 NICE=${NICE:=+10}
                UMASK=${UMASK:=0022}
         SORCERY_PATH=${SORCERY_PATH:-"/usr/sbin"}
FORCE_BASESYSTEM_DEPENDS=${FORCE_BASESYSTEM_DEPENDS:-off}
FORCE_SORCERY_BASE_DEPENDS=${FORCE_SORCERY_BASE_DEPENDS:-off}

            LDD_CHECK=${LDD_CHECK:=on}
           FIND_CHECK=${FIND_CHECK:=on}


@@ 78,6 78,9 @@ FORCE_BASESYSTEM_DEPENDS=${FORCE_BASESYSTEM_DEPENDS:-off}
         ARCHITECTURE=${ARCHITECTURE:=i386}
        OPTIMIZATIONS=${OPTIMIZATIONS:=strip}

         SORCERY_BASE=${SORCERY_BASE:=basesystem}
          SYSTEM_BASE=${SYSTEM_BASE:=basesystem}

        COMPILE_CONFIG=${COMPILE_CONFIG:-/etc/sorcery/compile_config}
          ROOTS_CONFIG=${ROOTS_CONFIG:-/etc/sorcery/roots}
          MEDIA_CONFIG=${MEDIA_CONFIG:-/etc/sorcery/media}

M usr/sbin/cast => usr/sbin/cast +2 -2
@@ 70,7 70,7 @@ Optional Parameters:
                                need updates. Optional parameter same as
                                above.

-b  |  --force-base-dep         Force all spells to depend on basesystem
-b  |  --force-base-dep         Force all spells to depend on $SORCERY_BASE

       --from   directory       Specify an alternate for $SOURCE_CACHE



@@ 115,7 115,7 @@ process_parameters()  {
   -Z|--lazy-updates) get_option "$2" "$DEFAULT_LAZY_DEPENDS_UPDATE" \
                                 LAZY_DEPENDS_UPDATES n
                                                                     shift $n ;;
 -b|--force-base-dep)  FORCE_BASESYSTEM_DEPENDS=on;                  shift 1  ;;
 -b|--force-base-dep)  FORCE_SORCERY_BASE_DEPENDS=on;                shift 1  ;;
        -c|--compile)  COMPILE="$1";                                 shift 1  ;;
       -d|--download)  export  FORCE_DOWNLOAD="$1"; COMPILE="-c";    shift 1  ;;
              --from)  export  SOURCE_CACHE=$2;                      shift 2  ;;

M usr/sbin/gaze => usr/sbin/gaze +49 -10
@@ 1902,36 1902,75 @@ gaze_system_info()
  uname -a

  #---
  ## Section: BASESYSTEM
  ## Section: SORCERY BASE
  #---

  message -n "${PROBLEM_COLOR}--------------------{"
  message -n "Section:          BASESYSTEM"
  message -n "Section:        SORCERY BASE"
  message    "}--------------------${DEFAULT_COLOR}"

  #---
  ## Need a list of the base spell and ALL of it's DIRECT
  ## depends(what's in DEPENDS)
  ## base_system="$(gaze dependencies basesystem 2 | sed
  ## Need a list of the sorcery base spell and ALL of it's
  ## DIRECT depends(what's in DEPENDS)
  ## base_system="$(gaze dependencies ${SORCERY_BASE} 2 | sed
  ## -e "s/()//" -e 's/ (depends)//' -e 's/ (optional)//' | tr "\n" " " )"
  #---

  version="$(figure_installed basesystem)"
  section="$(codex_get_spell_section_name basesystem)"
  message -n "${MESSAGE_COLOR}${section}/basesystem:\t"
  version="$(figure_installed ${SORCERY_BASE})"
  section="$(codex_get_spell_section_name ${SORCERY_BASE})"
  message -n "${MESSAGE_COLOR}${section}/${SORCERY_BASE}:\t"
  message    "${QUERY_COLOR}${version}${DEFAULT_COLOR}\n"

  compute_installed_depends on_down_deps x on
  compute_installed_depends off_down_deps x off
  {
  for curr_spell in $(hash_get on_down_deps basesystem)
  for curr_spell in $(hash_get on_down_deps ${SORCERY_BASE})
  do
    version="$(figure_installed $curr_spell)"
    section="$(codex_get_spell_section_name $curr_spell)"
    message -n "${MESSAGE_COLOR}${section}/${curr_spell}:\t"
    message    "${QUERY_COLOR}${version}${DEFAULT_COLOR}"
  done
  for curr_spell in $(hash_get off_down_deps basesystem)
  for curr_spell in $(hash_get off_down_deps ${SORCERY_BASE})
  do
    version="$(figure_installed $curr_spell)"
    section="$(codex_get_spell_section_name $curr_spell)"
    message -n "${MESSAGE_COLOR}${section}/${curr_spell}:\t"
    message    "${QUERY_COLOR}${version} (disabled)${DEFAULT_COLOR}"
  done
  } | sort

  #---
  ## Section: SYSTEM BASE
  #---

  message -n "${PROBLEM_COLOR}--------------------{"
  message -n "Section:         SYSTEM BASE"
  message    "}--------------------${DEFAULT_COLOR}"

  #---
  ## Need a list of the sorcery base spell and ALL of it's
  ## DIRECT depends(what's in DEPENDS)
  ## base_system="$(gaze dependencies ${SYSTEM_BASE} 2 | sed
  ## -e "s/()//" -e 's/ (depends)//' -e 's/ (optional)//' | tr "\n" " " )"
  #---

  version="$(figure_installed ${SYSTEM_BASE})"
  section="$(codex_get_spell_section_name ${SYSTEM_BASE})"
  message -n "${MESSAGE_COLOR}${section}/${SYSTEM_BASE}:\t"
  message    "${QUERY_COLOR}${version}${DEFAULT_COLOR}\n"

  compute_installed_depends on_down_deps x on
  compute_installed_depends off_down_deps x off
  {
  for curr_spell in $(hash_get on_down_deps ${SYSTEM_BASE})
  do
    version="$(figure_installed $curr_spell)"
    section="$(codex_get_spell_section_name $curr_spell)"
    message -n "${MESSAGE_COLOR}${section}/${curr_spell}:\t"
    message    "${QUERY_COLOR}${version}${DEFAULT_COLOR}"
  done
  for curr_spell in $(hash_get off_down_deps ${SYSTEM_BASE})
  do
    version="$(figure_installed $curr_spell)"
    section="$(codex_get_spell_section_name $curr_spell)"

M usr/sbin/sorcery => usr/sbin/sorcery +33 -0
@@ 818,6 818,36 @@ custom_optimization_menu() {
  fi
}

set_base_spells()  {
  local RESULTS KEY rc

  while true ; do
    RESULTS=($(eval $DIALOG '--extra-label Adjust --inputmenu \
                            "Base Spells Menu" \
                            17 50 9 \
                            SORCERY_BASE "$SORCERY_BASE" \
                            SYSTEM_BASE "$SYSTEM_BASE"'))
    rc=$?
    [[ $rc == 0 ]] || [[ $rc == 1 ]] && break
    if (( ${#RESULTS[*]} != 3 )); then
      eval $DIALOG '--title "ERROR" --msgbox \
                   "ERROR: Specify a single spell." 8 40'
      continue
    fi
    KEY=${RESULTS[1]}
    case "$KEY" in
      SORCERY_BASE) SORCERY_BASE="${RESULTS[2]}"  ;;
      SYSTEM_BASE) SYSTEM_BASE="${RESULTS[2]}"  ;;
    esac
  done

  # only commit values if user selected "OK"
  if [ $rc == 0 ] ; then
    modify_local_config SORCERY_BASE "$SORCERY_BASE"
    modify_local_config SYSTEM_BASE "$SYSTEM_BASE"
  fi
}

integrity_fix_menu()  {

  local INT_TITLE="Integrity Checking Selection Menu"


@@ 1636,6 1666,7 @@ option_menu()  {
  local R_HELP="Enter the maximum rate for downloading"
  local T_HELP="Select compression program for logs and archives"
  local N_HELP="Enter the process priority (nice value) to use for sorcery"
  local P_HELP="Select system base spells"
  local U_HELP="Enter the permissions mask (umask value) to use for sorcery"
  local S_HELP="Sorcery development options (debugging)"
  local W_HELP="Enter maximum timeout (seconds) for summoning sources"


@@ 1665,6 1696,7 @@ option_menu()  {
                      "J"  "Dependency Following"     "$J_HELP" \
                      "M"  "Software Mirrors"         "$M_HELP" \
                      "O"  "Optimize Architecture"    "$O_HELP" \
                      "P"  "Base Spells"              "$P_HELP" \
                      "T"  "Compression Type"         "$T_HELP" \
                      "S"  "Sorcery Development"      "$S_HELP" \
                      "W"  "Summon Timeout Value"     "$W_HELP" \


@@ 1689,6 1721,7 @@ option_menu()  {
      C)  parallel_compilation_menu ;;
      M)  mirror_menu               ;;
      O)  optimize_architecture     ;;
      P)  set_base_spells           ;;
      S)  sorcery_devel_settings    ;;
      T)  set_compression_type      ;;
      W)  set_http_ftp_timeout      ;;

M usr/share/man/man8/cast.8 => usr/share/man/man8/cast.8 +1 -1
@@ 17,7 17,7 @@ and

.SH OPTIONS
.SS \fB\-b\fP, \fB\-\-force\-base\-dep\fP
Force all spells to depend on basesystem (used internally).
Force all spells to depend on sorcery base spell (used internally).

.SS \fB\-B\fP, \fB\-\-recast\-up\fP
Recasts all the spells that depend on the given spell(s) (and the ones

M var/lib/sorcery/modules/libdepends => var/lib/sorcery/modules/libdepends +8 -8
@@ 380,10 380,10 @@ compute_uninstalled_depends()
  local _idx
  local looked_at

  # this is a list of all spells basesystem depends on it is used to
  # avoid loops with the "everything depends on basesystem" feature
  # this is a list of all spells $SORCERY_BASE depends on it is used to
  # avoid loops with the "everything depends on $SORCERY_BASE" feature
  local base_deps
  base_deps=$(search_depends_status $DEPENDS_STATUS basesystem|cut -f2 -d:)
  base_deps=$(search_depends_status $DEPENDS_STATUS $SORCERY_BASE|cut -f2 -d:)

  # All specified spells are assumed to be not installed, or else -c and -r
  # would have to be specified all the time.


@@ 1611,12 1611,12 @@ private_add_depends()
    hash_append "$BACK_CAST_HASH" "$child" "$SPELL"
  done

  # force implied basesystem dependency in the depends tree
  if [[ $FORCE_BASESYSTEM_DEPENDS == on ]] &&
     [[ $SPELL != basesystem ]] &&
  # force implied $SORCERY_BASE dependency in the depends tree
  if [[ $FORCE_SORCERY_BASE_DEPENDS == on ]] &&
     [[ $SPELL != $SORCERY_BASE ]] &&
     ! real_list_find "$base_deps" "$SPELL"; then
    hash_append "$CAST_HASH" "$SPELL" "basesystem"
    hash_append "$BACK_CAST_HASH" "basesystem" "$SPELL"
    hash_append "$CAST_HASH" "$SPELL" "$SORCERY_BASE"
    hash_append "$BACK_CAST_HASH" "$SORCERY_BASE" "$SPELL"
  fi

  spells=( ${spells[*]} ${NEW_DEPENDS[*]}

M var/lib/sorcery/modules/libmisc => var/lib/sorcery/modules/libmisc +2 -2
@@ 1333,8 1333,8 @@ mk_tmp_dir_error() {

#---------------------------------------------------------------------
##
## 'which' is not in basesystem, heres our own simple version of it
## it should be just as fast as the real one.
## 'which' is not in sorcery base spells, heres our own simple version
## of it, it should be just as fast as the real one.
##
## @param executable to look for
## @param variable to return path in (pass by reference)

M var/lib/sorcery/modules/libsorcery => var/lib/sorcery/modules/libsorcery +4 -4
@@ 28,12 28,12 @@ update_sorcery_scripts() {
    #This section is to make sure that all sorcery dependencies are cast
    #Keep this outer if until basesystem is in the grimoires properly.
    #(2002/10/13)
    if [[ $(codex_find_spell_by_name basesystem) ]] ; then
      if ! spell_ok basesystem  ; then
        cast basesystem
    if [[ $(codex_find_spell_by_name ${SORCERY_BASE}) ]] ; then
      if ! spell_ok ${SORCERY_BASE}  ; then
        cast ${SORCERY_BASE}
      fi &&
      if [[ "$UPDATEFIX" == on ]] ; then
        cleanse --fix basesystem
        cleanse --fix ${SORCERY_BASE}
      fi
      if [[ $? != 0 ]] ; then
        query "Would you like to continue anyway?" y || return 1