commit a221921db397b7f15e9ee79ab96eeb6219b50c0a
parent 7eb78309af06f6cf144b9045bd7281f27e3865c0
Author: MikoĊaj Lenczewski <mikolaj.lenczewski308@gmail.com>
Date: Mon, 3 May 2021 23:49:27 +0100
Started to write out setup script
Diffstat:
5 files changed, 105 insertions(+), 0 deletions(-)
diff --git a/STAGES.md b/STAGES.md
@@ -23,6 +23,7 @@ Process:
...
... # archives of all packages
/configs # contains all configuration files
+ f target # the build target (arm, arm64, x86_64, etc)
/pkg1 # contains configuration for package 1
...
/pkg2 # contains configuration for package 2
diff --git a/stages/build-clfs b/build-clfs
diff --git a/clean b/clean
@@ -1 +1,2 @@
#!/bin/sh
+
diff --git a/common.sh b/common.sh
@@ -1 +1,23 @@
#!/bin/sh
+
+CONFIRM () {
+ read -p "Press enter to continue..." _
+}
+
+export CFLAGS="-Os -pipe"
+export CXXFLAGS="-Os -pipe"
+export MAKEFLAGS="-j$(nproc)"
+
+export CLFS=/mnt/clfs
+
+export CLFS_CONFIGS=$CLFS/configs
+export CLFS_SOURCES=$CLFS/sources
+export CLFS_SCRIPTS=$CLFS/scripts
+export CLFS_LOGS=$CLFS/logs
+export CLFS_CONF=$CLFS_SOURCES/sysconf
+export CLFS_INIT=$CLFS_SOURCES/init
+
+export CLFS_STAGE1=$CLFS/stage1
+export CLFS_STAGE2=$CLFS/stage2
+export CLFS_STAGE3=$CLFS/stage3
+export CLFS_STAGE4=$CLFS/stage4
diff --git a/setup b/setup
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+. ./common.sh
+
+echo $CLFS_STAGE1
+
+TARGET=$1
+
+[ "${TARGET:-z}" = "z" ] && echo "No target specified!" && exit 1
+
+# select a build target + build configuration
+TARGET_EXISTS=
+for ENTRY in ./targets/*; do
+ if [ -d $ENTRY -a "$(basename $ENTRY)" = "$TARGET" ]; then
+ TARGET_EXISTS=y
+ echo "Selected target: $TARGET"
+ fi
+done
+
+[ "${TARGET_EXISTS:-z}" = "z" ] && echo "Target $TARGET not found!" && exit 1
+
+# write out shell includes for any environment variables
+# TODO(mikolaj)
+
+# create clfs build user + setup user bashrc with environment variables
+groupadd clfs
+useradd clfs -s /bin/bash -g clfs -m -k /dev/null
+
+cat > /home/clfs/.bash_profile <<'EOF'
+exec env -i HOME=${HOME} TERM=${TERM} PS1='\u:\w\$ ' /bin/bash
+EOF
+
+cat > /home/clfs/.bashrc <<'EOF'
+set +h
+umask 022
+EOF
+
+cat common.sh >> /home/clfs/.bashrc
+
+# TODO(mikolaj): append shell includes to bashrc
+# TODO(mikolaj): ensure CLFS_SYSROOT, CLFS_XSYSROOT and other important
+# environment variables have been assigned
+
+cat >> /home/clfs/.bashrc <<'EOF'
+export CLFS_HOST="$(echo ${MACHTYPE} | sed "s/-[^-]*/-cross/")"
+
+LC_ALL=POSIX
+PATH=${CLFS_STAGE1}/bin:/bin:/usr/bin
+export LC_ALL PATH
+EOF
+
+# create clfs build directory + subdirectories
+mkdir $CLFS
+chmod 755 $CLFS
+
+mkdir $CLFS_CONFIGS $CLFS_SCRIPTS $CLFS_SOURCES $CLFS_LOGS
+mkdif $CLFS_CONF $CLFS_INIT
+mkdir $CLFS_STAGE1 $CLFS_STAGE2 $CLFS_STAGE3 $CLFS_STAGE4
+chmod a+wt $CLFS/*
+
+cp -r bootscripts/* $CLFS_INIT
+cp -r configs/* $CLFS_CONF
+cp -r stages/* $CLFS_SCRIPTS
+chmod +x $CLFS_SCRIPTS/*
+
+chown clfs:clfs $CLFS -R
+
+# download sources and verify source signatures
+cp wget-list.src $CLFS_SOURCES/wget-list
+cp md5sums.src $CLFS_SOURCES/md5sums
+
+OLD=$(pwd)
+cd $CLFS_SOURCES
+ wget --input-file=wget-list --continue
+ md5sum -c md5sums
+cd $OLD
+
+# copy required source package build scripts to build directory
+
+# create linux standard hierarchy (fs) for rootfs
+