Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 601506 - eselect news list reports no news immediately after emerge-webrsync reports 11 news items
Summary: eselect news list reports no news immediately after emerge-webrsync reports 1...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: eselect (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo eselect Team
URL:
Whiteboard: eselect-1.4.8
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2016-12-03 10:27 UTC by Kent Fredric (IRC: kent\n) (RETIRED)
Modified: 2016-12-10 17:17 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Check return status of package manager calls in news module. (0001-Check-return-status-of-package-manager-calls-in-news.patch,1.32 KB, patch)
2016-12-04 05:42 UTC, Ulrich Müller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2016-12-03 10:27:24 UTC
Following the dev manual to set up a Chroot: 

https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Base#Reading_news_items

I perform an emerge-webrsync

the emerge-webrsync ends with:

 * IMPORTANT: 11 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items

However, immediately afterwards, eselect news reports nothing:

# eselect news list
News items:
  (none found)


This behaviour happened identically in 2-chroots. 

Chroot-1: stage3-amd64-nomultilib-20161124.tar.bz2
Chroot-2: stage3-i686-20161129.tar.bz2

And the snapshot fetched in both cases was:

- portage-20161202.tar.xz


Using those images versions of eselect/portage/everything ( no upgrades have been performed ):
=app-admin/eselect-1.4.5
=sys-apps/portage-2.3.0
Comment 1 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2016-12-03 10:39:47 UTC
In fact, subsequent emerges still show this annoying notifaction, but eselect still can't see it :/
Comment 2 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2016-12-03 11:29:17 UTC
Ok, the cause for the problem appears to be as follows:

Outside the chroots I'm building, I have paludis installed
and set as "the package manager", and it turns up in PACKAGE_MANAGER=paludis

chrooting doesn't clear this env field, so it is still ambient in the chroot

/etc/profile in the chroot does not change this field.

But lo, paludis is *NOT* installed in the chroot.

And eselect appears to run down that dead end as a result:

+ local item stat repo dir header line title posted i=1
+ local cols=277 'ifs_save=
'
+ local -a repos dirs
++ find_items unread read
+++ get_repositories
+++ case $(package_manager) in
++++ package_manager
++++ local pm
++++ case ${PACKAGE_MANAGER} in
++++ pm=paludis
++++ echo paludis
+++ run_paludis print-repositories
+++ cave print-repositories
++ local stat repos= repo file item
++ sort -t / -k 3
++ for stat in '"$@"'
++ for stat in '"$@"'
+ set --
+ write_list_start 'News items:'

^ it basically finds no repositories, and so cant' print
news from said repositories.

calling `unset PACKAGE_MANAGER` then makes eselect news actually work again :)
Comment 3 Mike Gilbert gentoo-dev 2016-12-03 14:50:19 UTC
So, INVALID then?
Comment 4 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2016-12-03 15:12:29 UTC
(In reply to Mike Gilbert from comment #3)
> So, INVALID then?

No. More:

1. Should not silently continue when calling paludis fails ( should bail instead )
2. PACKAGE_MANAGER crossing the chroot boundary should be considered something that needs fixing in the default /etc/profile (somehow)
Comment 5 Ulrich Müller gentoo-dev 2016-12-03 15:14:34 UTC
(In reply to Kent Fredric (IRC: kent\n) from comment #2)
> +++ get_repositories
> +++ case $(package_manager) in
> ++++ package_manager
> ++++ local pm
> ++++ case ${PACKAGE_MANAGER} in
> ++++ pm=paludis
> ++++ echo paludis
> +++ run_paludis print-repositories
> +++ cave print-repositories

Right, either get_repositories() or its caller should die when there is an error, or when the list of repositories is empty.
Comment 6 Ulrich Müller gentoo-dev 2016-12-04 05:42:24 UTC
Created attachment 455040 [details, diff]
Check return status of package manager calls in news module.

Can you test if attached patch fixes the problem for you?
Comment 7 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2016-12-04 08:24:01 UTC
# eselect news list
!!! Error: Cannot get list of repositories
Call stack:
    * find_items (news.eselect:18)
    * do_list (news.eselect:178)
    * check_do (core.bash:24)
    * do_action (core.bash:105)
    * main (eselect:179)
News items:
  (none found)
exiting


^ I'd hope for something more obvious, given how easy it is to trip this behaviour unintentionally.
Comment 8 Ulrich Müller gentoo-dev 2016-12-04 09:57:31 UTC
Can you please suggest a better error message than "Cannot get list of repositories" if get_repositories() returns with an error?
Comment 9 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2016-12-04 10:41:45 UTC
(In reply to Ulrich Müller from comment #8)
> Can you please suggest a better error message than "Cannot get list of
> repositories" if get_repositories() returns with an error?

Ideally you want get_repositories() to explain *why* it can't get repositories.

"Cannot get list of repositories: cave not installed and PACKAGE_MANAGER=paludis"

"Cannot get list of repositories: cave print-repositories returned no results"

etc.
Comment 10 Ulrich Müller gentoo-dev 2016-12-04 11:34:43 UTC
Well, how would we know that cave is not installed? It may have failed for whatever reason. get_repositories() calls the run_paludis() wrapper which in turn calls the cave command. There we get a non-zero return status which travels back up to find_items.

Also note that stderr for cave is redirected to /dev/null because paludis tends to output lots of warnings even if the command succeeds. So the "cave: command not found" message won't be seen.

We could do something like this:

--- a/libs/package-manager.bash.in
+++ b/libs/package-manager.bash.in
@@ -36,7 +36,12 @@
 # run_paludis PRIVATE
 # Run CAVE (defaults to "cave"). Redirect stderr
 run_paludis() {
-       ${CAVE:-cave} "$@" 2>/dev/null
+       local ret logfile=$(mktemp "${TMPDIR:-${ROOT}/tmp}/eselect.log.XXXXXX")
+       ${CAVE:-cave} "$@" 2>"${logfile}"
+       ret=$?
+       [[ ${ret} -eq 0 ]] || cat "${logfile}" >&2
+       rm -f "${logfile}"
+       return ${ret}
 }
 
 # arch

That is, save the stderr output and display it only if the command failed. But I believe that would be over-engineered. And it may cause other problems, for example mktemp may fail because the user hasn't purged TMPDIR from the environment when entering a chroot.

Anyway, I have updated the error messages to say "Package manager ..." so that there is at least a hint where to look for the problem:

-   repos=$(get_repositories) || die "Cannot get list of repositories"
+   repos=$(get_repositories) \
+       || die "Package manager cannot get list of repositories"

-           || die "Cannot get news dir for repo ${repo}"
+           || die "Package manager cannot get news dir for repo ${repo}"
Comment 11 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2016-12-04 12:37:15 UTC
(In reply to Ulrich Müller from comment #10)
> -   repos=$(get_repositories) || die "Cannot get list of repositories"
> +   repos=$(get_repositories) \
> +       || die "Package manager cannot get list of repositories"
> 
> -           || die "Cannot get news dir for repo ${repo}"
> +           || die "Package manager cannot get news dir for repo ${repo}"

I think you could increase the clarity of why with the phrasing:

"Package manager ($(package_manager)) cannot get list of repositories"

Then seeing an obviously wrong package manager listed would be a good hint.
Comment 12 Ulrich Müller gentoo-dev 2016-12-04 12:59:01 UTC
(In reply to Kent Fredric (IRC: kent\n) from comment #11)
> I think you could increase the clarity of why with the phrasing:
> 
> "Package manager ($(package_manager)) cannot get list of repositories"

Yeah, that would require making package_manager() a public function. I'll think about it.
Comment 13 Ulrich Müller gentoo-dev 2016-12-06 07:09:03 UTC
Committed to master:
https://gitweb.gentoo.org/proj/eselect.git/commit/?id=24b7b6c3026e62b519922cf81074594fbd573ef8

Waiting for bug 304011 until making a new release.