Skip to Content.
Sympa Menu

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

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 (8d44d25f35cb44cb912f97c05c2f31dd7fa42f02)
  • Date: Tue, 25 Jul 2023 19:58:08 +0000

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

usr/sbin/alter | 10 +---
usr/sbin/delve | 82
++++++++++++++++-----------------
var/lib/sorcery/modules/build_api/api1 | 17 ++----
var/lib/sorcery/modules/build_api/api2 | 24 +++------
var/lib/sorcery/modules/libgrimoire | 9 ---
var/lib/sorcery/modules/libmisc | 17 ++++++
6 files changed, 75 insertions(+), 84 deletions(-)

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

libgrimoire: Simplify setting size in mk_source_dir

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

Implement logging by reusing file descriptors

Avoid opening files, references to /proc/self/fd/ may cause permission
issues when dropping privileges.

diff --git a/usr/sbin/alter b/usr/sbin/alter
index f15f1ba..2c52815 100755
--- a/usr/sbin/alter
+++ b/usr/sbin/alter
@@ -43,19 +43,17 @@ EOF
[ -n "$COM_DATA" ] && echo "$COM_DATA" > "$C_LOG"
message "${MESSAGE_COLOR}Altering...${DEFAULT_COLOR}"

+ reserve_fds VOYEUR_STDOUT VOYEUR_STDERR
if [ "$VOYEUR" == "on" -a -z "$SILENT" ]; then
- VOYEUR_STDOUT=/dev/stdout
- VOYEUR_STDERR=/dev/stderr
- else
- VOYEUR_STDOUT=/dev/null
- VOYEUR_STDERR=/dev/null
+ eval "exec $((VOYEUR_STDOUT))>&1 $((VOYEUR_STDERR))>&2"
fi

invoke_installwatch
(
echo "$@"
echo "$@" | bash
- ) 2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) > >(tee -a $C_LOG >
$VOYEUR_STDOUT)
+ ) 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
+ > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
devoke_installwatch
touch $IW_LOG $MD5_LOG $C_LOG_COMP
create_install_log $IW_LOG $INST_LOG
diff --git a/usr/sbin/delve b/usr/sbin/delve
index 1c1360a..5eb6b73 100755
--- a/usr/sbin/delve
+++ b/usr/sbin/delve
@@ -102,11 +102,16 @@ delve_log_helper() {
CASTFS_DBGLOG=${CASTFS_DBGLOG:="/tmp/sorcery/delve/$SPELL.iwdbglog"}
C_FIFO=${C_FIFO:="/dev/stdout"}
IW_LOG=${IW_LOG:="/tmp/sorcery/delve/$SPELL.iw"}
- VOYEUR_STDOUT=${VOYEUR_STDOUT:="/dev/stdout"}
- VOYEUR_STDERR=${VOYEUR_STDERR:="/dev/stderr"}
S_PWD=${S_PWD:="/tmp/sorcery/delve/$SPELL.pwd"}
touch $C_LOG
-
+ if [ -z "$VOYEUR_STDOUT" ]; then
+ reserve_fds VOYEUR_STDOUT
+ eval "exec $((VOYEUR_STDOUT))>&1"
+ fi
+ if [ -z "$VOYEUR_STDERR" ]; then
+ reserve_fds VOYEUR_STDERR
+ eval "exec $((VOYEUR_STDERR))>&2"
+ fi
}

#---------------------------------------------------------------------------
@@ -151,22 +156,20 @@ delve_build() {
debug "delve" "Running $FUNCNAME"
delve_is_valid_step BUILD 1 2 || return 1
delve_log_helper
- (
- run_build
- ) 3> >(tee -a $C_LOG >> /dev/stdout) \
- 2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
- > >(tee -a $C_LOG > $VOYEUR_STDOUT)
+ ( run_build ) \
+ 3> >(tee -a "$C_LOG") \
+ 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
+ > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
}

delve_pre_install() {
debug "delve" "Running $FUNCNAME"
delve_is_valid_step PRE_INSTALL 2 || return 1
delve_log_helper
- (
- run_pre_install
- ) 3> >(tee -a $C_LOG >> /dev/stdout) \
- 2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
- > >(tee -a $C_LOG > $VOYEUR_STDOUT)
+ ( run_pre_install ) \
+ 3> >(tee -a "$C_LOG") \
+ 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
+ > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
}

delve_staged_install_setup() {
@@ -197,11 +200,11 @@ delve_install() {
else
$CHROOT_CMD delve $SPELL INSTALL
fi
- ) 3> >(tee -a $C_LOG >> /dev/stdout) \
- 2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
- > >(tee -a $C_LOG > $VOYEUR_STDOUT)
+ ) 3> >(tee -a "$C_LOG") \
+ 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
+ > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
local rc=$?
- if [[ $CHROOT_CMD ]]
+ if [[ -n "$CHROOT_CMD" && "$STAGED_INSTALL" = castfs ]]
then
devoke_stage_root
fi &&
@@ -221,11 +224,11 @@ delve_install_extras() {
else
$CHROOT_CMD delve $SPELL INSTALL_EXTRAS
fi
- ) 3> >(tee -a $C_LOG >> /dev/stdout) \
- 2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
- > >(tee -a $C_LOG > $VOYEUR_STDOUT)
+ ) 3> >(tee -a "$C_LOG") \
+ 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
+ > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
local rc=$?
- if [[ $CHROOT_CMD ]]
+ if [[ -n "$CHROOT_CMD" && "$STAGED_INSTALL" = castfs ]]
then
devoke_stage_root
fi &&
@@ -242,33 +245,30 @@ delve_post_build() {
return 1
}
cd $SOURCE_DIRECTORY
- (
- run_post_build
- ) 3> >(tee -a $C_LOG >> /dev/stdout) \
- 2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
- > >(tee -a $C_LOG > $VOYEUR_STDOUT)
+ ( run_post_build ) \
+ 3> >(tee -a "$C_LOG") \
+ 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
+ > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
}

delve_post_install() {
debug "delve" "Running $FUNCNAME"
delve_is_valid_step POST_INSTALL 1 2 || return 1
delve_log_helper
- (
- run_post_install
- ) 3> >(tee -a $C_LOG >> /dev/stdout) \
- 2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
- > >(tee -a $C_LOG > $VOYEUR_STDOUT)
+ ( run_post_install ) \
+ 3> >(tee -a "$C_LOG") \
+ 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
+ > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
}

delve_transfer() {
debug "delve" "Running $FUNCNAME"
delve_is_valid_step TRANSFER 2 || return 1
delve_log_helper
- (
- run_transfer
- ) 3> >(tee -a $C_LOG >> /dev/stdout) \
- 2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
- > >(tee -a $C_LOG > $VOYEUR_STDOUT)
+ ( run_transfer ) \
+ 3> >(tee -a "$C_LOG") \
+ 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
+ > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
}

