~sourcemage/sorcery

7c86111336e4df7e5507855c78f90b4f16037001 — Thomas Orgis 6 months ago 796aae6 + 1b5f0d7 devel-sobukus-protection
Merge branch 'master' into devel-sobukus-protection
M ChangeLog => ChangeLog +23 -1
@@ 1,8 1,30 @@
2022-07-23 Ismael Luceno <ismael@sourcemage.org>
	* gaze: sreamlined show-spell-version functions

2022-03-14 Ismael Luceno <ismael@sourcemage.org>
	* api2: simplified calls to delve
	* scribe: fixed updating from tarballs

2022-03-10 Ismael Luceno <ismael@sourcemage.org>
	* api2: simplified run_install initial message

2022-02-24 Ismael Luceno <ismael@sourcemage.org>
	* url_git: simplified url_git_crack

2021-09-08 Ismael Luceno <ismael@sourcemage.org>
	* Makefile: simplified help rule

2021-09-08 Ismael Luceno <ismael@sourcemage.org>
	* Makefile: unified version bump target + make devinst dep on it

2021-08-28 Ismael Luceno <ismael@sourcemage.org>
	* protected: fixed libintl path

2021-02-26 Thomas Orgis <sobukus@sourcemage.org>
	* Makefile: added devinst target to mark installs from git checkout

2020-10-01 Thomas Orgis <sobukus@sourcemage.org>
	* protected: add /bin/login (!!)
	* protected: added /bin/login (!!)

2020-09-30 Thomas Orgis <sobukus@sourcemage.org>
	* libgrimoire: default to default size of tmpfs (half of RAM)

M Makefile => Makefile +10 -15
@@ 1,6 1,9 @@
AWK ?= awk

.MAKE.MAKEFILES ?= ${MAKEFILE_LIST}
.PHONY: help
help:
	@awk 'sub(/^#HELP: ?/, "")' $(MAKEFILE_LIST) $(.MAKE.MAKEFILES)
	@${AWK} 'sub(/^#HELP: ?/, "")' ${.MAKE.MAKEFILES}

BRANCH = stable
release = sorcery-$(BRANCH).tar.bz2


@@ 19,24 22,16 @@ $(release): $(ts-scm)
release: $(release)

#HELP:	bump      - Bump version
.PHONY: bump bump-stable bump-devel
bump-stable:
	git describe --tags | >etc/sorcery/version \
	awk -F'[^0-9]' -vOFS=. '{++$$NF;for(i=1;i<NF;i++)$$i=$$(i+1)}NF--'

bump-devel:
	date -u +%Y%m%d > etc/sorcery/version

bump: bump-$(BRANCH)
.PHONY: bump
bump:
	git describe --tags | >etc/sorcery/version ${AWK} -f bump.awk

devinst: install
	date +%Y%m%d | tr '\n' - > /etc/sorcery/version
	git show --oneline | head -n 1 | cut -f 1 -d ' ' >> /etc/sorcery/version
devinst: bump install

#HELP:	install   - Install sorcery
#HELP:	devinst   - Install with version vom active branch
#HELP:	devinst   - Install with version from active branch
#HELP:	uninstall - Uninstall sorcery
#HELP:	convert   - Convert from Pre 0.8.x grimoire to new codex format
script-targets = install uninstall convert
script-targets = install devinst uninstall convert
.PHONY: $(script-targets)
$(script-targets):; ./$@

A bump.awk => bump.awk +20 -0
@@ 0,0 1,20 @@
BEGIN {
	FS="[^0-9]"
	OFS="."
}

# bump stable
/^v/ && !/-[1-9][0-9]*-g[0-9a-f]+$/ {
	++$NF
	for (i = 1; i < NF; i++)
		$i = $(i+1)
	--NF
	print
	exit
}

# bump snapshot
{
	sub(/.*-g/, strftime("%Y%m%d-g", systime(), 1))
	print
}

