Initial commit of new system target
authorAndrew Gaffney <agaffney@gentoo.org>
Tue, 13 Jan 2009 22:39:35 +0000 (16:39 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Tue, 13 Jan 2009 22:39:35 +0000 (16:39 -0600)
ChangeLog
modules/catalyst/target/system.py [new file with mode: 0644]
targets/system/system-chroot.sh [new file with mode: 0644]
targets/system/system-controller.sh [new file with mode: 0644]
targets/system/system-preclean-chroot.sh [new file with mode: 0644]

index 1576b29465d0685ecdfdcd9573003d0d62102f49..160a27f14fcd4916b9133bed34254cea2aaf398a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
 # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS)
 # Distributed under the GPL v2
 
+  13 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
+  +modules/catalyst/target/system.py, +targets/system/system-chroot.sh,
+  +targets/system/system-controller.sh,
+  +targets/system/system-preclean-chroot.sh:
+  Initial commit of new system target
+
   13 Jan 2009; Andrew Gaffney <agaffney@gentoo.org> TODO:
   Add procedure for 'system' target
 
diff --git a/modules/catalyst/target/system.py b/modules/catalyst/target/system.py
new file mode 100644 (file)
index 0000000..67d5e5f
--- /dev/null
@@ -0,0 +1,93 @@
+
+"""
+Builder class for a system tarball build.
+"""
+
+from generic_stage import *
+import catalyst
+from catalyst.output import *
+
+class system_target(generic_stage_target):
+
+       def __init__(self):
+               generic_stage_target.__init__(self)
+
+               self.required_values=[]
+               self.valid_values=["chost"]
+
+       def set_stage_path(self):
+               self.settings["stage_path"]=catalyst.util.normpath(self.settings["chroot_path"]+self.settings["root_path"])
+               msg("system stage path is " + self.settings["stage_path"])
+
+       def set_root_path(self):
+               # sets the root path, relative to 'chroot_path', of the stage1 root
+               self.settings["root_path"]=catalyst.util.normpath("/tmp/stage3root")
+               msg("system root path is " + self.settings["root_path"])
+
+       def set_cleanables(self):
+               generic_stage_target.set_cleanables(self)
+               self.settings["cleanables"].extend(["/etc/portage"])
+
+       def override_chost(self):
+               if "chost" in self.settings:
+                       self.settings["CHOST"] = catalyst.util.list_to_string(self.settings["chost"])
+
+       def override_cflags(self):
+               if "cflags" in self.settings:
+                       self.settings["CFLAGS"] = catalyst.util.list_to_string(self.settings["cflags"])
+
+       def override_cxxflags(self):
+               if "cxxflags" in self.settings:
+                       self.settings["CXXFLAGS"] = catalyst.util.list_to_string(self.settings["cxxflags"])
+
+       def override_ldflags(self):
+               if "ldflags" in self.settings:
+                       self.settings["LDFLAGS"] = catalyst.util.list_to_string(self.settings["ldflags"])
+
+       def set_portage_overlay(self):
+               generic_stage_target.set_portage_overlay(self)
+               if "portage_overlay" in self.settings:
+                       msg()
+                       msg("WARNING !!!!!")
+                       msg("\tUsing an portage overlay for earlier stages could cause build issues.")
+                       msg("\tIf you break it, you buy it. Don't complain to us about it.")
+                       msg("\tDont say we did not warn you")
+                       msg()
+
+       def base_dirs(self):
+               if os.uname()[0] == "FreeBSD":
+                       # baselayout no longer creates the .keep files in proc and dev for FreeBSD as it
+                       # would create them too late...we need them earlier before bind mounting filesystems
+                       # since proc and dev are not writeable, so...create them here
+                       if not os.path.exists(self.settings["stage_path"]+"/proc"):
+                               os.makedirs(self.settings["stage_path"]+"/proc")
+                       if not os.path.exists(self.settings["stage_path"]+"/dev"):
+                               os.makedirs(self.settings["stage_path"]+"/dev")
+                       if not os.path.isfile(self.settings["stage_path"]+"/proc/.keep"):
+                               try:
+                                       proc_keepfile = open(self.settings["stage_path"]+"/proc/.keep","w")
+                                       proc_keepfile.write('')
+                                       proc_keepfile.close()
+                               except IOError:
+                                       msg("!!! Failed to create %s" % (self.settings["stage_path"] + "/dev/.keep"))
+                       if not os.path.isfile(self.settings["stage_path"]+"/dev/.keep"):
+                               try:
+                                       dev_keepfile = open(self.settings["stage_path"]+"/dev/.keep","w")
+                                       dev_keepfile.write('')
+                                       dev_keepfile.close()
+                               except IOError:
+                                       msg("!!! Failed to create %s" % (self.settings["stage_path"]+"/dev/.keep"))
+               else:
+                       pass
+
+       def set_mounts(self):
+               # stage_path/proc probably doesn't exist yet, so create it
+               if not os.path.exists(self.settings["stage_path"]+"/proc"):
+                       os.makedirs(self.settings["stage_path"]+"/proc")
+
+               # alter the mount mappings to bind mount proc onto it
+               self.mounts.append(self.settings["root_path"] + "/proc")
+               self.mountmap[self.settings["root_path"] + "/proc"]="/proc"
+
+
+__target_map = {"system": system_target}
diff --git a/targets/system/system-chroot.sh b/targets/system/system-chroot.sh
new file mode 100644 (file)
index 0000000..8d7d975
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+source /tmp/chroot-functions.sh
+
+# Next, we install the package manager
+clst_root_path=/ setup_pkgmgr
+make_destpath /tmp/stage3root
+
+# Install baselayout first, so we have our directory structure
+[ -e /etc/make.conf ] && echo 'USE="${USE} build"' >> /etc/make.conf
+run_merge "--oneshot --nodeps baselayout"
+sed -i '/^USE="\${USE} build"$/d' /etc/make.conf
+
+# Now, we emerge system
+run_merge "system"
diff --git a/targets/system/system-controller.sh b/targets/system/system-controller.sh
new file mode 100644 (file)
index 0000000..f150c08
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+. ${clst_sharedir}/targets/support/functions.sh
+
+case $1 in
+       enter)
+       ;;
+       run)
+               # Setup "ROOT in chroot" dir
+               install -d ${clst_chroot_path}/${clst_root_path}/etc
+
+               # Setup make.conf and make.profile link in "ROOT in chroot":
+               for i in make.conf make.globals make.profile; do
+                       copy_to_chroot ${clst_chroot_path}/etc/${i} /${clst_root_path}/etc
+               done
+
+               # Enter chroot, execute our build script
+               exec_in_chroot \
+                       ${clst_sharedir}/targets/${clst_target}/${clst_target}-chroot.sh \
+                       || exit 1
+       ;;
+       preclean)
+               exec_in_chroot ${clst_sharedir}/targets/${clst_target}/${clst_target}-preclean-chroot.sh /${clst_root_path} || exit 1
+       ;;
+       *)
+               exit 1
+       ;;
+esac
+exit $?
diff --git a/targets/system/system-preclean-chroot.sh b/targets/system/system-preclean-chroot.sh
new file mode 100644 (file)
index 0000000..a80fc92
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+export RUN_DEFAULT_FUNCS="no"
+
+source /tmp/chroot-functions.sh
+
+update_env_settings
+show_debug
+
+# Now, some finishing touches to initialize gcc-config....
+unset ROOT
+
+setup_gcc
+setup_binutils
+
+# Stage1 is not going to have anything in zoneinfo, so save our Factory timezone
+if [ -d /usr/share/zoneinfo ]
+then
+       rm -f /etc/localtime
+       cp /usr/share/zoneinfo/Factory /etc/localtime
+else
+       echo UTC > /etc/TZ
+fi
+
+cleanup_stages