Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Ismael Luceno (b1f08e0907a0eb7470fa148dd8cf120083e19e5a)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Ismael Luceno <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Ismael Luceno (b1f08e0907a0eb7470fa148dd8cf120083e19e5a)
  • Date: Tue, 5 Feb 2019 23:56:50 +0000

GIT changes to master sorcery by Ismael Luceno <ismael AT sourcemage.org>:

install | 23 ++++------
usr/sbin/confmeld | 3 -
var/lib/sorcery/modules/libcodex | 43 ++++++++++---------
var/lib/sorcery/modules/libgcc | 6 ++
var/lib/sorcery/modules/liblock | 45 ++++++++------------
var/lib/sorcery/modules/libmisc | 81
+++++++++++++++++-------------------
var/lib/sorcery/modules/liboscompat | 36 ++++++++++++++++
7 files changed, 136 insertions(+), 101 deletions(-)

New commits:
commit b1f08e0907a0eb7470fa148dd8cf120083e19e5a
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libcodex: Remove usage of character classes

Not available in busybox.

commit 239f482e102974a7eab7b4be8b6fb58040be50c4
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libcodex: Simplify codex_cache_spell_lookup

commit d71e14821709f6eabf1441a86c07155e1c986260
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libcodex: Make codex_check_cache take multiple arguments

commit f2a07e7e321e28d616b8bab98914f29812e7dedf
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

liblock: Streamline trylock_resources

commit 617d3f04f966ca19d67a63e6e08585a1ba57d998
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

liblock: Simplify global_clean_resources

Compatible with non-GNU implementations of find.

commit 2cce8ad30220b492088dd42f084416db5ae1e20e
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libmisc: Introduce debug_stream

Allows simplified logging from a command's output.

commit 6bd4db4174e0fcf8d43845374b5b6b36a4f5b6ed
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

confmeld: Remove usage of "-delete" and "-empty" find flags

For compatibility with non-GNU implementations.

commit e559097e4a1117d9bbe0b1e3c7662f319229b314
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libmisc: Fix missing specdir in set_architecture

commit bbad10b10acb28ec292e6ca6d7d95437370840b6
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libgcc: Fix GCC version check

Contemplate the case of $CC being set and also prefixes.

commit 8e92e5784c02fe019eefc7020d840dc7f5b190c6
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

liboscompat: Move install replacement to a library

And implement "-d" flag.

commit da7abed626c88b22b7b619faa57c2db9732f77f1
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

install: Fix installation without /usr/bin/install

It may be in /bin, or it may be unavailable.

commit e0e2ef9886c40b77c597d366277d166f09270458
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

install: Simplify find usage, make POSIX-compliant

commit ab7edf449cb7c2000613170bc466638a6c84086c
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libmisc: Simplify setting of $ARCHITECTURE[@]

commit 615b00c28da7e62b0b31098b0229b0f9a04de0d2
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libmisc: Implement one-shot specfile selection

commit bba0a8359eba30baddbdcb0a5ff19e557aee0552
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libbmisc: Simplify architecture selection

commit 5bbf95c2996602476efafabeeb09d60a883beb5e
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libmisc: Fix support for find without "-quit"

Other implementations lack it, e.g.: Busybox, NetBSD, OpenBSD.

Instead of doing a feature test, we can just read the first result.

diff --git a/install b/install
index e1dcf2b..9f9e2e2 100755
--- a/install
+++ b/install
@@ -1,21 +1,20 @@
#!/bin/bash

+. ./var/lib/sorcery/modules/liboscompat
+
#
# For unknown reasons `$filter=...; find . $filter` doesn't work, so this
function
# encapsulates the filters necessary to strip CVS files and EMACS temporary
files
function install__find_non_volatile() {
- find "$@" -not -type d -and -not -path '*CVS*' -and -not -name '.#*' -and
-not -name '*~' -and -not -path '*.svn*' -and -not -path '*.arch-id*'
+ find "$@" \( -name CVS -o -name .svn -o -name .arch-id \) -prune -o \
+ \! -name '.#*' \! -name '*~' \
+ \! -type d
}
function install__find_for_log() {
- find "$@" -not -path '*CVS*' -and -not -name '.#*' -and -not -name '*~'
-and -not -path '*.svn*' -and -not -path '*.arch-id*'|
- while read line; do echo /$line; done
+ install__find_non_volatile | sed 's:^:/:'
}

