[freenos] push by nieklinn...@xxxxxxxxx - Generate separate rootfs in build/ and restructured rootfs paths.... on 2015-01-22 18:33 GMT

  • From: freenos@xxxxxxxxxxxxxx
  • To: freenos@xxxxxxxxxxxxx
  • Date: Thu, 22 Jan 2015 18:33:18 +0000

Revision: c5ee93e4ad19
Author:   Niek Linnenbank <nieklinnenbank@xxxxxxxxx>
Date:     Thu Jan 22 18:31:11 2015 UTC
Log:      Generate separate rootfs in build/ and restructured rootfs paths.
Generate ISO with embedded LinnFS. Added TargetInstall() method.

https://code.google.com/p/freenos/source/detail?r=c5ee93e4ad19

Added:
 /bin/init/rc
 /site_scons/linn.py
Deleted:
 /etc/logo.gif
 /etc/logo.txt
 /etc/rc
 /kernel/x86/pc/boot.isodesc
Modified:
 /bin/bench/SConscript
 /bin/cat/SConscript
 /bin/echo/SConscript
 /bin/hostname/SConscript
 /bin/init/Main.cpp
 /bin/init/SConscript
 /bin/ls/SConscript
 /bin/memstat/SConscript
 /bin/mknod/SConscript
 /bin/mount/SConscript
 /bin/parse/SConscript
 /bin/ps/SConscript
 /bin/reboot/SConscript
 /bin/sh/SConscript
 /bin/sh/Shell.cpp
 /bin/shutdown/SConscript
 /bin/stat/SConscript
 /bin/touch/SConscript
 /bin/uname/SConscript
 /kernel/x86/pc/SConscript
 /site_scons/build.py

=======================================
--- /dev/null
+++ /bin/init/rc        Thu Jan 22 18:31:11 2015 UTC
@@ -0,0 +1,13 @@
+/srv/input/keyboard/server
+/srv/video/vga/server
+/srv/terminal/server
+/srv/log/server
+/srv/ata/server
+/srv/filesystem/proc/server
+/srv/filesystem/grub/server
+/srv/filesystem/linn/server /dev/ata0 0x400000 /usr
+/srv/serial/server
+/srv/pci/server
+/srv/pci/detect
+/srv/time/server
+/bin/sh
=======================================
--- /dev/null
+++ /site_scons/linn.py Thu Jan 22 18:31:11 2015 UTC
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2009 Niek Linnenbank
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+import os.path
+from SCons.Action import *
+
+def linnfs_generate(target, source, env):
+    """
+    Generate an LinnFS filesystem image.
+    """
+    rootfs_out, ext  = os.path.splitext(str(target[0]))
+    rootfs_path = env.Dir(env['ROOTFS']).srcnode().path
+
+ os.system("build/host/srv/filesystem/linn/create " + rootfs_out + " -s -n 16384 -d " + rootfs_path)
+    os.system("gzip " + rootfs_out)
+
+#
+# Prints out a user friendly command-line string.
+#
+def linnfs_string(target, source, env):
+    return "  LINN " + str(target[0])
+
+#
+# Add ourselves to the given environment.
+#
+def generate(env):
+ builder = env.Builder(action = env.Action(linnfs_generate, linnfs_string))
+    env.Append(BUILDERS = { 'LinnImage' : builder })
+
+#
+# We always exist.
+#
+def exists(env):
+    return True
=======================================
--- /etc/logo.gif       Fri Jun 12 21:21:40 2009 UTC
+++ /dev/null   
Binary file, no diff available.
=======================================
--- /etc/logo.txt       Fri Jun 12 21:21:40 2009 UTC
+++ /dev/null
@@ -1,24 +0,0 @@
-       .
-      'l:.
-     .:ccc:. ..',;::ccccccccccc::;,'..
-     .:::ccc:cllccccccccccccccccccccclc:,'.
-     .cc:clccccccclccccccccllllllcccccccccc:;.
-    .,c:cllllcclllllccccccc:;;:ccclllllllcccccc;'
-   ',:;:llllc:lclcc::c:ccll'      ....',;:clccccc;'
-     ..:lllllccllllcc;;:ccc.               .',clccc;.
-       ,cllllcccclllllccccc:::;;;;;,'...       .:c:c;
-       .;llllllcccccccccllllllllllllllllc:;..    'c:c'
-         ;clllllllclcccccccccccccccccccclllll:'   .:::
-          .;clllcllclllcllclllcclllllccccclllllc'  .::.
-  .'.....  ...,ccoccooddolcllllllllllllcclllllllc'  ':,
- '::ccc:cc:ccclOklccokoccc:ccccccclccllcccllllllc:. .;c'
-.c:,,c:c:::cllclllllc:ccllccc::;;:::cccclllllccccc.  ';.
-  .,;;,,,,;,;;:cllllccclllllllllcccclllllllllc::::'..'.
-    ...'''....'':lllcclllllllllllllllllllllcccccccclcc:.
-        .,'..''':lc;...';:llllllllllllllllllccc:....:cl:.
-       .,,.';;;c:'.     .;c:ccllclcclllllclclc'     :ccc'
-      .;,';::;,'       .';;'..,:cclllllllcc,.       .;cl,
-      ;':;,..                     ........           .cl:.
-        .                                            ,:c:;.
-                                                     . ..
-
=======================================
--- /etc/rc     Sat Sep  5 09:05:24 2009 UTC
+++ /dev/null
@@ -1,13 +0,0 @@
-/srv/input/keyboard/server
-/srv/video/vga/server
-/srv/terminal/server
-/srv/log/server
-/srv/ata/server
-/srv/filesystem/proc/server
-/srv/filesystem/grub/server
-/srv/filesystem/linn/server /dev/ata0 0x400000 /usr
-/srv/serial/server
-/srv/pci/server
-/srv/pci/detect
-/srv/time/server
-/bin/sh/sh
=======================================
--- /kernel/x86/pc/boot.isodesc Wed Jan 21 18:25:37 2015 UTC
+++ /dev/null
@@ -1,6 +0,0 @@
-./boot/grub/stage1
-./boot/grub/stage2_eltorito
-./boot/boot.linn.gz
-./boot/boot.img.gz
-./boot/grub/menu.lst
-./kernel/kernel
=======================================
--- /bin/bench/SConscript       Mon Jan 19 19:58:13 2015 UTC
+++ /bin/bench/SConscript       Thu Jan 22 18:31:11 2015 UTC
@@ -20,4 +20,4 @@
 env = build_env.Clone()
 env.UseLibraries([ 'libposix', 'libc', 'liballoc', 'libcrt', 'libexec' ])
 env.UseServers(['memory'])
