changeset 5405:53a9f1d78f1d

/GUB: initial full cross root build setup.
author Jan Nieuwenhuizen <janneke@gnu.org>
date Fri, 24 Jul 2009 14:10:44 +0200
parents 7a19ab8eeda0
children 798458797acb
files GNUmakefile gub/buildrunner.py gub/settings.py gub/tools.py
diffstat 4 files changed, 130 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/GNUmakefile	Fri Jul 24 13:56:09 2009 +0200
+++ b/GNUmakefile	Fri Jul 24 14:10:44 2009 +0200
@@ -79,3 +79,93 @@
 	    -e 's@#\nfrom gub import@#\nfrom gub.syntax import printf\nfrom gub import@' $$(grep -l printf $$(git diff --name-only))
 # sed 4.0.1 is broken, what t[ext]t[tool] do you use?
 	pytt '#\nfrom gub import' '#\nfrom gub.syntax import printf\nfrom gub import' $$(grep -l printf $$(git diff --name-only))
+
+
+ROOT = ./GUB
+FAKEROOT = $(ROOT)/usr/bin/fakeroot -s fakeroot.save
+FAKECHROOT = $(ROOT)/usr/bin/fakechroot chroot $(ROOT)
+BUILD_ARCHITECTURE = $(shell $(PYTHON) bin/build-architecture)
+UNTAR = cd $(ROOT)/$(BUILD_ARCHITECTURE) && for i in $$(find packages -name "*.gup"); do tar xzf $$i; done
+
+boot_packs =\
+ librestrict\
+ gawk\
+ ncurses\
+ texinfo\
+ cross/binutils\
+ dash\
+ cross/gcc-core\
+ linux-headers\
+ glibc-core\
+ cross/gcc\
+ glibc\
+ bash\
+ coreutils\
+ tar\
+ make\
+ sed\
+ findutils\
+ libtool\
+ fakeroot\
+ fakechroot\
+ makedev\
+ expat\
+ zlib\
+ db\
+ python\
+
+#
+
+root_packs =\
+ bash\
+ coreutils\
+ cross/binutils\
+ cross/gcc-core\
+ dash\
+ db\
+ expat\
+ fakechroot\
+ fakeroot\
+ glibc-core\
+ make\
+ makedev\
+ python\
+ tar\
+ zlib\
+
+#
+
+# build GUB packages to populate root [eventually for distribution]
+boot:
+	mkdir -p $(ROOT)
+	sudo ln -sf $(PWD)/GUB /
+	$(foreach i,$(boot_packs),bin/gub -x --fresh --keep --lax-checksums $(i) &&) :
+	mkdir -p BOOTSTRAP/$(BUILD_ARCHITECTURE)/packages
+	rsync -az $(ROOT)/$(BUILD_ARCHITECTURE)/packages/ BOOTSTRAP/$(BUILD_ARCHITECTURE)/packages
+	rm -f $$(find BOOTSTRAP/$(BUILD_ARCHITECTURE)/packages -name 'glibc' -o -name 'gcc' -o -name 'librestrict' -o -name 'linux-headers' -o -name 'sed' -o -name 'libtool' -o -name 'findutils' | grep -v core)
+
+# populate root with [minimal set of] binary packs
+root:
+	rm -rf $(ROOT)
+	mkdir -p $(ROOT)
+	# Symlink setup
+	bin/gub > /dev/null || bin/gub > /dev/null || true
+	rsync -az ./BOOTSTRAP/ $(ROOT)
+	mkdir -p $(ROOT)/downloads/cross/gcc-core
+	rsync -az downloads/cross/gcc-core/ $(ROOT)/downloads/cross/gcc-core
+	# let's not clutter /bin
+	rsync -az bin/ $(ROOT)/gbin
+	rsync -az gub librestrict nsis patches sourcefiles $(ROOT)
+	$(UNTAR)
+	$(FAKEROOT) $(FAKECHROOT) /bin/bash -l -c 'cd /dev && ./MAKEDEV standard'
+#	$(FAKEROOT) $(FAKECHROOT) /bin/bash -l -c '($UNTAR)'
+	mv $(ROOT)/dev/urandom $(ROOT)/dev/urandom-
+	$(FAKECHROOT) bash -l -c 'gbin/gub cross/gcc'
+
+# run test build in root
+run:
+	$(FAKECHROOT) bash -l -c 'gbin/gub --lax-checksums cross/gcc'
+
+# enter into root
+chroot:
+	$(FAKEROOT) $(FAKECHROOT) bash -l
--- a/gub/buildrunner.py	Fri Jul 24 13:56:09 2009 +0200
+++ b/gub/buildrunner.py	Fri Jul 24 14:10:44 2009 +0200
@@ -51,6 +51,8 @@
 #FIXME: split spec_* into SpecBuiler?
 class BuildRunner:
     def __init__ (self, manager, settings, options, specs):
