Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 265264 - app-admin/eselect: profiles module does not support profiles in overlays
Summary: app-admin/eselect: profiles module does not support profiles in overlays
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: eselect (show other bugs)
Hardware: All Linux
: High enhancement with 2 votes (vote)
Assignee: Gentoo eselect Team
URL:
Whiteboard:
Keywords: InVCS
: 359023 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-04-07 08:34 UTC by Kobboi
Modified: 2012-02-13 13:17 UTC (History)
4 users (show)

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


Attachments
/usr/share/eselect/modules/profile.eselect (profile.eselect,4.13 KB, text/plain)
2011-03-16 12:50 UTC, mike
Details
/usr/share/eselect/modules/profile.eselect Support make.profile in the /etc/portage directory (profile.eselect,4.63 KB, text/plain)
2011-03-16 15:04 UTC, mike
Details
Add support selecting profile from overlay (profile.eselect.diff,5.38 KB, patch)
2011-03-18 23:28 UTC, mike
Details | Diff
Add support selecting profile from overlay (profile.eselect.diff,5.79 KB, patch)
2011-03-19 12:46 UTC, mike
Details | Diff
complete rerite (profile.eselect,4.37 KB, text/plain)
2011-08-25 09:01 UTC, Lash the Core
Details
complete reerite (profile.eselect,5.53 KB, text/plain)
2011-08-26 06:12 UTC, Lash the Core
Details
profile.eselect new version (profile.eselect,6.56 KB, text/plain)
2011-08-27 09:55 UTC, Ulrich Müller
Details
completed reerite as file (profile.eselect,3.42 KB, text/plain)
2011-12-01 10:57 UTC, Lash the Core
Details
completed reerite as a patch (profile.eselect.patch,7.80 KB, text/plain)
2011-12-01 12:09 UTC, Lash the Core
Details
completed reerite as a patch (profile.eselect.patch,8.09 KB, patch)
2011-12-01 13:33 UTC, Lash the Core
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kobboi 2009-04-07 08:34:03 UTC
From looking at the module code, it appears the eselect profiles module does not support profiles that are in overlays. I now manually link to the profile.