M usr/sbin/gaze => usr/sbin/gaze +57 -115
@@ 1056,60 1056,58 @@ gaze_show_section()  {

#---------------------------------------------------------------------
##
## Given a section name, shows a table of spells in that section along
## with their grimoire version and installed verion
## @param Section
##
#---------------------------------------------------------------------
gaze_show_section_version_table()  {

   local  SPELLS=$(codex_get_spells_in_section $1)

   (

     echo  "Grimoire|Section|Spell|Grimoire Version|Installed Version"
     echo  "--------|-------|-----|----------------|-----------------"

     for  spell  in  $SPELLS;  do

       codex_set_current_spell  $spell                            &&
       local  INSTALLED=$(installed_version  $SPELL)               &&
       echo  "$GRIMOIRE_NAME|$SECTION|$SPELL|${VERSION:="-"}|${INSTALLED:="-"}"

     done

   ) | maybe_column -t -s "|"

}


#---------------------------------------------------------------------
##
## Shows the versions of spells, both the version in the grimoire and
## the version installed on the system.
## Shows a table with the installed version of a spell and the
## versions available in the specified grimoires.
## @param Grimoires  space-separated list of grimoires to check, or "-"
##                   to list the first found.
## @param Spell
## @param ...
##
#---------------------------------------------------------------------
gaze_show_spell_version_table()  {

  local grimoires installed_grimoire installed_ver
  grimoires=($1)
  shift
  [[ $# != 0 ]] || return 0
  (
    echo  "Grimoire|Section|Spell|Grimoire Version|Installed Version"
    echo  "--------|-------|-----|----------------|-----------------"

   for  SPELL  in  $@; do

      codex_set_current_spell  $SPELL                        &&
      local  INSTALLED=$(installed_version  $SPELL)           &&
      echo  "$GRIMOIRE_NAME|$SECTION|$SPELL|${VERSION:="-"}|${INSTALLED:="-"}"

    for SPELL in "$@"; do
      unset installed_grimoire
      if [[ $grimoires != - ]]; then
	codex_does_spell_exist $SPELL || continue
	if tablet_find_spell_dir "$SPELL" tablet; then
	  # TODO change this if it will be stored in the less volatile
	  #      state/packages file.
	  tablet_get_grimoire_name $tablet installed_grimoire
	fi
      fi
      for grimoire in "${grimoires[@]}"; do
        unset SECTION VERSION installed_ver
	if [[ $grimoire == - ]]; then
	  SPELL_DIRECTORY="$SPELL"
	else
	  SPELL_DIRECTORY=$(codex_cache_spell_lookup $SPELL $grimoire)
	fi &&
	codex_set_current_spell "$SPELL_DIRECTORY" || continue
	# XXX old tablet/state files may not hold installed_grimoire,
	#     so match the first.
	: ${installed_grimoire:=$GRIMOIRE_NAME}
	case "$VERSION:$GRIMOIRE_NAME" in
	  # Always match the installed-from grimoire
	  (*:"$installed_grimoire")
	    installed_ver="$(installed_version "$SPELL")"
	    ;&
	  (?*:*)
	    echo "$GRIMOIRE_NAME|${SECTION:--}|$SPELL|${VERSION:--}|${installed_ver:--}"
	    ;;
	esac
      done
    done

  ) | maybe_column -t -s "|"

  ) 2>/dev/null | maybe_column -t -s "|"
  echo
}


#---------------------------------------------------------------------
##
## Shows the versions of spells, both the version in the grimoire and


@@ 1119,42 1117,26 @@ gaze_show_spell_version_table()  {
##
#---------------------------------------------------------------------
gaze_show_version()  {

  local SPELLS_AND_SECTIONS=$@
  local SPELLS=
  local UNKNOWN=

  for  spell_or_section  in  $SPELLS_AND_SECTIONS;  do

    if  codex_find_spell_or_section_by_name  $spell_or_section;  then

      [  -n  "$CODEX_FOUND_SECTION"  ]                                      &&
      gaze_show_section_version_table  $CODEX_FOUND_SECTION  2>  /dev/null  &&
      echo " "

      [  -n  "$CODEX_FOUND_SPELL"  ]    &&
      SPELLS="$SPELLS $CODEX_FOUND_SPELL"

  local spells unknown
  for spell_or_section in "$@"; do
    if codex_find_spell_or_section_by_name "$spell_or_section"; then
      [ -n "$CODEX_FOUND_SECTION" ] &&
        gaze_show_spell_version_table - \
          $(codex_get_spells_in_section "$CODEX_FOUND_SECTION")
      [ -n "$CODEX_FOUND_SPELL" ] &&
      spells+=("$CODEX_FOUND_SPELL")
    else
      UNKNOWN="$spell_or_section $UNKNOWN"
      unknown+=("$spell_or_section")
    fi

  done

  [  -n  "$SPELLS"  ]  &&
  gaze_show_spell_version_table  $SPELLS  2>  /dev/null  &&
  echo " "


  if [[ -n $UNKNOWN ]]; then
    message "Unknown Spells or Sections"
    message "--------------------------"
    message "$UNKNOWN"
    return 1
  else
    return 0
  fi
  gaze_show_spell_version_table - "${spells[@]}"

  [[ ${#unknown[@]} == 0 ]] && return 0
  message "Unknown Spells or Sections"
  message "--------------------------"
  message "${unknown[*]}"
  return 1
}

#---------------------------------------------------------------------


@@ 1165,47 1147,7 @@ gaze_show_version()  {
##
#---------------------------------------------------------------------
gaze_show_versions()  {
  (
    echo "Grimoire|Section|Spell|Grimoire Version|Installed Version"
    echo "--------|-------|-----|----------------|-----------------"
    for SPELL in "$@"; do
      codex_does_spell_exist $SPELL || continue
      #saving them, since they will be overwritten later
      if tablet_find_spell_dir "$SPELL" tablet; then
	# TODO: change this if it will be stored in the less volatile state/packages file
	tablet_get_grimoire_name $tablet installed_grimoire
      fi
      installed=$(installed_version $SPELL)

      for grimoire in $(codex_get_all_grimoires)
      do
	if SPELL_DIRECTORY=$(codex_cache_spell_lookup $SPELL $grimoire)
	then
	  codex_set_current_spell $SPELL_DIRECTORY

	  # old states don't have the name stored so fall back to similar old
	  # broken behaviour where the first matching grimoire was used
	  [[ -z $installed_grimoire ]] && installed_grimoire=$GRIMOIRE_NAME

	  if [[ $GRIMOIRE_NAME == $installed_grimoire ]]
	  then
	    echo "$GRIMOIRE_NAME|$SECTION|$SPELL|$VERSION|${installed:="-"}"
	  else
            echo  "$GRIMOIRE_NAME|$SECTION|$SPELL|$VERSION|-"
	  fi
	else
	  # handle also (re)moved spells
	  smgl_basename "$grimoire" name
	  if [[ $name == $installed_grimoire ]]; then
            echo "$name|-|-|-|$installed"
	  else
            echo "$name|-|-|-|-"
	  fi
	fi
      done
    done
  ) | maybe_column -t -s "|"
  echo
  gaze_show_spell_version_table "$(codex_get_all_grimoires)" "$@"
}

#---------------------------------------------------------------------

M usr/sbin/scribe => usr/sbin/scribe +9 -5
@@ 281,11 281,15 @@ scribe_add_update_worker() {

  # download it
  local scribe_target scribe_type
  if [[ $add_or_update == update ]]; then
    url_download "$grim_name" "$from" "" scribe_target scribe_type
  else
    url_download "$grim_target" "$from" "" scribe_target scribe_type
  fi
  case "$add_or_update:$from" in
    # Special case to avoid re-downloading git repos
    (update:git*)
      url_download "$grim_name" "$from" "" scribe_target scribe_type
      ;;
    (*)
      url_download "$grim_target" "$from" "" scribe_target scribe_type
      ;;
  esac

  #check the success of the download
  if [ $? != 0 ]; then

M var/lib/sorcery/modules/build_api/api2 => var/lib/sorcery/modules/build_api/api2 +5 -15
@@ 85,13 85,8 @@ run_build_spell() {
      then
        invoke_installwatch
      fi                                    &&
      if [[ $OVERRIDE_GRIMOIRES ]]; then
        delve -g "$OVERRIDE_GRIMOIRES" $SPELL INSTALL &&
        delve -g "$OVERRIDE_GRIMOIRES" $SPELL INSTALL_EXTRAS
      else
        delve $SPELL INSTALL &&
        delve $SPELL INSTALL_EXTRAS
      fi &&
      delve ${OVERRIDE_GRIMOIRES+-g "$OVERRIDE_GRIMOIRES"} $SPELL INSTALL &&
      delve ${OVERRIDE_GRIMOIRES+-g "$OVERRIDE_GRIMOIRES"} $SPELL INSTALL_EXTRAS &&
      run_post_install                      || return 2
      run_transfer                          &&
      devoke_installwatch                   &&


@@ 211,14 206,9 @@ run_pre_install() {
run_install() {
  debug "build_api2" "Starting run_install()"

  if [[ $STAGED_INSTALL == on ]]; then
    message "${MESSAGE_COLOR}Installing"              \
            "${SPELL_COLOR}${SPELL}${MESSAGE_COLOR}"  \
            "into the stage${DEFAULT_COLOR}" >&3
  else
    message "${MESSAGE_COLOR}Installing" \
            "${SPELL_COLOR}${SPELL}${DEFAULT_COLOR}" >&3
  fi
  message "${MESSAGE_COLOR}Installing" \
          "${SPELL_COLOR}${SPELL}${DEFAULT_COLOR}" \
	  "(staging: $STAGED_INSTALL)" >&3

  if [ -f $S_PWD ] ; then
    cd "$(cat $S_PWD)"

M var/lib/sorcery/modules/libsecurity => var/lib/sorcery/modules/libsecurity +1 -1
@@ 58,7 58,7 @@ gaze_checkmd5() {
      SOURCE="$(ls $SOURCE_CACHE/$SOURCE* 2> /dev/null | cut -d'/' -f 5 | head -n 1)"
      if [ "$SOURCE" ]
      then
        if [[ -z $(echo ${SOURCE#$OLDSOURCE.} | egrep '^[0-9]{14}$') ]]
        if [[ -z $(echo ${SOURCE#$OLDSOURCE.} | grep -E '^[0-9]{14}$') ]]
        then
          APPEND="FUZZ s/$OLDSOURCE/$SOURCE/ "
        else

M var/lib/sorcery/modules/libsorcery => var/lib/sorcery/modules/libsorcery +1 -1
@@ 883,7 883,7 @@ unset_details()  {
    TEMP=${TEMP}${i}\\n
  done
  # not all SOURCE_* should be deleted (SOURCE_CACHE)
  VARS="$VARS $(echo -e $TEMP | egrep "^SOURCE[0-9]*(_URL|_GPG|_IGNORE)?$")"
  VARS="$VARS $(echo -e $TEMP | grep -E "^SOURCE[0-9]*(_URL|_GPG|_IGNORE)?$")"

  unset $VARS
}

M var/lib/sorcery/modules/url_handlers/url_git => var/lib/sorcery/modules/url_handlers/url_git +4 -6
@@ 33,12 33,10 @@
#---------------------------------------------------------------------
url_git_crack() {
  URL=$(url_strip_prefix "$1" git)
  GIT_ROOT=git://$(sed "s#\(^[^/]*[^:]*\):.*#\1#" <<< "$URL")
  local GIT_DIRECTORY_TAG=$(sed "s#^[^/]*[^:]*\(.*\)#\1#" <<< "$URL")
  GIT_DIRECTORY=$(cut -d : -f2 <<< "$GIT_DIRECTORY_TAG")
  local GIT_TAGNAME=$(cut -d : -f3 <<< "$GIT_DIRECTORY_TAG")
  GIT_TAG=${GIT_TAGNAME:=master}

  GIT_ROOT="git://${URL%%:*}"
  GIT_DIRECTORY=$(cut -d : -f2 <<< "$URL")
  GIT_TAG=$(cut -d : -f3 <<< "$URL")
  : ${GIT_TAG:=master}
}

#---------------------------------------------------------------------

M var/lib/sorcery/protected => var/lib/sorcery/protected +43 -38
@@ 1,34 1,33 @@
^/bin/awk$
^/bin/gawk$
^/bin/mawk$
^/bin/sed$
^/bin/basename$
^/bin/bash$
^/bin/login$
^/bin/cat$
^/bin/cp$
^/bin/cut$
^/bin/date$
^/bin/dirname$
^/bin/gawk$
^/bin/install$
^/bin/ln$
^/bin/login$
^/bin/ls$
^/bin/mawk$
^/bin/md5sum$
^/bin/mkdir$
^/bin/mount$
^/bin/mv$
^/bin/rm$
^/bin/rmdir$
^/bin/sed$
^/bin/sh$
^/bin/uname$
^/bin/ln$
^/bin/ls$
^/bin/dirname$
^/bin/uniq$
^/bin/tail$
^/bin/sleep$
^/bin/true$
^/bin/cut$
^/bin/mkdir$
^/bin/sort$
^/bin/basename$
^/bin/md5sum$
^/bin/install$
^/bin/tr$
^/usr/bin/install$
^/bin/su$
^/sbin/ldconfig$
^/bin/tail$
^/bin/tr$
^/bin/true$
^/bin/uname$
^/bin/uniq$
^/boot
^/etc/X11/XF86Config$
^/etc/X11/XftConfig\.gdkxftsaved$


@@ 37,47 36,53 @@
^/etc/grsec$
^/etc/httpsd$
^/etc/ppp
^/etc/protocols$
^/etc/pureftpd\.passwd$
^/etc/pureftpd\.pdb$
^/etc/resolv\.conf$
^/etc/security$
^/etc/services$
^/etc/skel
^/etc/sorcery/local
^/etc/ssh
^/etc/ssl/certs/
^/etc/sudoers$
^/etc/services$
^/etc/sysconfig/facilities$
^/etc/protocols$
^/lib/modules
^/lib/ld\.so\.1$
^/lib/ld-linux\.so\.2$
^/lib/ld-linux[-.]
^/lib/ld-musl-
^/lib/ld\.so
^/lib/libblkid\.so\.
^/lib/libintl\.so\.
^/lib/libc\.so
^/lib/libdl\.so
^/lib/libm\.so
^/lib/libpthread\.so
^/lib/libresolv\.so
^/lib/libhistory\.so\.
^/lib/libmount\.so\.
^/lib/libncurses\.so\.
^/lib/libncursesw\.so\.
^/lib/libreadline\.so\.
^/lib/modules
^/sbin/ldconfig$
^/usr/X11R6/lib/X11/app-defaults
^/usr/bin/as$
^/usr/bin/ld$
^/usr/bin/egrep$
^/usr/bin/file$
^/usr/bin/find$
^/usr/bin/grep$
^/usr/bin/egrep$
^/usr/bin/install$
^/usr/bin/ld$
^/usr/bin/make$
^/usr/bin/ranlib$
^/usr/bin/wget$
^/usr/lib/installwatch\.so$
^/usr/lib/libc\.so$
^/usr/lib/libc\.so
^/usr/lib/libguile-.*\.so\.
^/usr/lib/libguilereadline-.*\.so\.
^/usr/lib/libiconv\.so\.
^/usr/lib/libicu.*\.so\.
^/usr/lib/libintl\.so\.
^/usr/lib/libisl\.so\.
^/usr/share/httpd
^/usr/share/httpsd
^/usr/share/info/dir$
^/bin/mount$
^/lib/libmount\.so\.
^/lib/libreadline\.so\.
^/lib/libhistory\.so\.
^/lib/libncurses\.so\.
^/lib/libncursesw\.so\.
^/usr/lib/libisl\.so\.
^/usr/lib/libicu.*\.so\.
^/usr/lib/libguile-.*\.so\.
^/usr/lib/libguilereadline-.*\.so\.