From 6d640c0b9681b81be13ed11c52f1f037abc0d875 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sun, 24 Feb 2013 12:33:18 -0800 Subject: Migrate hardcoded /etc/portage paths Create "port_conf" default. Migrate all references to /etc/portage to the config's default. Migrate all make.conf paths to the config'd default. --- catalyst/base/stagebase.py | 15 +++++++++------ catalyst/defaults.py | 3 ++- catalyst/targets/stage1.py | 2 +- targets/stage1/stage1-chroot.sh | 18 +++++++++--------- targets/stage1/stage1-controller.sh | 6 +++--- targets/support/chroot-functions.sh | 16 ++++++++-------- targets/support/kmerge.sh | 10 +++++----- targets/support/livecdfs-update.sh | 12 ++++++------ 8 files changed, 43 insertions(+), 39 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 644bd7c1..4c7f0296 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -875,12 +875,15 @@ class StageBase(TargetBase, ClearBase, GenBase): # TODO: zmedico and I discussed making this a directory and pushing # in a parent file, as well as other user-specified configuration. print "Configuring profile link..." - cmd("rm -f "+self.settings["chroot_path"]+"/etc/portage/make.profile",\ - "Error zapping profile link",env=self.env) - cmd("mkdir -p "+self.settings["chroot_path"]+"/etc/portage/") - cmd("ln -sf ../.." + self.settings["portdir"] + "/profiles/" + \ - self.settings["target_profile"]+" "+\ - self.settings["chroot_path"]+"/etc/portage/make.profile",\ + cmd("rm -f " + self.settings["chroot_path"] + + self.settings["port_conf"] + "/make.profile", + "Error zapping profile link",env=self.env) + cmd("mkdir -p " + self.settings["chroot_path"] + + self.settings["port_conf"]) + cmd("ln -sf ../.." + self.settings["portdir"] + "/profiles/" + + self.settings["target_profile"] + " " + + self.settings["chroot_path"] + + self.settings["port_conf"] + "/make.profile", "Error creating profile link",env=self.env) self.resume.enable("config_profile_link") diff --git a/catalyst/defaults.py b/catalyst/defaults.py index 5cb5e3fb..975e55bd 100644 --- a/catalyst/defaults.py +++ b/catalyst/defaults.py @@ -26,7 +26,8 @@ confdefaults={ "hash_function": "crc32", "icecream": "/var/cache/icecream", "local_overlay": "/usr/local/portage", - "make_conf": "/etc/portage/make.conf", + "port_conf": "/etc/portage", + "make_conf": "%(port_conf)s/make.conf", "options": set(), "packagedir": "/usr/portage/packages", "portdir": "/usr/portage", diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py index 3d3b9e90..d5cc298d 100644 --- a/catalyst/targets/stage1.py +++ b/catalyst/targets/stage1.py @@ -32,7 +32,7 @@ class stage1(StageBase): def set_cleanables(self): StageBase.set_cleanables(self) self.settings["cleanables"].extend([\ - "/usr/share/zoneinfo", "/etc/portage/package*"]) + "/usr/share/zoneinfo", self.settings["port_conf"] + "/package*"]) # XXX: How do these override_foo() functions differ from the ones in StageBase and why aren't they in stage3_target? diff --git a/targets/stage1/stage1-chroot.sh b/targets/stage1/stage1-chroot.sh index 63aa5633..4afc8fe1 100755 --- a/targets/stage1/stage1-chroot.sh +++ b/targets/stage1/stage1-chroot.sh @@ -16,7 +16,7 @@ if [ -z "${clst_buildpkgs}" ] then echo "Your profile seems to be broken." echo "Could not build a list of build packages." - echo "Double check your /etc/portage/make.profile link and the 'packages' files." + echo "Double check your ${clst_port_conf}/make.profile link and the 'packages' files." exit 1 fi @@ -47,27 +47,27 @@ make_destpath /tmp/stage1root ## START BUILD # First, we drop in a known-good baselayout -[ -e /etc/portage/make.conf ] && \ - echo 'USE="${USE} -build"' >> /etc/portage/make.conf +[ -e ${clst_make_conf} ] && \ + echo 'USE="${USE} -build"' >> ${clst_make_conf} run_merge "--oneshot --nodeps sys-apps/baselayout" -sed -i '/USE="${USE} -build"/d' /etc/portage/make.conf +sed -i '/USE="${USE} -build"/d' ${clst_make_conf} # Now, we install our packages -if [ -e /etc/portage/make.conf ]; then +if [ -e ${clst_make_conf} ] && \ echo "USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"" \ - >> /etc/portage/make.conf + >> ${clst_make_conf} for useexpand in ${clst_HOSTUSEEXPAND}; do x="clst_${useexpand}" echo "${useexpand}=\"${!x}\"" \ - >> /etc/portage/make.conf + >> ${clst_make_conf} done fi run_merge "--oneshot ${clst_buildpkgs}" sed -i "/USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"/d" \ - /etc/portage/make.conf + ${clst_make_conf} for useexpand in ${clst_HOSTUSEEXPAND}; do x="clst_${useexpand}" sed -i "/${useexpand}=\"${!x}\"/d" \ - /etc/portage/make.conf + ${clst_make_conf} done diff --git a/targets/stage1/stage1-controller.sh b/targets/stage1/stage1-controller.sh index 09a121d2..0f44e97e 100755 --- a/targets/stage1/stage1-controller.sh +++ b/targets/stage1/stage1-controller.sh @@ -10,11 +10,11 @@ case $1 in cp ${clst_shdir}/stage1/build.py ${clst_chroot_path}/tmp # Setup "ROOT in chroot" dir - install -d ${clst_chroot_path}${clst_root_path}/etc - install -d ${clst_chroot_path}${clst_root_path}/etc/portage + install -d ${clst_chroot_path}/${clst_root_path}/etc + install -d ${clst_chroot_path}/${clst_root_path}${clst_port_conf} # Setup make.conf and make.profile link in "ROOT in chroot": - copy_to_chroot ${clst_chroot_path}/etc/portage/make.conf ${clst_root_path}/etc/portage + copy_to_chroot ${clst_chroot_path}${clst_make_conf} ${clst_root_path}${clst_port_conf} # Enter chroot, execute our build script exec_in_chroot \ diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index 3b7f77b4..71849844 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -75,8 +75,8 @@ setup_myfeatures(){ then export clst_myfeatures="${clst_myfeatures} distcc" export DISTCC_HOSTS="${clst_distcc_hosts}" - [ -e /etc/portage/make.conf ] && \ - echo 'USE="${USE} -avahi -gtk -gnome"' >> /etc/portage/make.conf + [ -e ${clst_make_conf} ] && \ + echo 'USE="${USE} -avahi -gtk -gnome"' >> ${clst_make_conf} # We install distcc to / on stage1, then use --noreplace, so we need to # have some way to check if we need to reinstall distcc without being # able to rely on USE, so we check for the distcc user and force a @@ -87,7 +87,7 @@ setup_myfeatures(){ else clst_root_path=/ run_merge --oneshot --noreplace sys-devel/distcc || exit 1 fi - sed -i '/USE="${USE} -avahi -gtk -gnome"/d' /etc/portage/make.conf + sed -i '/USE="${USE} -avahi -gtk -gnome"/d' ${clst_make_conf} mkdir -p /etc/distcc echo "${clst_distcc_hosts}" > /etc/distcc/hosts @@ -173,9 +173,9 @@ setup_pkgmgr(){ # Use --newuse to make sure it rebuilds with any changed use flags. if [ -n "$1" ];then echo "Adding USE='${USE} $1' to make.conf for portage build" - [ -e /etc/portage/make.conf ] && echo 'USE="${USE} $1"' >> /etc/portage/make.conf + [ -e ${clst_make_conf} ] && echo 'USE="${USE} $1"' >> ${clst_make_conf} run_merge --oneshot --update --newuse sys-apps/portage - sed -i '/USE="${USE} $1"/d' /etc/portage/make.conf + sed -i '/USE="${USE} $1"/d' ${clst_make_conf} else echo "Updating portage with USE='${USE}'" run_merge --oneshot --update --newuse sys-apps/portage @@ -245,11 +245,11 @@ die() { make_destpath() { # ROOT is / by default, so remove any ROOT= settings from make.conf - sed -i '/ROOT=/d' /etc/portage/make.conf + sed -i '/ROOT=/d' ${clst_make_conf} export ROOT=/ if [ "${1}" != "/" -a -n "${1}" ] then - echo "ROOT=\"${1}\"" >> /etc/portage/make.conf + echo "ROOT=\"${1}\"" >> ${clst_make_conf} export ROOT=${1} fi if [ ! -d ${ROOT} ] @@ -300,7 +300,7 @@ show_debug() { emerge --info # TODO: grab our entire env # to get see the ebuild env you can do something like: - # `set > /tmp/env_dump.${EBUILD_PHASE}` inside /etc/portage/bashrc + # `set > /tmp/env_dump.${EBUILD_PHASE}` inside ${clst_port_conf}/bashrc # XXX: Also, portageq does *not* source profile.bashrc at any time. echo echo "BOOTSTRAP_USE: $(portageq envvar BOOTSTRAP_USE)" diff --git a/targets/support/kmerge.sh b/targets/support/kmerge.sh index 03869c35..b72eeb6d 100755 --- a/targets/support/kmerge.sh +++ b/targets/support/kmerge.sh @@ -209,12 +209,12 @@ then if [ ! -e ${clst_port_conf}/profile/package.provided ] then - mkdir -p /etc/portage/profile - echo "${KERNELVERSION}" > /etc/portage/profile/package.provided + mkdir -p ${clst_port_conf}/profile + echo "${KERNELVERSION}" > ${clst_port_conf}/profile/package.provided else - if ( ! grep -q "^${KERNELVERSION}\$" /etc/portage/profile/package.provided ) + if ( ! grep -q "^${KERNELVERSION}\$" ${clst_port_conf}/profile/package.provided ) then - echo "${KERNELVERSION}" >> /etc/portage/profile/package.provided + echo "${KERNELVERSION}" >> ${clst_port_conf}/profile/package.provided fi fi @@ -271,7 +271,7 @@ make_destpath build_kernel -sed -i "/USE=\"\${USE} ${clst_kernel_use} \"/d" /etc/portage/make.conf +sed -i "/USE=\"\${USE} ${clst_kernel_use} \"/d" ${clst_make_conf} # grep out the kernel version so that we can do our modules magic VER=`grep ^VERSION\ \= /usr/src/linux/Makefile | awk '{ print $3 };'` PAT=`grep ^PATCHLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'` diff --git a/targets/support/livecdfs-update.sh b/targets/support/livecdfs-update.sh index aeae88cb..12f82935 100755 --- a/targets/support/livecdfs-update.sh +++ b/targets/support/livecdfs-update.sh @@ -105,12 +105,12 @@ fi # Tweak the livecd make.conf so that users know not to edit it # http://bugs.gentoo.org/show_bug.cgi?id=144647 -mv /etc/portage/make.conf /etc/portage/make.conf.old -echo "####################################################" >> /etc/portage/make.conf -echo "## ATTENTION: THIS IS THE MAKE.CONF ON THE LIVECD ##" >> /etc/portage/make.conf -echo "## PLEASE EDIT /mnt/gentoo/etc/portage/make.conf INSTEAD ##" >> /etc/portage/make.conf -echo "####################################################" >> /etc/portage/make.conf -cat /etc/portage/make.conf.old >> /etc/portage/make.conf +mv ${clst_make_conf} ${clst_make_conf}.old +echo "####################################################" >> ${clst_make_conf} +echo "## ATTENTION: THIS IS THE MAKE.CONF ON THE LIVECD ##" >> ${clst_make_conf} +echo "## PLEASE EDIT /mnt/gentoo${clst_make_conf} INSTEAD ##" >> ${clst_make_conf} +echo "####################################################" >> ${clst_make_conf} +cat ${clst_make_conf}.old >> ${clst_make_conf} # devfs tweaks [ -e /etc/devfsd.conf ] && sed -i '/dev-state/ s:^:#:' /etc/devfsd.conf -- cgit v1.2.3-65-gdbad