Skip to content

cdomet-d/LFS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LFS

Here's a compendium of the things I found interresting while doing this project.

Various notes and sources

LFS Packages triva and explainations

  • Ncurses: tic - the terminfo entry-description compiler

Notes on the LFS chapters

I really struggled to understand this section of the LFS manual, so here's my understanding.

Overall, cross compilation is used to generate code for a machine target on a machine host. Those two machines can be completely different, and using host's native compiler toolchain would produce binaries that can run on it's system and architecture but not on the target's.

While native compilation is always simpler, sometimes a target system is too slow, or doesn't have enough memory (for instance, embedded systems), and so we must compile that system's binaries on another, more powerful machine.

7.3. Preparing Virtual Kernel File Systems

In this part we must choose a package management technique ; I've opted for the timestamp tracking, which I've implemented like follows :

First, in the host, I created this script - which I named install-log.sh - in a directory that's accessible in the chroot environnement. For me, that meant $LFS/var/log/pckmgmt.

#!/bin/bash
# Usage: ./log_installed.sh [timestamp_file] [output_log]

TIMESTAMP_FILE="$1"
OUTPUT_LOG="$2"

if [ ! -f "$TIMESTAMP_FILE" ]; then
    echo "Error: Timestamp file '$TIMESTAMP_FILE' not found."
    echo "Create it first with: date +%s > <timestamp-file>"
    exit 1
fi

TIMESTAMP=$(cat "$TIMESTAMP_FILE")
echo "Logging files newer than: $(date -d "@$TIMESTAMP" '+%Y-%m-%d %H:%M:%S')"

find / -type f -newermt "@$TIMESTAMP" \
    -not -path "/proc/*" \
    -not -path "/sys/*" \
    -not -path "/dev/*" \
    -not -path "/run/*" \
    -not -path "/tmp/*" \
    -not -path "/var/tmp/*" >> "$OUTPUT_LOG" 2>/dev/null

echo "Logged $(wc -l < "$OUTPUT_LOG") files to $OUTPUT_LOG"
echo "------" >> "$OUTPUT_LOG"

Then, in the same directory, I created a script to run the installation tracking more smoothly. I've named it log.sh and will refer to it as such thereafter.

#!/bin/bash

set -x

if [ $# -eq 0 ]
  then
    echo "Usage: log <package-name>"
	exit 1
fi

bash /path/to/logging-dir/install-log.sh \
		/path/to/logging-dir/<timestamp-file> \
		/path/to/logging-dir/"$1".log

Finally, in the chroot environnement, I :

  • exported a LOGGER environnement variable, which holds the path to the logging script - it's also where I've elected to store the logs ;
  • created a date alias to make the timestamp file management less of a pain;
export LOGGER=/path/to/logging-dir/
alias date='date +%s > $LOGGER/<timestamp-file>'

I guess those could be added to chroot command used to enter our building environnement, but I honestly didn't feel comfortable modifying it ; I'll take the pain of having to type two commands.

Utilities

As I was starting to loose my mind from repetitive tasks, I remembered the Shell is a powerful things and made a few tools to automate annoying stuff:

Check if all the packages where successfully installed

function chkinstall { while IFS= read -r line; do   command -v "$line" || echo "Not Found: $line" ; done < installed ;}

This expects an installed file to be in the directory where you run this. To create it, I created this function:

function winstalled { printf '%s\n' "$1" | sed 's/, and /\n/; s/, /\n/g' > installed ; }

That you use by copy-pasting the "installed programs" paragraph in your current binary LFS page, IE for kbd :

	winstalled  chvt, deallocvt, dumpkeys, fgconsole, getkeycodes, kbdinfo, kbd_mode, kbdrate, loadkeys, loadunimap, mapscrn, openvt, psfaddtable (link to psfxtable), psfgettable (link to psfxtable), psfstriptable (link to psfxtable), psfxtable, setfont, setkeycodes, setleds, setmetamode, setvtrgb, showconsolefont, showkey, unicode_start, and unicode_stop

Then your package management process can look like that:

Useful links

My own commands

Aliases

export LOGGER=/var/log/pckmgmt/
alias date='date +%s > $LOGGER/install_timestamp'
alias pcki='date && make install && log'

Functions

function cwd { basename $(pwd) ;}
function log { bash /log.sh $(cwd) ;}
function leave { export DONE=$(cwd) && cd .. && rm -rf $DONE ;}
function winstall() { echo $1 | sed 's/, /\n/g; s/and //g;' > installed ; }
function chkinstall() { while IFS= read -r line; do name=${line%% *}; echo -n "$name: "; command -v "$name" || ls -R /usr/lib | grep "$name" || echo "Not Found"; done < installed; }

About

In this project, you have to build a basic, but functional, linux distribution. This subject is not about Kernel programming, but it’s highly related. This distro will be the base for all your kernel projects, because all your kernel-code will be executed here, on your distro. Try to implement what you want/need to.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors