GentooThis forum is for the discussion of Gentoo Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
As far as I know, portage logging has never worked correctly on any of my systems (and I'm not alone). While trying to diagnose the issue, I noticed that there is conflicting information on various Gentoo wikis regarding the proper setup and execution of elog. Further examining the scripts show inconsistencies as well. I hope to get some input from the community, and devs, to help clear everything up on the wikis and get some patches pushed through.
# ls /var/log/portage/
www-client:firefox-bin-81.0.1-r1:20201009-170046.log
www-client:firefox-bin-81.0.1-r1:20201009-170058.log
# ls /var/log/portage/elog/www-client/
firefox-bin-81.0.1-r1:20201009-170100.log
and eread sees nothing
Code:
# eread
No log items to read
Because I have FEATURES="split-elog" set, I expect the three logs to be placed in /var/log/portage/www-client and eread to detect and display those logs.
PORT_LOGDIR or PORTAGE_LOGDIR
The x86 Handbook suggests that PORT_LOGDIR is the correct variable to set in make.conf.
Quote:
Portage can create per-ebuild log files, but only when the PORT_LOGDIR variable is set to a location that is writable by Portage (through the Portage user). By default this variable is unset. If PORT_LOGDIR is not set, then there will not be any build logs with the current logging system, though users may receive some logs from the new elog support.
Until Portage version 2.3.53, PORTAGE_LOGDIR variable used to be named PORT_LOGDIR. This old name is now deprecated.
The python module responsible for saving logs uses PORTAGE_LOGDIR
Code:
# cat /usr/lib/python3.7/site-packages/portage/elog/mod_save.py
import errno
import io
import time
import portage
from portage import os
from portage import _encodings
from portage import _unicode_decode
from portage import _unicode_encode
from portage.data import portage_gid, portage_uid
from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs
from portage.util import apply_permissions, ensure_dirs, normalize_path
def process(mysettings, key, logentries, fulltext):
if mysettings.get("PORTAGE_LOGDIR"):I hope to get some input from the community, and devs, to help clear everything up on the wikis
logdir = normalize_path(mysettings["PORTAGE_LOGDIR"])
else:
logdir = os.path.join(os.sep, mysettings["EPREFIX"].lstrip(os.sep),
"var", "log", "portage")
And the eread script, part of app-portage/gentoolkit, uses PORT_LOGDIR
Code:
# cat /usr/bin/eread
#!/bin/bash
# This is a script to read portage log items from einfo, ewarn etc, new in the
# portage-2.1 series.
#
# Author: Donnie Berkholz <spyderous@gentoo.org>
# Updated by: Uwe Klosa <uwe.klosa@gmail.com>
# Updated by: Slawomir Nizio <slawomir.nizio@sabayon.org>
# Get prefix
EPREFIX=${EPREFIX:-$(portageq envvar EPREFIX)}
# set decent PATH for bug 172969
PATH=${EPREFIX}/usr/bin:${EPREFIX}/bin:${PATH}
# Set ELOGDIR
PORT_LOGDIR="$(portageq envvar PORT_LOGDIR)"
[ "$PORT_LOGDIR" = "" ] && PORT_LOGDIR="${EPREFIX}/var/log/portage"
ELOGDIR="$PORT_LOGDIR/elog"
It is clear to me that after portage-2.3.53 PORTAGE_LOGDIR should be used, so the x86 Handbook and gentoolkit should be updated?
cat /var/log/portage/elog/www-client/firefox-bin-81.0.1-r1\:20201009-170100.log
INFO: setup
Package: www-client/firefox-bin-81.0.1-r1
Repository: gentoo
Maintainer: tripolar@gmx.at mozilla@gentoo.org,proxy-maint@gentoo.org
USE: abi_x86_64 alsa amd64 elibc_glibc ffmpeg gmp-autoupdate kernel_linux pulseaudio userland_GNU
FEATURES: network-sandbox preserve-libs sandbox userpriv usersandbox
INFO: install
Final size of build directory: 12 KiB
Final size of installed tree: 212864 KiB (207.8 MiB)
INFO: postinst
Updating .desktop files database ...
Updating icons cache ...
For using the crashreporter, you need gnome-base/gconf,
gnome-base/orbit and net-misc/curl emerged.
There is a python module responsible for saving logs to file. This appears to be fine, taking the package log key and writing it to a file in the elog subdir, but I'm not a python guru and hope someone will correct me if I am wrong.
Code:
cat /usr/lib/python3.7/site-packages/portage/elog/mod_save.py
# elog/mod_save.py - elog dispatch module
# Copyright 2006-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import errno
import io
import time
import portage
from portage import os
from portage import _encodings
from portage import _unicode_decode
from portage import _unicode_encode
from portage.data import portage_gid, portage_uid
from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs
from portage.util import apply_permissions, ensure_dirs, normalize_path
def process(mysettings, key, logentries, fulltext):
if mysettings.get("PORTAGE_LOGDIR"):
logdir = normalize_path(mysettings["PORTAGE_LOGDIR"])
else:
logdir = os.path.join(os.sep, mysettings["EPREFIX"].lstrip(os.sep),
"var", "log", "portage")
if not os.path.isdir(logdir):
# Only initialize group/mode if the directory doesn't
# exist, so that we don't override permissions if they
# were previously set by the administrator.
# NOTE: These permissions should be compatible with our
# default logrotate config as discussed in bug 374287.
uid = -1
if portage.data.secpass >= 2:
uid = portage_uid
ensure_dirs(logdir, uid=uid, gid=portage_gid, mode=0o2770)
cat, pf = portage.catsplit(key)
elogfilename = pf + ":" + _unicode_decode(
time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time())),
encoding=_encodings['content'], errors='replace') + ".log"
if "split-elog" in mysettings.features:
log_subdir = os.path.join(logdir, "elog", cat)
elogfilename = os.path.join(log_subdir, elogfilename)
else:
log_subdir = os.path.join(logdir, "elog")
elogfilename = os.path.join(log_subdir, cat + ':' + elogfilename)
_ensure_log_subdirs(logdir, log_subdir)
try:
with io.open(_unicode_encode(elogfilename,
encoding=_encodings['fs'], errors='strict'), mode='w',
encoding=_encodings['content'],
errors='backslashreplace') as elogfile:
elogfile.write(_unicode_decode(fulltext))
except IOError as e:
func_call = "open('%s', 'w')" % elogfilename
if e.errno == errno.EACCES:
raise portage.exception.PermissionDenied(func_call)
elif e.errno == errno.EPERM:
raise portage.exception.OperationNotPermitted(func_call)
elif e.errno == errno.EROFS:
raise portage.exception.ReadOnlyFileSystem(func_call)
else:
raise
# Copy group permission bits from parent directory.
elogdir_st = os.stat(log_subdir)
elogdir_gid = elogdir_st.st_gid
elogdir_grp_mode = 0o060 & elogdir_st.st_mode
# Copy the uid from the parent directory if we have privileges
# to do so, for compatibility with our default logrotate
# config (see bug 378451). With the "su portage portage"
# directive and logrotate-3.8.0, logrotate's chown call during
# the compression phase will only succeed if the log file's uid
# is portage_uid.
logfile_uid = -1
if portage.data.secpass >= 2:
logfile_uid = elogdir_st.st_uid
apply_permissions(elogfilename, uid=logfile_uid, gid=elogdir_gid,
mode=elogdir_grp_mode, mask=0)
return elogfilename
So what is creating the other two log files in /var/log/portage/? or Why is portage not adhering to FEATURES="split-elog"?
Why does eread see nothing?
The full eread script is
Code:
# cat /usr/bin/eread
#!/bin/bash
# This is a script to read portage log items from einfo, ewarn etc, new in the
# portage-2.1 series.
#
# Author: Donnie Berkholz <spyderous@gentoo.org>
# Updated by: Uwe Klosa <uwe.klosa@gmail.com>
# Updated by: Slawomir Nizio <slawomir.nizio@sabayon.org>
# Get prefix
EPREFIX=${EPREFIX:-$(portageq envvar EPREFIX)}
# set decent PATH for bug 172969
PATH=${EPREFIX}/usr/bin:${EPREFIX}/bin:${PATH}
# Set ELOGDIR
PORT_LOGDIR="$(portageq envvar PORT_LOGDIR)"
[ "$PORT_LOGDIR" = "" ] && PORT_LOGDIR="${EPREFIX}/var/log/portage"
ELOGDIR="$PORT_LOGDIR/elog"
# Verify that ELOGDIR exists
if [ ! -d "$ELOGDIR" ]; then
echo "ELOG directory: $ELOGDIR does not exist!"
exit 1
fi
# Use the pager from the users environment
[ -z "$PAGER" ] && PAGER="less"
# Set up select prompt
PS3="Choice? "
SORT=${EREAD_SORT_ORDER}
find_unsorted() {
find . -name '*:*:*.log*' | sed -e "s:\./::g"
}
find_by_name() {
find . -name '*:*:*.log*' | sort | sed -e "s:\./::g"
}
find_by_time() {
find . -name '*:*:*.log*' | sort -k 3 -t : | sed -e "s:\./::g"
}
find_files() {
case ${SORT} in
alphabet)
find_by_name
;;
time)
find_by_time
;;
*)
find_unsorted
;;
esac
}
select_loop() {
until [[ -n ${QUIT} ]]; do
ANY_FILES=$(find_files)
if [[ -z ${ANY_FILES} ]]; then
echo "No log items to read"
break
fi
echo
echo "This is a list of portage log items. Choose a number to view that file or type q to quit."
echo
# Pick which file to read
select FILE in ${ANY_FILES}; do
case ${REPLY} in
q)
echo "Quitting"
QUIT="yes"
break
;;
a)
SORT="alphabet"
;;
t)
SORT="time"
;;
*)
if [ -f "$FILE" ]; then
${PAGER} ${FILE}
read -p "Delete file? [y/N] " DELETE
case ${DELETE} in
q)
echo "Quitting"
QUIT="yes"
break
;;
y|Y)
rm -f ${FILE}
SUCCESS=$?
if [[ ${SUCCESS} = 0 ]]; then
echo "Deleted ${FILE}"
else
echo "Unable to delete ${FILE}"
fi
;;
# Empty string defaults to N (save file)
n|N|"")
echo "Saving ${FILE}"
;;
*)
echo "Invalid response. Saving ${FILE}"
;;
esac
else
echo
echo "Invalid response."
fi
;;
esac
break
done
done
}
pushd ${ELOGDIR} > /dev/null
select_loop
popd > /dev/null
But the error is in the find commands, which assume that split-elog is not set
Code:
find . -name '*:*:*.log*' | sed -e "s:\./::g"
So it looks like a patch needs to be made to check whether split-elog is set and adjust the file name scheme accordingly?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.