-if [[ $1 ]] ; then
- INSTALL_ROOT=$1
-else
- INSTALL_ROOT=""
-fi
+INSTALL_ROOT="$1"
# First clean out all libraries.
echo "Cleaning out all old sorcery libraries..."
SORCERY_LIBS=${INSTALL_ROOT}/var/lib/sorcery/modules
@@ -32,7 +31,7 @@ echo "Installing scripts and libraries"
install__find_for_log etc usr/sbin var/lib >> $SORCERY_INSTALL_LOG
install__find_non_volatile etc usr/sbin var/lib | (
while read SCRIPT; do
- /usr/bin/install --owner=root --group=root --mode=755 -pD "${SCRIPT}"
"${INSTALL_ROOT}/${SCRIPT}"
+ install -o root -g root -m 755 -p -D "${SCRIPT}"
"${INSTALL_ROOT}/${SCRIPT}"
done
)

@@ -45,18 +44,18 @@ install__find_non_volatile usr/share/man | (
while read DOC; do
# remove incorrectly installed manuals
rm -f $INSTALL_ROOT/${DOC/share\/}
- /usr/bin/install --owner=root --group=root --mode=644 -pD "${DOC}"
"${INSTALL_ROOT}/${DOC}"
+ install -o root -g root -m 644 -p -D "${DOC}" "${INSTALL_ROOT}/${DOC}"
gzip --best -f "${INSTALL_ROOT}/${DOC}"
done
)

# Install the GNU General Public License
mkdir -p ${INSTALL_ROOT}/usr/share/doc
-/usr/bin/install --owner=root --group=root --mode=644 -pD "COPYING"
"${INSTALL_ROOT}/usr/share/doc/sorcery/COPYING"
+install -o root -g root -m 644 -p -D "COPYING"
"${INSTALL_ROOT}/usr/share/doc/sorcery/COPYING"
echo /usr/share/doc/sorcery/COPYING >> $SORCERY_INSTALL_LOG

# Install the ChangeLog
-/usr/bin/install --owner=root --group=root --mode=644 -pD "ChangeLog"
"${INSTALL_ROOT}/usr/share/doc/sorcery/ChangeLog"
+install -o root -g root -m 644 -p -D "ChangeLog"
"${INSTALL_ROOT}/usr/share/doc/sorcery/ChangeLog"
echo /usr/share/doc/sorcery/ChangeLog >> $SORCERY_INSTALL_LOG

# Install the run_compiler script with the same names as gcc
diff --git a/usr/sbin/confmeld b/usr/sbin/confmeld
index 5e42d8f..a939178 100755
--- a/usr/sbin/confmeld
+++ b/usr/sbin/confmeld
@@ -185,7 +185,8 @@ function override_changed_config_menu()
#--------------------------------------------------------------------
function final_cleanup()
{
- find $CONFIG_STAGE_DIRECTORY -mindepth 1 -maxdepth 2 -type d -empty -delete
+ find "$CONFIG_STAGE_DIRECTORY" -mindepth 1 -maxdepth 2 \
+ -type d -exec rmdir {} + 2>/dev/null
}