Reproducible: Always
Comment 1 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-04-08 04:29:58 UTC
I'll evaluate a patch for submission.
Comment 2 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-07-23 03:23:55 UTC
(In reply to comment #1)
> I'll evaluate a patch for submission.
> 

No comment since then, removing myself from CC
Comment 3 Mike Hiretsky 2010-02-24 13:00:42 UTC
I need this enhancement also. Will make this possibility at the future?
Comment 4 Ulrich Müller gentoo-dev 2010-02-24 13:20:50 UTC
(In reply to comment #3)
> I need this enhancement also. Will make this possibility at the future?

Read comment #1 again. ;)
Comment 5 Ulrich Müller gentoo-dev 2011-03-15 20:02:04 UTC
*** Bug 359023 has been marked as a duplicate of this bug. ***
Comment 6 mike 2011-03-16 12:50:34 UTC
Created attachment 266113 [details]
/usr/share/eselect/modules/profile.eselect

In the last version made ​​a typo.
Notes on a CHROOT in curent version:

* If the profile is selected from the ROOT != / , in <CHROOT>/etc/make.conf should be
source ../var/lib/layman/make.conf
not
source /var/lib/layman/make.conf

* I do not know - it's a bug or a feature (possibly - I misunderstood the logic of portageq and expect different answer), but
PORTAGE_CONFIGROOT=${ROOT} ROOT=${ROOT} portageq portdir_overlay
looking for ways to overlay with respect to /, not $ ROOT
and therefore to work properly in a chroot overlays must meet the same in the basic system
Comment 7 Ulrich Müller gentoo-dev 2011-03-16 13:04:33 UTC
(In reply to comment #6)
> Created attachment 266113 [details]
> /usr/share/eselect/modules/profile.eselect

Thank you for the update. I'd much prefer if you could attach a patch against the newest version in <http://sources.gentoo.org/cgi-bin/viewvc.cgi/eselect/trunk/>.

> * I do not know - it's a bug or a feature (possibly - I misunderstood the
> logic of portageq and expect different answer), but
> PORTAGE_CONFIGROOT=${ROOT} ROOT=${ROOT} portageq portdir_overlay
> looking for ways to overlay with respect to /, not $ ROOT
> and therefore to work properly in a chroot overlays must meet the same in the
> basic system

Not sure if I have fully understood you here, but this sounds like bug 358185.
Comment 8 mike 2011-03-16 15:04:18 UTC
Created attachment 266131 [details]
/usr/share/eselect/modules/profile.eselect Support make.profile in the /etc/portage directory

as you requested, modified version of the latest version from SVN
Comment 9 Kobboi 2011-03-16 16:44:25 UTC
Also note that the path of layman's make.conf is set in /etc/layman/layman.cfg, you cannot assume it is /var/lib/layman/make.conf
Comment 10 mike 2011-03-16 17:08:12 UTC
> Also note that the path of layman's make.conf is set in /etc/layman/layman.cfg,
> you cannot assume it is /var/lib/layman/make.conf

many thanks, but in this profile.eselct I don't use layman cfg file

> * If the profile is selected from the ROOT != / , in <CHROOT>/etc/make.conf
> should be
> source ../var/lib/layman/make.conf
> not
> source /var/lib/layman/make.conf
It's more of a hint, there are no errors in the utility portageq?

but anyway thanks a lot.
Comment 11 mike 2011-03-18 23:28:03 UTC
Created attachment 266411 [details, diff]
Add support selecting profile from overlay

> Thank you for the update. I'd much prefer if you could attach a patch against the newest version in

Thid is a patch to the last version(for now) of the profile.eselect
this solves the problem from the subject

this is the same as https://bugs.gentoo.org/attachment.cgi?id=266131 . but deleted unnecessary comments.

And in a diff
Comment 12 mike 2011-03-19 12:46:40 UTC
Created attachment 266489 [details, diff]
Add support selecting profile from overlay

Hm.. in the latest patch I made ​​a small mistake - do not pay attention to the function set_symlink() use a variable to initialize the $target
>  [[ -z "${target}" ]] && die -q "Target \"${target}\" doesn't appear to be valid!"
Now corrected, checked - everything works.
This is a patch to http://sources.gentoo.org/cgi-bin/viewvc.cgi/eselect/trunk/modules/profile.eselect?view=markup&pathrev=810
Comment 13 Ulrich Müller gentoo-dev 2011-03-22 21:27:56 UTC
Another minor point: In eselect, we can't call functions like canonicalise or portageq in global scope, so the code in line 14 and following should be moved into a function (that is called for the different actions). No need to post another update though; I'll take care of it.
Comment 14 Lash the Core 2011-08-25 09:01:30 UTC
Created attachment 284575 [details]
complete rerite

HELO ppl.
take look at this.
original profile.eselect code is too ugly for me, so I did my own
Comment 15 Ulrich Müller gentoo-dev 2011-08-25 10:49:28 UTC
(In reply to comment #14)
> Created attachment 284575 [details]
> complete rerite

Thanks. If you want this to be reviewed for inclusion:
1. Please base it on a current version of profile.eselect. For example, your
   new version doesn't support the new /etc/portage location any more.
2. Since this is not a rewrite from scratch, a patch is much preferred, even
   if changes are large.
3. Please don't mix functional changes with style changes or purely cosmetic
   stuff like whitespace, because that makes it harder to see the important
   things. (The patch in comment #12 also suffered from this, BTW.)
4. Calls to portageq are expensive, so better avoid them inside of a loop.
   "portageq get_repo_path" can accept a list of arguments.
5. Usage of ${ROOT} and ${EROOT} in front of ${repo_path} is not consistent.
   (And I'm not sure if any of them belongs there at all. Best would be to
   test this with a non-trivial ROOT.)
Comment 16 Lash the Core 2011-08-25 12:42:40 UTC
(In reply to comment #15)
> (In reply to comment #14)
> > Created attachment 284575 [details]
> > complete rerite
> 
> Thanks. If you want this to be reviewed for inclusion:
I wanna this to be reviewed for bugs including st.5.:
> 5. Usage of ${ROOT} and ${EROOT} in front of ${repo_path} is not consistent.
>    (And I'm not sure if any of them belongs there at all. Best would be to
>    test this with a non-trivial ROOT.)
Testing this should make me sure in my vision of profile.eselect functionality.
Help of society will be appreciated.
Comment 17 Lash the Core 2011-08-26 06:06:38 UTC
Comment on attachment 284575 [details]
complete rerite

# -*-eselect-*-  vim: ft=eselect
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id: profile.eselect 820 2011-07-07 18:03:44Z ulm $

# This is a portage-only module.
inherit package-manager

DESCRIPTION="Manage the make.profile symlink"
MAINTAINER="eselect@gentoo.org"
SVN_DATE='$Date: 2011-07-07 20:03:44 +0200 (Thu, 07 Jul 2011) $'
VERSION=$(svn_date_to_version "${SVN_DATE}")

# get location of make.profile symlink
get_symlink_location() {
	local oldloc=${EROOT%/}/etc/make.profile
	local newloc=${EROOT%/}/etc/portage/make.profile

	if [[ -e ${oldloc} ]]; then
		MAKE_PROFILE=${oldloc}
		if [[ -e ${newloc} ]]; then
			write_warning_msg "Both ${oldloc} and ${newloc} exist."
			write_warning_msg "Using ${MAKE_PROFILE} for now."
		fi
	else
		MAKE_PROFILE=${newloc}
	fi
}

# get a list of valid profiles
find_targets() {
	# declaring local arrays
	local -a repos=( $( portageq get_repos "/" ) ) repospaths=( $( portageq get_repo_path "/" ${repos[@]} ) )
	# declaring local vars
	local arch=$( arch ) reposnum=${#repos[@]} repospathsnum=${#repospaths[@]} reponum p;

	# empty $arch & $repos leads to north-north-west^Wexit
	[[ -z ${arch} ]] && [[ -z ${repos} ]] && { echo "Errorr: cannot determine arch and repos">/dev/stderr; return 1; }
	# Portageq sanity check: $reposnum & $repospathsnum must be equal
	[[ "${reposnum}" != "${repospathsnum}" ]] && { echo "Errorr: unexpected portageq answer">/dev/stderr; return 1; }

	for(( reponum=0; $reponum<$reposnum; reponum++ ));do
		[[ -r ${ROOT}/${repospaths[$reponum]}/profiles/profiles.desc ]] && \
		# parsing profiles.desc for $arch suitable profiles
		for p in $( sed -n -e \
		"s|^${arch}[[:space:]]\+\([^[:space:]]\+\).*$|${repos[$reponum]}:\1|p" "${ROOT}${repospaths[$reponum]}/profiles/profiles.desc" );
		# printing "overlay-name:profile-dir" pairs
		do echo ${p}; done
	done
}

# remove make.profile symlink
remove_symlink() {
	rm "${MAKE_PROFILE}"
}

# set the make.profile symlink
set_symlink() {
	local portdir=$(portageq portdir) target=${1} force=${2} arch=$( arch ) parch repo repo_path
	[[ -z ${target} ]] && die -q "Target \"${1}\" doesn't appear to be valid!"

	local -a targets=( $(find_targets ) )
	[[ -z ${targets} ]] && die -q "Failed to get a list of valid profiles"

	if is_number "${target}" ; then target=${targets[target - 1]}; fi
	repo=${target%:*}
	repopath=$( portageq get_repo_path / ${repo} )
	target=${target#*:}

	if [[ -n ${target} && -d ${ROOT}${repopath}/profiles/${target} ]];then
		# if the profile was explicitly specified (rather than a number)
		# double check and make sure it's valid
		[[ -z ${arch} && -z "${force}" ]] && return 1
		# do a reverse lookup and find the arch associated with ${target}
		parch=$(sed -n -e \
			"s|^\([[:alnum:]]\+\)[[:space:]].*${target}[[:space:]].*$|\1|p" \
			"${ROOT}${repopath}/profiles/profiles.desc")
		if [[ ${arch} != ${parch} && -z "${force}" ]] ; then
			die -q "${target} is not a valid profile for ${arch}"
		fi
	fi

	if [[ -d ${ROOT}${repopath}/profiles/${target} ]]; then
		# we must call remove_symlink() here instead of calling
		# it from do_set(), since if the link is removed, we
		# cannot determine $ARCH in find_targets()
		if [[ -L ${EROOT}/etc/make.profile ]] ; then
			remove_symlink || die -q "Couldn't remove current make.profile symlink"
		fi
		# set relative symlink
		ln -s "$(relative_name "${EROOT}${repopath}/profiles/${target}" "${EROOT}/etc")" "${EROOT}/etc/make.profile"
		# check if the resulting symlink is sane
		if [[ $(canonicalise "${EROOT}/etc/make.profile") \
			!= "$(canonicalise "${EROOT}")"/* ]]; then
			write_warning_msg "Strange path. Check ${EROOT}/etc/make.profile symlink"
		fi
	else
		die -q "Target \"${1}\" doesn't appear to be valid at all!"
	fi
}

### show action ###

describe_show() {
	echo "Show the current make.profile symlink"
}

do_show() {
	get_symlink_location
	write_list_start "Current ${MAKE_PROFILE} symlink:"
	if [[ -L ${MAKE_PROFILE} ]]; then
		local link=$(canonicalise "${MAKE_PROFILE}")
		local portdir=$(portageq portdir)
		local profiledir=$(canonicalise "${ROOT}${portdir}/profiles")
		link=${link##${profiledir}/}
		write_kv_list_entry "${link}" ""
	else
		write_kv_list_entry "(unset)" ""
	fi
}

### list action ###

describe_list() {
	echo "List available profile symlink targets"
}

do_list() {
	local portdir profiledir active targets
	targets=( $(find_targets) )

	[[ -z ${targets} ]] && die -q "Failed to get a list of valid profiles"

	get_symlink_location
	portdir=$(portageq portdir)
	profiledir=$(canonicalise "${ROOT}${portdir}/profiles")
	active=$(canonicalise "${MAKE_PROFILE}")
	active=${active##${profiledir}/}
	if [[ -n ${targets[@]} ]]; then
		local i
		for (( i = 0; i < ${#targets[@]}; i++ )); do
			[[ ${targets[i]} == ${active} ]] \
				&& targets[i]=$(highlight_marker "${targets[i]}")
		done
	fi
	write_list_start "Available profile symlink targets:"
	write_numbered_list "${targets[@]}"
}

### set action ###

describe_set() {
	echo "Set a new profile symlink target"
}

describe_set_parameters() {
	echo "<target>"
}

describe_set_options() {
	echo "target : Target name or number (from 'list' action)"
	echo "--force : Forcibly set the symlink"
}

do_set() {
	local force
	if [[ $1 == "--force" ]]; then
		force=1
		shift
	fi

	[[ -z $1 ]] && die -q "You didn't tell me what to set the symlink to"
	[[ $# -gt 1 ]] && die -q "Too many parameters"

	get_symlink_location
	if [[ -e ${MAKE_PROFILE} ]] && [[ ! -L ${MAKE_PROFILE} ]]; then
		die -q "${MAKE_PROFILE} exists but is not a symlink"
	else
		set_symlink "$1" ${force} || die -q "Couldn't set a new symlink"
	fi
}
Comment 18 Lash the Core 2011-08-26 06:12:43 UTC
Created attachment 284687 [details]
complete reerite

complete reerite set_symlink() & find_targets() functions on latest profile.eselect
Comment 19 Lash the Core 2011-08-26 06:17:02 UTC
(In reply to comment #17)
> Comment on attachment 284575 [details]
> complete rerite

Sorry for that comment #17 - it can be safely deleted
Comment 20 Ulrich Müller gentoo-dev 2011-08-27 05:40:53 UTC
@Portage team: I need your advice. There are now two alternative patches that use different portageq calls to obtain a list of overlays/repositories. The first one (attachment 266489 [details, diff]) uses "portageq portdir" and "portageq portdir_overlay", whereas the second one (attachment 284687 [details]) uses "portageq get_repos" and "portageq get_repo_path".

Are there any strong reasons for using the one or the other? The second approach seems to have the advantage that it also makes the repositories' names available.
Comment 21 Zac Medico gentoo-dev 2011-08-27 05:52:37 UTC
Maybe "portageq get_repos" and "portageq get_repo_path" are better if you want to abstract away the idea of PORTDIR and PORTDIR_OVERLAY being separate entities rather than just having a single big list of repositories. Other than that, either approach is fine.
Comment 22 Ulrich Müller gentoo-dev 2011-08-27 09:55:27 UTC
Created attachment 284781 [details]
profile.eselect new version

Here's a new version, based on lashzcore's patch. I've added more changes in do_show and do_list so that the active will be recognised.

Please test.
Comment 23 Ulrich Müller gentoo-dev 2011-08-27 10:46:49 UTC
(In reply to comment #22)
> I've added more changes in do_show and do_list so that the active will be
> recognised.

s/active/active profile/
Comment 24 Ulrich Müller gentoo-dev 2011-09-01 20:25:49 UTC
Committed to SVN, revision 832.

Because the changes are quite intrusive, the module should really see some testing before the release. So who volunteers as guinea pig? ;-)
Comment 25 Lash the Core 2011-09-14 09:57:58 UTC
BTW, http://devmanual.gentoo.org/profiles/profiles.desc/index.html ?
Comment 26 Ulrich Müller gentoo-dev 2011-09-14 10:04:07 UTC
(In reply to comment #25)
> BTW, http://devmanual.gentoo.org/profiles/profiles.desc/index.html ?

Different issue → Please open a new bug (file it under "Product: Doc Other" and "Component: Devmanual").
Comment 27 Lash the Core 2011-12-01 10:57:58 UTC
Created attachment 294431 [details]
completed reerite as file
Comment 28 Lash the Core 2011-12-01 12:09:02 UTC
Created attachment 294433 [details]
completed reerite as a patch
Comment 29 Ulrich Müller gentoo-dev 2011-12-01 12:30:13 UTC
(In reply to comment #28)
> Created attachment 294433 [details]
> completed reerite as a patch

Could you please add an explanation what features are still missing, in your opinion, and why a further (rather intrusive) rewrite would be necessary? The tip version already supports overlays:
<http://sources.gentoo.org/cgi-bin/viewvc.cgi/eselect/trunk/modules/profile.eselect?view=markup>
(For convenience, there's also a live ebuild: app-admin/eselect-9999)
Comment 30 Lash the Core 2011-12-01 13:33:32 UTC
Created attachment 294437 [details, diff]
completed reerite as a patch

Just added support for make.profile in /etc/portage

Well, current svn version is two times bigger and seems to have fuzzy logic.
My version is more flexible for adding new features, whatever it may be.
I'm not asking to commit this to repo, but you may do 8)
--
cheers
Comment 31 Ulrich Müller gentoo-dev 2012-01-21 19:43:17 UTC
Support for overlays is included with eselect-1.3.
Thank you for bringing this up.