+        info = logging.default_logger.harmless
+        info.write ('MANAGER:' + settings.platform)
         self.managers = {settings.platform : manager }
         self.settings = settings
         self.options = options
@@ -70,6 +72,8 @@
 
     def manager (self, platform):
         if platform not in self.managers:
+            info = logging.default_logger.harmless
+            info.write ('MANAGER for platform' + platform)
             settings = gub.settings.Settings (platform)
             self.managers[platform] = gup.DependencyManager (settings.system_root)
         return self.managers[platform]
@@ -209,11 +213,17 @@
         if all_installed:
             return
         checksum_fail_reason = self.failed_checksums.get (spec_name, '')
-        if not checksum_fail_reason and not spec.install_after_build:
+        if ((not checksum_fail_reason or self.options.lax_checksums)
+            and not spec.install_after_build):
             return
         logger = logging.default_logger
         if checksum_fail_reason:
-            logger.write_log ('must rebuild: %(spec_name)s\n' % locals (), 'verbose')
+            rebuild = 'must'
+            if self.options.lax_checksums:
+                rebuild = 'should'
+            else:
+                boo
+            logger.write_log ('%(rebuild)s rebuild: %(spec_name)s\n' % locals (), 'verbose')
         else:
             logger.write_log ('checksum ok: %(spec_name)s\n' % locals (), 'verbose')
 
@@ -273,6 +283,7 @@
                             .replace (misc.with_platform ('', platform), ''))
             logging.default_logger.write_log ('removing outdated[%(platform)s]: %(outdated_str)s\n' % locals (), 'stage')
             for name in outdated:
+                print 'uninstalling:', spec.name
                 self.uninstall_spec (self.specs[name])
 
     def build_source_packages (self, names):
--- a/gub/settings.py	Fri Jul 24 13:56:09 2009 +0200
+++ b/gub/settings.py	Fri Jul 24 14:10:44 2009 +0200
@@ -95,6 +95,7 @@
 
         # config dirs
         self.root_dir = '/' + self.target_architecture
+        self.tools_root_dir = '/' + self.build_architecture
         self.prefix_dir = '/usr'
         self.cross_dir = ''
 
@@ -126,6 +127,11 @@
         if self.platform == 'tools' and GUB_TOOLS_PREFIX:
             self.system_root = GUB_TOOLS_PREFIX
         self.system_prefix = self.system_root + self.prefix_dir
+        self.system_cross_prefix = self.system_prefix + '/' + self.target_architecture
+
+        self.tools_root = self.alltargetdir + self.tools_root_dir
+        self.tools_prefix = self.tools_root + self.prefix_dir
+        self.tools_cross_prefix = self.tools_prefix + '/' + self.build_architecture
 
         self.targetdir = self.system_root
         self.logdir = self.targetdir + '/log'
@@ -137,19 +143,23 @@
         self.allbuilddir = self.targetdir + '/build'
         self.statusdir = self.targetdir + '/status'
         self.packages = self.targetdir + '/packages'