-env.TargetProgram('bench', 'Main.cpp')
+env.TargetProgram('bench', 'Main.cpp', env['bin'])
=======================================
--- /bin/cat/SConscript Mon Jan 19 19:58:13 2015 UTC
+++ /bin/cat/SConscript Thu Jan 22 18:31:11 2015 UTC
@@ -19,4 +19,4 @@

 env = build_env.Clone()
 env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc' ])
-env.TargetProgram('cat', 'Main.cpp')
+env.TargetProgram('cat', 'Main.cpp', env['bin'])
=======================================
--- /bin/echo/SConscript        Mon Jan 19 19:58:13 2015 UTC
+++ /bin/echo/SConscript        Thu Jan 22 18:31:11 2015 UTC
@@ -19,4 +19,4 @@

 env = build_env.Clone()
 env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc' ])
-env.TargetProgram('echo', 'Main.cpp')
+env.TargetProgram('echo', 'Main.cpp', env['bin'])
=======================================
--- /bin/hostname/SConscript    Mon Jan 19 19:58:13 2015 UTC
+++ /bin/hostname/SConscript    Thu Jan 22 18:31:11 2015 UTC
@@ -19,4 +19,4 @@

 env = build_env.Clone()
 env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc' ])
-env.TargetProgram('hostname', 'Main.cpp')
+env.TargetProgram('hostname', 'Main.cpp', env['bin'])
=======================================
--- /bin/init/Main.cpp  Tue Jan 20 18:37:02 2015 UTC
+++ /bin/init/Main.cpp  Thu Jan 22 18:31:11 2015 UTC
@@ -27,14 +27,14 @@

 int main(int argc, char **argv)
 {
-    const char *av[] = { "/bin/sh/sh", "/etc/rc", ZERO };
+    const char *av[] = { "/bin/sh", "/etc/rc", ZERO };

     /*
      * TODO: give up all privileges.
      */

     /* Execute the run commands file. */
-    forkexec("/bin/sh/sh", av);
+    forkexec("/bin/sh", av);

     /* Exit immediately. */
     return EXIT_SUCCESS;
=======================================
--- /bin/init/SConscript        Tue Jan 20 18:37:02 2015 UTC
+++ /bin/init/SConscript        Thu Jan 22 18:31:11 2015 UTC
@@ -20,4 +20,5 @@
 env = build_env.Clone()
 env.UseLibraries([ 'libposix', 'libc', 'liballoc', 'libcrt', 'libexec' ])
 env.UseServers(['memory', 'filesystem'])
-env.TargetProgram('init', 'Main.cpp')
+env.TargetProgram('init', 'Main.cpp', env['bin'])
+env.TargetInstall('rc', env['etc'])
=======================================
--- /bin/ls/SConscript  Mon Jan 19 19:58:13 2015 UTC
+++ /bin/ls/SConscript  Thu Jan 22 18:31:11 2015 UTC
@@ -20,4 +20,4 @@
 env = build_env.Clone()
 env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc' ])
 env.UseServers([ 'terminal', 'filesystem' ])
-env.TargetProgram('ls', 'Main.cpp')
+env.TargetProgram('ls', 'Main.cpp', env['bin'])
=======================================
--- /bin/memstat/SConscript     Mon Jan 19 19:58:13 2015 UTC
+++ /bin/memstat/SConscript     Thu Jan 22 18:31:11 2015 UTC
@@ -20,4 +20,4 @@
 env = build_env.Clone()
 env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc' ])
 env.UseServers([ 'memory' ])
-env.TargetProgram('memstat', 'Main.cpp')
+env.TargetProgram('memstat', 'Main.cpp', env['bin'])
=======================================
--- /bin/mknod/SConscript       Mon Jan 19 19:58:13 2015 UTC
+++ /bin/mknod/SConscript       Thu Jan 22 18:31:11 2015 UTC
@@ -20,4 +20,4 @@
 env = build_env.Clone()
 env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc' ])
 env.UseServers(['filesystem'])
-env.TargetProgram('mknod', 'Main.cpp')
+env.TargetProgram('mknod', 'Main.cpp', env['bin'])
=======================================
--- /bin/mount/SConscript       Mon Jan 19 19:58:13 2015 UTC
+++ /bin/mount/SConscript       Thu Jan 22 18:31:11 2015 UTC
@@ -20,4 +20,4 @@
 env = build_env.Clone()
 env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc' ])
 env.UseServers(['filesystem', 'memory', 'process'])
-env.TargetProgram('mount', 'Main.cpp')
+env.TargetProgram('mount', 'Main.cpp', env['bin'])
=======================================
--- /bin/parse/SConscript       Mon Jan 19 19:58:13 2015 UTC
+++ /bin/parse/SConscript       Thu Jan 22 18:31:11 2015 UTC
@@ -19,4 +19,4 @@

 env = build_env.Clone()
env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc', 'libparse' ])
-env.TargetProgram('parse', 'Main.cpp')
+env.TargetProgram('parse', 'Main.cpp', env['bin'])
=======================================
--- /bin/ps/SConscript  Mon Jan 19 19:58:13 2015 UTC
+++ /bin/ps/SConscript  Thu Jan 22 18:31:11 2015 UTC
@@ -19,4 +19,4 @@

 env = build_env.Clone()
 env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc' ])
-env.TargetProgram('ps', 'Main.cpp')
+env.TargetProgram('ps', 'Main.cpp', env['bin'])
=======================================
--- /bin/reboot/SConscript      Tue Jan 20 18:37:02 2015 UTC
+++ /bin/reboot/SConscript      Thu Jan 22 18:31:11 2015 UTC
@@ -19,4 +19,4 @@

 env = build_env.Clone()
 env.UseLibraries([ 'libposix', 'libc', 'liballoc', 'libcrt', 'libexec' ])
-env.TargetProgram('reboot', 'Main.cpp')
+env.TargetProgram('reboot', 'Main.cpp', env['bin'])
=======================================
--- /bin/sh/SConscript  Mon Jan 19 19:58:13 2015 UTC
+++ /bin/sh/SConscript  Thu Jan 22 18:31:11 2015 UTC
@@ -20,4 +20,4 @@
 env = build_env.Clone()
env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc', 'libparse' ])
 env.UseServers(['filesystem', 'memory', 'filesystem/virtual', 'terminal'])
-env.TargetProgram('sh', [Glob('*.cpp')])
+env.TargetProgram('sh', [Glob('*.cpp')], env['bin'])
=======================================
--- /bin/sh/Shell.cpp   Fri Jul 10 16:07:14 2009 UTC
+++ /bin/sh/Shell.cpp   Thu Jan 22 18:31:11 2015 UTC
@@ -76,10 +76,8 @@
            return status;
        }
        /* Try to find it on the livecd filesystem. (temporary hardcoded PATH) 
*/
-       else if ((snprintf(tmp, sizeof(tmp), "/bin/%s/%s",  argv[0], argv[0]) &&
-               ((pid = forkexec(tmp, (const char **) argv)) >= 0)) ||
-                (snprintf(tmp, sizeof(tmp), "/sbin/%s/%s", argv[0], argv[0]) &&
-               ((pid = forkexec(tmp, (const char **) argv)) >= 0)))
+       else if (snprintf(tmp, sizeof(tmp), "/bin/%s",  argv[0], argv[0]) &&
+               (pid = forkexec(tmp, (const char **) argv)) >= 0)
        {
            waitpid(pid, &status, 0);
            return status;
=======================================
--- /bin/shutdown/SConscript    Tue Jan 20 18:37:02 2015 UTC
+++ /bin/shutdown/SConscript    Thu Jan 22 18:31:11 2015 UTC
@@ -19,4 +19,4 @@

 env = build_env.Clone()
 env.UseLibraries([ 'libposix', 'libc', 'liballoc', 'libcrt', 'libexec' ])
-env.TargetProgram('shutdown', 'Main.cpp')
+env.TargetProgram('shutdown', 'Main.cpp', env['bin'])
=======================================
--- /bin/stat/SConscript        Mon Jan 19 19:58:13 2015 UTC
+++ /bin/stat/SConscript        Thu Jan 22 18:31:11 2015 UTC
@@ -20,4 +20,4 @@
 env = build_env.Clone()
 env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc' ])
 env.UseServers(['filesystem'])
-env.TargetProgram('stat', 'Main.cpp')
+env.TargetProgram('stat', 'Main.cpp', env['bin'])
=======================================
--- /bin/touch/SConscript       Mon Jan 19 19:58:13 2015 UTC
+++ /bin/touch/SConscript       Thu Jan 22 18:31:11 2015 UTC
@@ -20,4 +20,4 @@
 env = build_env.Clone()
 env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc' ])
 env.UseServers(['filesystem'])
-env.TargetProgram('touch', 'Main.cpp')
+env.TargetProgram('touch', 'Main.cpp', env['bin'])
=======================================
--- /bin/uname/SConscript       Mon Jan 19 19:58:13 2015 UTC
+++ /bin/uname/SConscript       Thu Jan 22 18:31:11 2015 UTC
@@ -20,4 +20,4 @@
 env = build_env.Clone()
 env.UseLibraries([ 'libcrt', 'libposix', 'libc', 'libexec', 'liballoc' ])
 env.UseServers(['filesystem'])
-env.TargetProgram('uname', 'Main.cpp')
+env.TargetProgram('uname', 'Main.cpp', env['bin'])
=======================================
--- /kernel/x86/pc/SConscript   Wed Jan 21 18:25:37 2015 UTC
+++ /kernel/x86/pc/SConscript   Thu Jan 22 18:31:11 2015 UTC
@@ -16,6 +16,7 @@
 #

 Import('build_env')
+Import('rootfs_files')

 env = build_env.Clone()

@@ -28,7 +29,8 @@
 env.TargetProgram('kernel', [ Glob('*.cpp'),
                              Glob('*.S'),
                              Glob('#' + env['BUILDROOT'] + '/kernel/*.cpp'),
-                             Glob('#' + env['BUILDROOT'] + 
'/kernel/API/*.cpp') ])
+                             Glob('#' + env['BUILDROOT'] + 
'/kernel/API/*.cpp') ]
+                         , env['boot'])

 #
 # Boot Image