#--------------------------------------------------------------------
diff --git a/var/lib/sorcery/modules/libcodex
b/var/lib/sorcery/modules/libcodex
index 12e4268..b7b3e1d 100755
--- a/var/lib/sorcery/modules/libcodex
+++ b/var/lib/sorcery/modules/libcodex
@@ -358,7 +358,7 @@ function codex_set_grimoires() {
#---------------------------------------------------------------------
function codex_get_all_grimoires() {
debug "libcodex" "codex_get_all_grimoires()"
- echo "${GRIMOIRE_DIR[*]}" | tr '[:blank:]' '\n'
+ echo "${GRIMOIRE_DIR[*]}" | tr '[\t ]' '\n'
return $?
}

@@ -811,38 +811,43 @@ function find_providers() {
##
#---------------------------------------------------------------------
function codex_cache_spell_lookup() {
- local SECTION
local spell="$1"
shift
- while [ $# -gt 0 ] ; do
- debug "libcodex" "looking up $spell in ${1}'s cache"
- codex_check_cache $1
- SECTION=`grep -m 1 "^$spell " $1/$SPELL_INDEX_FILE | cut -d' ' -f2`
- [[ $SECTION ]] && echo "$SECTION/$spell" && return
- shift
- done
- return 1
+ debug "libcodex" "looking up $spell in the caches of: $*"
+ codex_check_cache "$@"
+ awk -vidx="/$SPELL_INDEX_FILE" -vOFS=/ -vspell="$spell" '
+ BEGIN { for (i in ARGV) ARGV[i] = ARGV[i] idx }
+ found = $1 == spell { print $2, $1; exit }
+ END { exit !found }
+ ' "$@"
}


#---------------------------------------------------------------------
## @param grimoire-path
+## @param [grimoire-path ...]
## @Stdout error if cache doesn't exist after creation
## Checks that the cache exists. if it doesn't exist, make it.
## If it still doesn't exist, the barf an error
##
#---------------------------------------------------------------------
function codex_check_cache() {
- codex_is_canonicalized $1 || return 1
- [[ -x $1 ]] || return 1
-
- if ! [ -f $1/$SPELL_INDEX_FILE ] || ! [ -f $1/$PROVIDE_INDEX_FILE ]; then
+ ret=0
+ while ! [ $# = 0 ]; do
+ if ! codex_is_canonicalized "$1" || ! [ -x "$1" ]; then
+ ret=1
+ continue
+ fi
+ if ! [ -f "$1/$SPELL_INDEX_FILE" ] || ! [ -f "$1/$PROVIDE_INDEX_FILE" ];
then
codex_create_cache
- fi
- if ! [ -f $1/$SPELL_INDEX_FILE ] || ! [ -f $1/$PROVIDE_INDEX_FILE ]; then
- error_message "${PROBLEM_COLOR}Eeek, $1 is not a
grimoire!${DEFAULT_COLOR}"
- exit 1
- fi
+ fi
+ if ! [ -f "$1/$SPELL_INDEX_FILE" ] || ! [ -f "$1/$PROVIDE_INDEX_FILE" ];
then
+ error_message "${PROBLEM_COLOR}Eeek, $1 is not a
grimoire!${DEFAULT_COLOR}"
+ exit 1
+ fi
+ shift
+ done
+ return "$ret"
}

#---------------------------------------------------------------------
diff --git a/var/lib/sorcery/modules/libgcc b/var/lib/sorcery/modules/libgcc
index f3d5b8a..7c1f622 100755
--- a/var/lib/sorcery/modules/libgcc
+++ b/var/lib/sorcery/modules/libgcc
@@ -34,8 +34,12 @@
## @return 1 otherwise
#---------------------------------------------------------------------
function real_using_gcc() {
+ : ${CC:=gcc}
+ # Check if it's GCC we're using
+ case "$CC" in *gcc);; *) return 1;; esac
+
local needed_version=${1%+}
- local installed_version=$(gcc -dumpversion)
+ local installed_version=$("$CC" -dumpversion)

if [[ "$needed_version" == "$1" ]]; then
grep -qE "^$(esc_str $needed_version)(\.0)*$" <<< "$installed_version"
diff --git a/var/lib/sorcery/modules/liblock b/var/lib/sorcery/modules/liblock
index 8dc6676..ad012ff 100755
--- a/var/lib/sorcery/modules/liblock
+++ b/var/lib/sorcery/modules/liblock
@@ -78,17 +78,16 @@ trylock_resources()

debug "trylock_resources" "lockfile=${lockfile}"

- [[ -d $LOCK_DIR ]] || mkdir -p "$LOCK_DIR"
-
- if [[ -d ${lockfile} ]] || ! mkdir "${lockfile}" 2>/dev/null; then
- # we try to remove stale locks here and try again
- sleep 0.1
- global_clean_resources
- if ! mkdir "${lockfile}" 2>/dev/null; then
- return 1
- fi
+ [ -e "$lockfile/$$" ] && return
+
+ mkdir -p "$LOCK_DIR"
+ if ! mkdir "${lockfile}" 2>/dev/null; then
+ # we try to remove stale locks here and try again
+ sleep 0.1
+ global_clean_resources
+ mkdir "${lockfile}" 2>/dev/null || return
fi
- [[ -e ${lockfile}/$$ ]] || ln -s /proc/$$ "${lockfile}/$$"
+ ln -sf /proc/$$ "${lockfile}/$$"
return 0
}

@@ -179,22 +178,16 @@ clean_resources()
#---------------------------------------------------------------------
global_clean_resources()
{
- if [ -d "${LOCK_DIR}" ]; then
- # we remove old locks (>1 minute) that are not owned by any process.
- find "${LOCK_DIR}" -maxdepth 1 -mindepth 1 -mmin +1 -type d -empty -exec
rmdir {} \;
-
- # we remove locks that are owned by dead processes
- find "${LOCK_DIR}" -maxdepth 2 -mindepth 2 | \
-
- while read file; do
- # check if the process still exist (we use procfs mounted on /proc)
- if [ ! -d "${file}" ]; then
- debug "global_clean_resources" "removing stale lock ${file}"
- rm -f "${file}" 2>/dev/null &&
- rmdir $(smgl_dirname "${file}") 2>/dev/null
- fi
- done
- fi
+ [ -d "$LOCK_DIR" ] || return 0
+
+ # Release locks from dead processes
+ find -L "$LOCK_DIR" -mindepth 2 -maxdepth 2 \
+ -type l -print -exec rm -f {} + |
+ debug_stream global_clean_resources 'removing stale lock'
+ # Try to clean up empty locks
+ 2>/dev/null \
+ find "$LOCK_DIR" -d -mindepth 1 -maxdepth 1 -type d \
+ -exec rmdir {} +
}

#---------------------------------------------------------------------
diff --git a/var/lib/sorcery/modules/libmisc b/var/lib/sorcery/modules/libmisc
index 7389534..064c17f 100755
--- a/var/lib/sorcery/modules/libmisc
+++ b/var/lib/sorcery/modules/libmisc
@@ -195,6 +195,24 @@ function error_message() {

#---------------------------------------------------------------------
## @param type
+##
+## Enters debug messages from stdin if the type of debug message != 'no'
+##
+## The 'type' is usually the name of the file the debug statement
+## comes from. i.e. DEBUG_liblock, DEBUG_libsorcery, DEBUG_cast etc.
+##
+#---------------------------------------------------------------------
+debug_stream() {
+ local debugVar="DEBUG_${1//[!a-zA-Z0-9_]/_}"
+ if ! [ "$DEBUG" ] || [ "${!debugVar}" = "no" ]; then
+ cat > /dev/null
+ else
+ awk -vpfx="$1($$): $2:" '{print pfx, $0; fflush()}' >> "$DEBUG"
+ fi
+}
+
+#---------------------------------------------------------------------
+## @param type
## @param message
##
## Enters a debug message if the type of debug message != 'no'
@@ -1429,63 +1447,42 @@ function set_architecture() {

$STD_DEBUG
local specdir
- local i j
+ local i
unset SPECFILE

# If given an argument, treat as the architecture to use
local arch=${1}

# If no arch is specified, see if this is a cross-install, if so, set arch
to
- # the target arch
- if [[ ! $arch ]] &&
- [[ $CROSS_INSTALL == on ]] &&
- [[ $TARGET ]]
- then
- debug "libmisc" "set_architecture: using cross-install's target arch"
- arch=${arch:-$TARGET}
- fi
-
- # If no arch given and this isn't a cross-install, then default to the
ARCHITECTURE var
- if ! [[ $arch ]] ; then
- arch=$ARCHITECTURE
- fi
+ # the target arch; otherwise default to the ARCHITECTURE var
+ [ "$CROSS_INSTALL" = on ] || TARGET=
+ : ${arch:=${TARGET:-$ARCHITECTURE}}

# Find the specfile to use
- local find_compat=0
- find --version|grep -q 'version 4\.1\(\.\|$\)' && find_compat=1
- for specdir in ${ARCH_SPECS[@]} ; do
- if [[ $find_compat == 1 ]] ; then
- # older find still exists run in slower compatibility mode
- SPECFILE=$(find ${specdir} -perm -400 -type f -name "$arch" -print
2>/dev/null)
- else
- # -L so symlinks work, -type f so it won't match dirs, -quit so it
- # stops searching when it finds the answer
- SPECFILE=$(find -L ${specdir} -perm -400 -type f -name "$arch" -print
-quit 2>/dev/null)
- fi
- [ $SPECFILE ] && break
- done
- if [[ ! $SPECFILE ]] ; then
- message "${PROBLEM_COLOR}Cannot find arch spec for $arch!"
- message "Reverting to null!"
- message "Please run sorcery afterwards and pick another
architecture!$DEFAULT_COLOR"
- echo
- sleep 2
- SPECFILE=$(find -L ${specdir} -perm -400 -type f -name "null" -print
-quit 2>/dev/null)
- fi
+ SPECFILE=$(find -L "${ARCH_SPECS[@]}" \( -name "$arch" -o -name null \) \
+ -perm -400 -type f 2>/dev/null |
+ awk '! /[/]null$/ { exit } END { print }')
+ case "$SPECFILE" in
+ */null)
+ message "${PROBLEM_COLOR}Cannot find arch spec for $arch!"
+ message "Reverting to null!"
+ message "Please run sorcery afterwards and pick another
architecture!$DEFAULT_COLOR"
+ echo
+ sleep 2
+ esac
debug "libmisc" "set_architecture: SPECFILE=$SPECFILE"

# turn the path into an array, but remove $specdir from the start first
unset SMGL_COMPAT_ARCHS
+ specdir="${SPECFILE%/*/*/*/*/*}"
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
+ # Reverse the array so that the most specific arch is first
+ ARCHITECTURE=(
+ $(for i in "${SMGL_COMPAT_ARCHS[@]}"; do echo "$i"; done | tac)
+ )

- source "$SPECFILE"
+ source "$SPECFILE"
}

#---------------------------------------------------------------------
diff --git a/var/lib/sorcery/modules/liboscompat
b/var/lib/sorcery/modules/liboscompat
new file mode 100644
index 0000000..5bc110e
--- /dev/null
+++ b/var/lib/sorcery/modules/liboscompat
@@ -0,0 +1,36 @@
+#!/bin/bash
+#---------------------------------------------------------------------
+##
+## @Synopsis Functions for OS compatibility.
+##
+##
+## This file contains functions that improve system compatibility.
+##
+##
+## @Copyright Copyright 2019 by the Source Mage Team
+##
+#---------------------------------------------------------------------
+
+# basic install replacement
+if ! type install >/dev/null 2>/dev/null; then
+ install() {
+ local o=0 g=0 m=644 d
+ while case "$1" in
+ -o|-g|-m) eval ${1#-}'="$2"'; shift;;
+ -p|-D) ;; # always
+ -d) eval ${1#-}=1 ;;
+ *) false ;;
+ esac
+ do shift; done
+ if [ "$d" ]; then
+ mkdir -p "$1"
+ else
+ mkdir -p "${2%/*}"
+ rm -f "$2"
+ cp "$1" "$2"
+ chmod "$m" "$2"
+ chown "$o:$g" "$2"
+ touch -r "$1" "$2"
+ fi
+ }
+fi



  • [SM-Commit] GIT changes to master sorcery by Ismael Luceno (b1f08e0907a0eb7470fa148dd8cf120083e19e5a), Ismael Luceno, 02/05/2019

Archive powered by MHonArc 2.6.24.

Top of Page