+        self.installdir = self.targetdir + '/install'
 
         self.uploads = self.workdir + '/uploads'
         self.platform_uploads = self.uploads + '/' + self.platform
 
-        # FIXME: rename to cross_root?
+        # Hmm, cross now == system, isn't that is silly?
         self.cross_prefix = self.system_prefix
-        self.installdir = self.targetdir + '/install'
-        self.tools_root = self.alltargetdir
-        self.tools_prefix = self.system_prefix
 
-        print 'SYSTEM_ROOT', self.system_root
-        print 'CROSS_PREFIX', self.cross_prefix
-        print 'SYSTEM_PREFIX', self.system_prefix
+        info = logging.default_logger.harmless
+        info.write ('\n')
+        info.write ('SYSTEM_ROOT=%(system_root)s\n' % self.__dict__)
+        info.write ('SYSTEM_PREFIX=%(system_prefix)s\n' % self.__dict__)
+        info.write ('CROSS_PREFIX=%(cross_prefix)s\n' % self.__dict__)
+        info.write ('ROOT_DIR=%(root_dir)s\n' % self.__dict__)
+        info.write ('PREFIX_DIR=%(prefix_dir)s\n' % self.__dict__)
+        info.write ('CROSS_DIR=%(cross_dir)s\n' % self.__dict__)
+        info.write ('\n')
 
         if GUB_TOOLS_PREFIX:
             self.tools_root = GUB_TOOLS_PREFIX
@@ -251,18 +261,22 @@
 cd %(alltargetdir)s && ln -sf . ./%(alltargetdir)s
 cd %(alltargetdir)s && ln -sf %(system_prefix)s .
 cd %(alltargetdir)s && ln -sf %(system_prefix)s/bin .
-cd %(alltargetdir)s && ln -sf %(system_prefix)s/dev .
-cd %(alltargetdir)s && ln -sf %(system_prefix)s/etc .
-cd %(alltargetdir)s && ln -sf %(system_prefix)s/%(lib)s lib
+cd %(alltargetdir)s && ln -sf %(system_root)s/dev .
+cd %(alltargetdir)s && ln -sf %(system_root)s/etc .
+cd %(alltargetdir)s && ln -sf %(system_root)s/%(lib)s .
 cd %(alltargetdir)s && mkdir -p lib
 cd %(alltargetdir)s && ln -sf %(system_prefix)s/bin/true lib/ld-linux.so.2      
+cd %(alltargetdir)s && mkdir -p %(system_prefix)s/bin
+cd %(alltargetdir)s && ln -sf %(system_prefix)s/bin/bash %(system_prefix)s/bin/sh
+#cd %(alltargetdir)s && mkdir -p proc
+cd %(alltargetdir)s && mkdir %(system_root)s/etc
 ''' % self.__dict__)
                 loggedos.dump_file ('''
-PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/%(build_architecture)s/bin"
+PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/%(build_architecture)s/bin:/gbin"
 alias l='ls -ltrF'
 alias p='less -nMiX'
 ''', '%(alltargetdir)s/etc/profile' % self.__dict__)
-                                    
+
     def dependency_url (self, string):
         # FIXME: read from settings.rc, take platform into account
         name = string.replace ('-', '_')
--- a/gub/tools.py	Fri Jul 24 13:56:09 2009 +0200
+++ b/gub/tools.py	Fri Jul 24 14:10:44 2009 +0200
@@ -156,7 +156,7 @@
             'LIBRARY_PATH': '%(system_prefix)s/lib'
             + misc.append_path (os.environ.get ('LIBRARY_PATH', '')),
             'LIBRESTRICT_IGNORE': '%(system_prefix)s/bin/make',
-            'PATH': '%(system_prefix)s/bin:' + os.environ['PATH'],
+            'PATH': '%(system_prefix)s/bin:%(system_cross_prefix)s/bin:' + os.environ['PATH'],
         }
         dict.update (env)
         d = build.AutoBuild.get_substitution_dict (self, dict).copy ()