added utilities function for directories & files

This commit is contained in:
ag-tsotetsi
2026-02-25 10:09:16 +02:00
parent ceda19fb62
commit 59608f2d64

View File

@@ -92,19 +92,62 @@ TAR_URL=https://mirror.ufs.ac.za/gnu/tar/tar-$TAR_VERSION.tar.xz
XZ_VERSION=5.8.2
XZ_URL=https://github.com//tukaani-project/xz/releases/download/v$XZ_VERSION/xz-$XZ_VERSION.tar.xz
create_sysroot() {
create_directories() {
if [ ! -d "$SYSROOT" ]; then
mkdir -p "$SYSROOT"/{etc,cross,sources,usr,dev,proc,sys,run}
mkdir -p "$SYSROOT"/usr/{bin,sbin,lib,include}
mkdir -p "$SYSROOT"/var/{cache,lib,run}
for directory in bin sbin lib; do
ln -fs "usr/$directory" "$SYSROOT/$directory"
ln -fs usr/$directory "$SYSROOT"/$directory
done
ln -s usr/lib "$SYSROOT"/lib64
ln -s run "$SYSROOT"/var/run
ln -sfv run/lock "$SYSROOT"/var/lock
install -dv -m 0750 "$SYSROOT"/root
install -dv -m 1777 "$SYSROOT"/tmp "$SYSROOT"/var/tmp
fi
}
create_files() {
if [[ ! -L "$SYSROOT"/etc/mtab ]]; then
sudo ln -s proc/self/mounts "$SYSROOT"/etc/mtab
cat > "$SYSROOT"/etc/hosts <<- "EOF"
127.0.0.1 localhost axe
::1 localhost
EOF
cat > "$SYSROOT"/etc/passwd <<- "EOF"
root:x:0:0:root:/root:/usr/bin/bash
uuidd:x:6:6::/dev/null:/usr/bin/nologin
messagebus:x:7:7::/run/dbus:/usr/bin/nologin
nobody:x:65534:65534::/dev/null:/usr/bin/nologin
EOF
cat > "$SYSROOT"/etc/group <<- "EOF"
root:x:0:
tty:x:1:
audio:x:2:
video:x:3:
input:x:4:
wheel:x:5:
uuidd:x:6:
messagebus:x:7:
users:x:999:
nogroup:x:65534:
EOF
fi
}
create_sysroot() {
create_directories
create_files
}
change_owner() {
sudo chown -R root:root "$SYSROOT"/{etc,cross,usr,dev,proc,sys,run,var}
}
@@ -611,6 +654,7 @@ toolchain_gcc() {
cd "$SOURCES" && rm -rf gcc-$GCC_VERSION
}
#create_sysroot
#bootstrap_binutils
#bootstap_gcc
#bootstap_linux
@@ -634,4 +678,4 @@ toolchain_gcc() {
#toolchain_binutils
#toolchain_gcc
#change_owner
do_mount
#do_mount