@@ -36,13 +38,20 @@
env.BootImage('#${BUILDROOT}/boot.img', '#${BUILDROOT}/kernel/x86/pc/boot.imgdesc')

 #
-# Make a bootable LiveCD.
+# RootFS
+#
+env.LinnImage('#${BUILDROOT}/boot.linn.gz', rootfs_files)
+env.Depends('#${BUILDROOT}/boot.linn.gz', '#build/host')
+
+#
+# Boot ISO (LiveCD)
 #
 cd = env.ISO('#${BUILDROOT}/boot.iso',
            [ '#kernel/x86/pc/cd.img',
              '#kernel/x86/pc/grub.cfg',
              '#${BUILDROOT}/kernel/x86/pc/kernel',
-             '#${BUILDROOT}/boot.img' ])
+             '#${BUILDROOT}/boot.img',
+            '#${BUILDROOT}/boot.linn.gz' ])

 # Shortcut to build the ISO.
 Alias('iso', cd)
=======================================
--- /site_scons/build.py        Wed Jan 21 18:25:37 2015 UTC
+++ /site_scons/build.py        Thu Jan 22 18:31:11 2015 UTC
@@ -15,9 +15,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #

+import os.path
 from SCons.Script import *
 from autoconf import *

+""" A list of files which are installed in the final RootFS """
+rootfs_files = []
+Export('rootfs_files')
+
 def UseLibraries(env, libs = [], arch = None):
     """
     Prepares a given environment, by adding library dependencies.
@@ -49,14 +54,31 @@
     if env['ARCH'] == 'host':
        env.Program(target, source)

-def TargetProgram(env, target, source):
+def TargetProgram(env, target, source, install_dir = None):
     if env['ARCH'] != 'host':
        env.Program(target, source)
+       env.TargetInstall(target, install_dir)

 def TargetLibrary(env, lib, source):
     if env['ARCH'] != 'host':
        env.Library(lib, source)

+def CopyStrFunc(target, source, env):
+ return " " + env.subst_target_source("COPY $SOURCE => $TARGET", 0, target, source)
+
+def DirStrFunc(target):
+    return "  MKDIR " + target
+
+def TargetInstall(env, source, target = None):
+    if env['ARCH'] != 'host':
+       SCons.Tool.install.install_action.strfunction = CopyStrFunc
+
+       if not target:
+           target = '${ROOTFS}/' + Dir('.').srcnode().path
+
+       env.Install(target, source)
+       rootfs_files.append(str(target) + os.sep + os.path.basename(source))
+
 def SubDirectories():
     dir_list = []
     dir_src  = Dir('.').srcnode().abspath
@@ -70,6 +92,7 @@

 Export('SubDirectories')

+
 # Create target, host and kernel environments.
 host = Environment()
 host.AddMethod(HostProgram, "HostProgram")
@@ -77,7 +100,15 @@
 host.AddMethod(TargetLibrary, "TargetLibrary")
 host.AddMethod(UseLibraries, "UseLibraries")
 host.AddMethod(UseServers, "UseServers")
-target = host.Clone(tools    = ["default", "bootimage", "iso", "binary"],
+host.AddMethod(TargetInstall, "TargetInstall")
+host.Append(ROOTFS = '#${BUILDROOT}/rootfs')
+host.Append(ROOTFS_FILES = [])
+host.Append(bin  = '${ROOTFS}/bin',
+           etc  = '${ROOTFS}/etc',
+           srv  = '${ROOTFS}/srv',
+            boot = '${ROOTFS}/boot')
+
+target = host.Clone(tools = ["default", "bootimage", "iso", "binary", "linn"],
                    toolpath = ["site_scons"])

 # Global top-level configuration.
@@ -117,6 +148,7 @@
     target['ARCOMSTR']     = host['ARCOMSTR']     = "  AR   $TARGET"
     target['RANLIBCOMSTR'] = host['RANLIBCOMSTR'] = "  LIB  $TARGET"
     target['LINKCOMSTR']   = host['LINKCOMSTR']   = "  LD   $TARGET"
+ target['COPYSTR'] = host['COPYSTR'] = " COPY $SOURCE => $TARGET"

 # Verify the configured CFLAGS.
 if not GetOption('clean'):

Other related posts:

  • » [freenos] push by nieklinn...@xxxxxxxxx - Generate separate rootfs in build/ and restructured rootfs paths.... on 2015-01-22 18:33 GMT - freenos