class RBT::Linux::LFS
Constants
- DEFAULT_USER
#¶ ↑
DEFAULT_USER
¶ ↑#¶ ↑
- F
#¶ ↑
F
¶ ↑#¶ ↑
- LFS_DIR
#¶ ↑
LFS_DIR
¶ ↑#¶ ↑
- LOCATION_OF_PARTITION
#¶ ↑
LOCATION_OF_PARTITION
¶ ↑This is presently hardcoded. We may move to a non-hardcoded approach at a later time.
#¶ ↑
- MOUNT_DIR
#¶ ↑
MOUNT_DIR
¶ ↑This will become /Mount/lfs/.
#¶ ↑
- SOURCES_DIR
#¶ ↑
SOURCES_DIR
¶ ↑#¶ ↑
- T
#¶ ↑
T
¶ ↑#¶ ↑
- TOOLS_DIR
#¶ ↑
TOOLS_DIR
¶ ↑#¶ ↑
Public Class Methods
esystem(i)
click to toggle source
mkdir(i)
click to toggle source
new( run_already = true )
click to toggle source
populate_dev_device()
click to toggle source
#¶ ↑
RBT::LFS.populate_dev_device¶ ↑
This method can be used to populate the linux /dev entries, as specified in the LFS
project.
See the following link for an in-depth explanation:
http://www.linuxfromscratch.org/lfs/view/6.1/chapter06/devices.html
#¶ ↑
# File lib/rbt/linux/lfs/lfs/lfs.rb, line 263 def self.populate_dev_device esystem 'mknod -m 600 /dev/console c 5 1' esystem 'mknod -m 666 /dev/null c 1 3' esystem 'mount -n -t tmpfs none /dev' esystem 'mknod -m 622 /dev/console c 5 1' esystem 'mknod -m 666 /dev/null c 1 3' esystem 'mknod -m 666 /dev/zero c 1 5' esystem 'mknod -m 666 /dev/ptmx c 5 2' esystem 'mknod -m 666 /dev/tty c 5 0' esystem 'mknod -m 444 /dev/random c 1 8' esystem 'mknod -m 444 /dev/urandom c 1 9' esystem 'chown 0:tty /dev/{console,ptmx,tty}' esystem 'ln -s /proc/self/fd /dev/fd' esystem 'ln -s /proc/self/fd/0 /dev/stdin' esystem 'ln -s /proc/self/fd/1 /dev/stdout' esystem 'ln -s /proc/self/fd/2 /dev/stderr' esystem 'ln -s /proc/kcore /dev/core' mkdir '/dev/pts' mkdir '/dev/shm' esystem 'mount -t devpts -o gid=4,mode=620 none /dev/pts' esystem 'mount -t tmpfs none /dev/shm' end
Public Instance Methods
add_user(i = DEFAULT_USER)
click to toggle source
#¶ ↑
add_user
¶ ↑
This method will add a new user, in this context the lfs-user.
This is equivalent to this step:
http://www.linuxfromscratch.org/lfs/view/development/chapter04/addinguser.html
#¶ ↑
# File lib/rbt/linux/lfs/lfs/lfs.rb, line 231 def add_user(i = DEFAULT_USER) @user = i.to_s e 'Next adding a new '+slateblue('user')+' via groupadd/useradd:' s 'groupadd '+i.to_s s 'useradd -s /bin/bash -g '+i.to_s+' -m -k /dev/null '+i.to_s end
compile( name, optional_version = nil )
click to toggle source
#¶ ↑
compile¶ ↑
This will compile. If name contains a number, we split it up.
#¶ ↑
# File lib/rbt/linux/lfs/lfs/lfs.rb, line 175 def compile( name, optional_version = nil ) if name =~ /-\d+/ name = name.split '-' optional_version = name[1] name = name[0] end # from here on everything is fine again. installer = RBT::Installer.new(name) installer.set_version optional_version if optional_version installer.run end
consider_creating_mount_directory(i = MOUNT_DIR)
click to toggle source
#¶ ↑
consider_creating_mount_directory
¶ ↑
Consider creating the directory /Mount/lfs/.
#¶ ↑
# File lib/rbt/linux/lfs/lfs/lfs.rb, line 103 def consider_creating_mount_directory(i = MOUNT_DIR) unless File.directory? i e "Anyway, let's get started and first "+ sfancy('create a new directory.') e i mkdir i change_permission i else e 'Directory '+sdir(i)+' already exists, thus' e 'we will not create it.' end end
create_all_directories()
click to toggle source
create_bash_profile()
click to toggle source
create_source_directory()
click to toggle source
create_temp_directory()
click to toggle source
create_tools_directory()
click to toggle source
enter_lfs_partition(this_directory = MOUNT_DIR)
click to toggle source
install_linux_kernel_headers()
click to toggle source
#¶ ↑
install_linux_kernel_headers
¶ ↑
This is used to install the Linux
kernel headers.
URL resource can be found at:
https://www.linuxfromscratch.org/lfs/view/development/chapter05/linux-headers.html
#¶ ↑
# File lib/rbt/linux/lfs/lfs/lfs.rb, line 126 def install_linux_kernel_headers esystem 'make mrproper' esystem 'make INSTALL_HDR_PATH=dest headers_install' esystem 'cp -rv dest/include/* /tools/include' end
mount_lfs_partition()
click to toggle source
prepare_user_then_login(i = @user)
click to toggle source
reset()
click to toggle source
#¶ ↑
reset¶ ↑
#¶ ↑
Calls superclass method
RBT::Base#reset
# File lib/rbt/linux/lfs/lfs/reset.rb, line 16 def reset super() infer_the_namespace # ======================================================================= # # === @sources_dir # ======================================================================= # @sources_dir = source_directory? # ======================================================================= # # === @mounted_sources_directory # ======================================================================= # @mounted_sources_directory = "#{MOUNT_DIR}sources/" # ======================================================================= # # === @mounted_temp_directory # ======================================================================= # @mounted_temp_directory = MOUNT_DIR+'temp/' end
run()
click to toggle source
#¶ ↑
run¶ ↑
#¶ ↑
# File lib/rbt/linux/lfs/lfs/run.rb, line 16 def run show_welcome_message # (1) consider_creating_mount_directory # (2) # mount_lfs_partition # (3) optional step enter_lfs_partition # (4) create_all_directories # (5) symlink_tools_to_root # (6) set_sticky_bit # (7) add_user(:lfs) # (8) also sets @user. prepare_user_then_login create_file create_bash_profile # creates ~/.bash_profile e steelblue('DEBUG - all fine up to this point?') e steelblue('If yes we can continue.') exit compile 'Binutils-2.27' # This should be synced to the most recent Binutils version. compile 'GCC-6.3.0' install_linux_kernel_headers compile 'Glibc-2.14.1' end
s(i)
click to toggle source
set_sticky_bit(i = @sources_dir)
click to toggle source
show_welcome_message()
click to toggle source
#¶ ↑
show_welcome_message
¶ ↑
#¶ ↑
# File lib/rbt/linux/lfs/lfs/lfs.rb, line 81 def show_welcome_message e 'Welcome to '+slateblue('Linux from Scratch')+'!' e 'This project will make use of the '+ sfancy('RBT (Ruby Build Tools)')+'project' e 'to try and compile a smooth LFS for you from scratch.' e e 'For this, we will need to know a few things.' e end
symlink_tools_to_root(i = TOOLS_DIR)
click to toggle source
#¶ ↑
symlink_tools_to_root
¶ ↑
The following is equivalent to:
ln -sv $LFS/tools /
#¶ ↑
# File lib/rbt/linux/lfs/lfs/lfs.rb, line 54 def symlink_tools_to_root(i = TOOLS_DIR) # ln -sv $MOLLI/tools / #symlink(TOOLS_DIR, '/') symlink_cmd = 'ln -sv '+i+' /' _ = '/'+File.basename(i) if File.exist? _ e 'Can not symlink into '+Colours.col(_)+' as that one already exists.' e 'We remove it though.' remove(_) symlink_tools_to_root elsif File.exist?(TOOLS_DIR) and File.symlink?(TOOLS_DIR) e 'There already exists a symlink at '+gold(TOOLS_DIR) else e "Now symlinking #{sfancy(i)} to /" s symlink_cmd end end