Migrate hardcoded /etc/portage paths
authorBrian Dolbec <dolsen@gentoo.org>
Sun, 24 Feb 2013 20:33:18 +0000 (12:33 -0800)
committerW. Trevor King <wking@tremily.us>
Sun, 15 Dec 2013 04:25:07 +0000 (20:25 -0800)
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
catalyst/defaults.py
catalyst/targets/stage1.py
targets/stage1/stage1-chroot.sh
targets/stage1/stage1-controller.sh
targets/support/chroot-functions.sh
targets/support/kmerge.sh
targets/support/livecdfs-update.sh

index e907de63132e8c36532f4e7417d12e4dff1edfa0..5db93887898a791ef5ced461bb047c53c41fe024 100644 (file)
@@ -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 """
index d91b06d3943e9abe8c61e4c3c52b42763b474126..ef5653a24c4a77b9f10893d8a6a05fbbfb1c2eb8 100644 (file)
@@ -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",
index bdb873187f7c757d01dc7fce272479522665b8ea..e9369290d0b0d6411be0cd065ac169522aa1392f 100644 (file)
@@ -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?
 
index ed83f3852f456bb195285657ef7269800a9da2c1..6ef9411764d50bc15e71c5e84f23d4657d64c492 100755 (executable)
@@ -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}
index 8ed42092c6462f63b8811796b2d7ecac043a87d4..7557708e5cd009cd810e824b9e1562daf13fb8d7 100755 (executable)
@@ -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 \
index 010f52780e0f2c9f6d0411f4f54cc1a4e545cba7..3c204b30f979148f6e4a8ff3b9c03720aabf8bf2 100755 (executable)
@@ -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
                # <zmedico> 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)"
index ef3eb2e8e8670022a80704ba9cfe42d3091137f4..0f2e1c755bdce034530f1e879763923982168650 100755 (executable)
@@ -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
index 2b41f9d0d609601a37e025065851bdddc78009dd..a1ae134dfb5b3bfad781784501ba45ece92dfacc 100755 (executable)
@@ -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