Skip to content

Commit 004f9db

Browse files
committed
sys-apps/portage-3.0.72: add code to migrate a users' config
Migrate Portage's user/group setup to make.conf (or the first file if it is a directory) to try and keep a system running without manual intervention. This code is in this version "dead", since the install still puts it in make.globals, but the next version will not. Signed-off-by: Fabian Groffen <[email protected]>
1 parent 751505f commit 004f9db

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

sys-apps/portage/portage-3.0.72.ebuild

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,52 @@ pkg_postinst() {
305305
eerror "Please remove this from ${bashrc} to avoid problems."
306306
eerror "See bug 867010 for more details."
307307
fi
308+
309+
# migrate to setup where user/group are in the users' config
310+
if use prefix-guest; then
311+
python_setup
312+
313+
local P_USER=$(
314+
env -u PORTAGE_USERNAME \
315+
"${PYTHON}" -c 'from portage.data import _portage_username; print(_portage_username)')
316+
if [[ ${P_USER} != ${PORTAGE_USERNAME} ]] ; then
317+
elog "Your Portage configuration is incomplete."
318+
elog "Due to a change in how Prefix Portage handles user and group"
319+
elog "administration, you must add the following in your"
320+
elog " ${EROOT}/etc/portage/make.conf"
321+
elog "PORTAGE_USERNAME=${PORTAGE_USERNAME}"
322+
elog "PORTAGE_GRPNAME=${PORTAGE_GRPNAME}"
323+
elog "PORTAGE_INST_UID=${PORTAGE_INST_UID}"
324+
elog "PORTAGE_INST_GID=${PORTAGE_INST_GID}"
325+
eerror "your installation will break without these settings"
326+
327+
local conffile="${EROOT}/etc/portage/make.conf"
328+
if [[ -d ${conffile} ]] ; then
329+
local f
330+
for f in ${conffile}/* ; do
331+
if [[ -w ${f} ]] ; then
332+
conffile=${f}
333+
break;
334+
fi
335+
done
336+
fi
337+
if [[ ! -w ${conffile} ]] ; then
338+
eerror "could not find a file in your make.conf to write to"
339+
eerror "you must add the variables yourself!"
340+
else
341+
{
342+
echo ""
343+
echo "# added by ${P} at $(date)"
344+
echo "# this was done as part of a migration of these"
345+
echo "# values from make.globals to user configuration"
346+
echo "PORTAGE_USERNAME=${PORTAGE_USERNAME}"
347+
echo "PORTAGE_GRPNAME=${PORTAGE_GRPNAME}"
348+
echo "PORTAGE_INST_UID=${PORTAGE_INST_UID}"
349+
echo "PORTAGE_INST_GID=${PORTAGE_INST_GID}"
350+
} >> "${conffile}"
351+
elog "user configuration variables were automatically added"
352+
elog "to your ${conffile}, please review"
353+
fi
354+
fi
355+
fi
308356
}

0 commit comments

Comments
 (0)