delve_final() {
@@ -277,12 +277,10 @@ delve_final() {
delve_log_helper
devoke_installwatch &&
STAGED_INSTALL=off
- (
- run_final
- ) 3> >(tee -a $C_LOG >> /dev/stdout) \
- 2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
- > >(tee -a $C_LOG > $VOYEUR_STDOUT)
-
+ ( run_final ) \
+ 3> >(tee -a "$C_LOG") \
+ 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
+ > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
}

delve_triggers() {
diff --git a/var/lib/sorcery/modules/build_api/api1
b/var/lib/sorcery/modules/build_api/api1
index ad90377..777814b 100755
--- a/var/lib/sorcery/modules/build_api/api1
+++ b/var/lib/sorcery/modules/build_api/api1
@@ -30,19 +30,13 @@ run_build_spell() {
STAGED_INSTALL=off
rm -f $C_LOG
touch $C_LOG
+ reserve_fds VOYEUR_STDOUT VOYEUR_STDERR
if [[ $SCREEN_NAME ]] ; then
screen_new_window "$SCREEN_NAME" $SCREEN_CAST_WIN "cast $SPELL" \
tail -f -s 0.1 $C_LOG
screen_switch_window "$SCREEN_NAME" $SCREEN_MAIN_WIN
-
- VOYEUR_STDOUT=/dev/null
- VOYEUR_STDERR=/dev/null
elif [ "$VOYEUR" == "on" -a -z "$SILENT" ] ; then
- VOYEUR_STDOUT=/dev/stdout
- VOYEUR_STDERR=/dev/stderr
- else
- VOYEUR_STDOUT=/dev/null
- VOYEUR_STDERR=/dev/null
+ eval "exec $((VOYEUR_STDOUT))>&1 $((VOYEUR_STDERR))>&2"
fi
# should OPTS get set here?

@@ -122,10 +116,9 @@ run_build() {
message "$SPELL $VERSION"

run_config_loc
- (
- run_spell_file BUILD build
- ) 2> >(tee -a $C_LOG 1>&2 >> $VOYEUR_STDERR) \
- > >(tee -a $C_LOG >> $VOYEUR_STDOUT) # see bug 7201
+ ( run_spell_file BUILD build ) \
+ 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
+ > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")

if [ "$?" != 0 ]; then
message "${PROBLEM_COLOR}" \
diff --git a/var/lib/sorcery/modules/build_api/api2
b/var/lib/sorcery/modules/build_api/api2
index abfceea..0c7c949 100755
--- a/var/lib/sorcery/modules/build_api/api2
+++ b/var/lib/sorcery/modules/build_api/api2
@@ -36,24 +36,16 @@ run_build_spell() {
export VOYEUR_STDOUT VOYEUR_STDERR
export __DELVE_IN_CAST=on

- rm -f $CASTFS_DBGLOG
- touch $CASTFS_DBGLOG
- rm -f $C_LOG
- touch $C_LOG
+ >"$CASTFS_DBGLOG"
+ >"$C_LOG"

+ reserve_fds VOYEUR_STDOUT VOYEUR_STDERR
if [[ $SCREEN_NAME ]] ; then
screen_new_window "$SCREEN_NAME" $SCREEN_CAST_WIN "cast $SPELL" \
- tail -f -s 0.1 $C_LOG
+ tail -f -s 0.1 "$C_LOG"
screen_switch_window "$SCREEN_NAME" $SCREEN_MAIN_WIN
-
- VOYEUR_STDOUT=/dev/null
- VOYEUR_STDERR=/dev/null
elif [ "$VOYEUR" == "on" -a -z "$SILENT" ] ; then
- VOYEUR_STDOUT=/dev/stdout
- VOYEUR_STDERR=/dev/stderr
- else
- VOYEUR_STDOUT=/dev/null
- VOYEUR_STDERR=/dev/null
+ eval "exec $((VOYEUR_STDOUT))>&1 $((VOYEUR_STDERR))>&2"
fi

if [[ -z $STAGED_INSTALL ]]
@@ -92,9 +84,9 @@ run_build_spell() {
devoke_installwatch &&
STAGED_INSTALL=off &&
run_final | append_to_notice_log || return 3
- ) 3> >(tee -a $C_LOG >> /dev/stdout) \
- 2> >(tee -a $C_LOG 1>&2 >> $VOYEUR_STDERR) \
- > >(tee -a $C_LOG >> $VOYEUR_STDOUT) \
+ ) 3> >(tee -a "$C_LOG") \
+ 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
+ > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
)
rs=$?
unset __DELVE_IN_CAST
diff --git a/var/lib/sorcery/modules/libgrimoire
b/var/lib/sorcery/modules/libgrimoire
index 7389b54..d61c5b6 100755
--- a/var/lib/sorcery/modules/libgrimoire
+++ b/var/lib/sorcery/modules/libgrimoire
@@ -39,22 +39,15 @@ real_mk_source_dir() {
local NEW_DIR=${NEW_DIR:=$SOURCE_DIRECTORY}

local SIZE=$2
- # See bug 15946. Even simpler approach: Just specify no size, wich
- # also defaults to half of RAM in Linux.
# TODO: Use given size to decide for TMPFS or not, early bail out
# if not enough disk.
- local sizepar
- if [[ -n "$SIZE" ]]; then
- sizepar="size=$SIZE,"
- fi
# Could also think about inode count being necessary.

if [ -n "$NEW_DIR" ]; then
-
rm_source_dir $NEW_DIR
mkdir -p $NEW_DIR &&
if [[ $TMPFS == on ]]; then
- mount -o "$sizepar"nr_inodes=1m -t tmpfs tmpfs $NEW_DIR
+ mount -o "${SIZE:+size=$SIZE,}"nr_inodes=1m -t tmpfs tmpfs "$NEW_DIR"
fi
fi

diff --git a/var/lib/sorcery/modules/libmisc b/var/lib/sorcery/modules/libmisc
index c4ba9c6..5f862cc 100755
--- a/var/lib/sorcery/modules/libmisc
+++ b/var/lib/sorcery/modules/libmisc
@@ -1764,6 +1764,23 @@ show_file() {
}

#---------------------------------------------------------------------
+##
+## Reserve file descriptors; connects them to /dev/null.
+##
+#---------------------------------------------------------------------
+SORCERY_LAST_RESERVED_FD=2
+reserve_fds() {
+ while [ $# -gt 0 ]; do
+ if ! : >& "$((SORCERY_LAST_RESERVED_FD))"; then
+ eval "$1=$((SORCERY_LAST_RESERVED_FD)) &&
+ exec $((SORCERY_LAST_RESERVED_FD))> /dev/null" &&
+ shift
+ fi 2>/dev/null
+ let ++SORCERY_LAST_RESERVED_FD
+ done
+}
+
+#---------------------------------------------------------------------
## @param title
## @Globals TERM
##



  • [SM-Commit] GIT changes to master sorcery by Ismael Luceno (8d44d25f35cb44cb912f97c05c2f31dd7fa42f02), Ismael Luceno, 07/25/2023

Archive powered by MHonArc 2.6.24.

Top of Page