From 759d26c2770042d7cd8af59d3b19c47f34ea1934 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sun, 24 Feb 2013 12:33:18 -0800 Subject: [PATCH] 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 | 34 ++++++++++++++++------------- catalyst/defaults.py | 3 ++- catalyst/targets/stage1.py | 2 +- targets/stage1/stage1-chroot.sh | 14 ++++++------ targets/stage1/stage1-controller.sh | 4 ++-- targets/support/chroot-functions.sh | 18 +++++++-------- targets/support/kmerge.sh | 20 ++++++++--------- targets/support/livecdfs-update.sh | 12 +++++----- 8 files changed, 56 insertions(+), 51 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index e907de63..5db93887 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -874,12 +874,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) touch(self.settings["autoresume_path"]+"config_profile_link") @@ -890,10 +893,11 @@ class StageBase(TargetBase, ClearBase, GenBase): print "Resume point detected, skipping setup_confdir operation..." else: if "portage_confdir" in self.settings: - print "Configuring /etc/portage..." - cmd("rsync -a "+self.settings["portage_confdir"]+"/ "+\ - self.settings["chroot_path"]+"/etc/portage/",\ - "Error copying /etc/portage",env=self.env) + print "Configuring %s..." % self.settings["port_conf"] + cmd("rsync -a " + self.settings["portage_confdir"] + "/ " + + self.settings["chroot_path"] + self.settings["port_conf"], + "Error copying %s" % self.settings["port_conf"], + env=self.env) touch(self.settings["autoresume_path"]+"setup_confdir") def portage_overlay(self): @@ -1009,7 +1013,7 @@ class StageBase(TargetBase, ClearBase, GenBase): def chroot_setup(self): self.makeconf=read_makeconf(normpath(self.settings["chroot_path"]+ - self.settings["make.conf"])) + self.settings["make_conf"])) self.override_cbuild() self.override_chost() self.override_cflags() @@ -1056,7 +1060,7 @@ class StageBase(TargetBase, ClearBase, GenBase): """ Modify and write out make.conf (for the chroot) """ makepath = normpath(self.settings["chroot_path"] + - self.settings["make.conf"]) + self.settings["make_conf"]) cmd("rm -f " + makepath,\ "Could not remove " + makepath, env=self.env) myf=open(makepath, "w") @@ -1110,9 +1114,9 @@ class StageBase(TargetBase, ClearBase, GenBase): myf.close() makepath = normpath(self.settings["chroot_path"] + - self.settings["make.conf"]) + self.settings["make_conf"]) cmd("cp " + makepath + " " + makepath + ".catalyst",\ - "Could not backup " + self.settings["make.conf"],env=self.env) + "Could not backup " + self.settings["make_conf"],env=self.env) touch(self.settings["autoresume_path"]+"chroot_setup") def fsscript(self): @@ -1158,7 +1162,7 @@ class StageBase(TargetBase, ClearBase, GenBase): cmd("rm -rf " + overlay, "Could not remove " + self.settings["local_overlay"], env=self.env) cmd("sed -i '/^PORTDIR_OVERLAY/d' "+self.settings["chroot_path"]+\ - self.settings["make.conf"],\ + self.settings["make_conf"],\ "Could not remove PORTDIR_OVERLAY from make.conf",env=self.env) """ Clean up old and obsoleted files in /etc """ diff --git a/catalyst/defaults.py b/catalyst/defaults.py index d91b06d3..ef5653a2 100644 --- a/catalyst/defaults.py +++ b/catalyst/defaults.py @@ -62,7 +62,8 @@ confdefaults = { "distdir": "/usr/portage/distfiles", "hash_function": "crc32", "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 bdb87318..e9369290 100644 --- a/catalyst/targets/stage1.py +++ b/catalyst/targets/stage1.py @@ -33,7 +33,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 ed83f385..6ef94117 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,16 +47,16 @@ 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 -[ -e /etc/portage/make.conf ] && \ +[ -e ${clst_make_conf} ] && \ echo "USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"" \ - >> /etc/portage/make.conf + >> ${clst_make_conf} run_merge "--oneshot ${clst_buildpkgs}" sed -i "/USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"/d" \ - /etc/portage/make.conf + ${clst_make_conf} diff --git a/targets/stage1/stage1-controller.sh b/targets/stage1/stage1-controller.sh index 8ed42092..7557708e 100755 --- a/targets/stage1/stage1-controller.sh +++ b/targets/stage1/stage1-controller.sh @@ -11,10 +11,10 @@ case $1 in # 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}${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 010f5278..3c204b30 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 @@ -167,13 +167,13 @@ setup_gcc(){ setup_pkgmgr(){ # We need to merge our package manager with USE="build" set in case it is - # portage to avoid frying our /etc/portage/make.conf file. Otherwise, we could + # portage to avoid frying our make.conf file. Otherwise, we could # just let emerge system could merge it. # Use --update or portage won't reinstall the same version later. # Use --newuse to make sure it rebuilds with the "build" use flag. - [ -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 --update --newuse sys-apps/portage - sed -i '/USE="${USE} build"/d' /etc/portage/make.conf + sed -i '/USE="${USE} build"/d' ${clst_make_conf} } cleanup_distcc() { @@ -239,11 +239,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} ] @@ -294,7 +294,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 ef3eb2e8..0f2e1c75 100755 --- a/targets/support/kmerge.sh +++ b/targets/support/kmerge.sh @@ -196,22 +196,22 @@ then fi fi -[ -e /etc/portage/make.conf ] && \ - echo "USE=\"\${USE} ${clst_kernel_use} \"" >> /etc/portage/make.conf +[ -e ${clst_make_conf} ] && \ + echo "USE=\"\${USE} ${clst_kernel_use} build\"" >> ${clst_make_conf} if [ -n "${clst_KERNCACHE}" ] then mkdir -p /tmp/kerncache/${clst_kname} clst_root_path=/tmp/kerncache/${clst_kname} PKGDIR=${PKGDIR} clst_myemergeopts="--quiet --update --newuse" run_merge "${clst_ksource}" || exit 1 KERNELVERSION=`portageq best_visible / "${clst_ksource}"` - if [ ! -e /etc/portage/profile/package.provided ] + 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 [ -L /usr/src/linux ] && rm -f /usr/src/linux @@ -237,7 +237,7 @@ then fi build_kernel -sed -i "/USE=\"\${USE} ${clst_kernel_use} \"/d" /etc/portage/make.conf +sed -i "/USE=\"\${USE} ${clst_kernel_use} build\"/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 };'` @@ -253,8 +253,8 @@ echo ${clst_kernel_use} > /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_vers if [ -n "${clst_KERNCACHE}" ] then - if [ -e /etc/portage/profile/package.provided ] + if [ -e ${clst_port_conf}/profile/package.provided ] then - sed -i "/^$(echo "${KERNELVERSION}" | sed -e 's|/|\\/|g')\$/d" /etc/portage/profile/package.provided + sed -i "/^$(echo "${KERNELVERSION}" | sed -e 's|/|\\/|g')\$/d" ${clst_port_conf}/profile/package.provided fi fi diff --git a/targets/support/livecdfs-update.sh b/targets/support/livecdfs-update.sh index 2b41f9d0..a1ae134d 100755 --- a/targets/support/livecdfs-update.sh +++ b/targets/support/livecdfs-update.sh @@ -112,12 +112,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 -- 2.26.2