mirror of
https://github.com/krglaws/MyLFS.git
synced 2025-08-01 23:54:52 +00:00
add linux build
This commit is contained in:
42
build.sh
42
build.sh
@ -24,6 +24,16 @@ function usage {
|
|||||||
"\n" \
|
"\n" \
|
||||||
" -o|--one-off Only build the specified phase/package.\n" \
|
" -o|--one-off Only build the specified phase/package.\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
|
" -k|--kernel-config Optional path to kernel config file to use during linux\n" \
|
||||||
|
" build.\n" \
|
||||||
|
"\n" \
|
||||||
|
" -m|--mount\n" \
|
||||||
|
" -u|--umount These options will mount or unmount the disk image to the\n" \
|
||||||
|
" filesystem, and then exit the script immediately.\n" \
|
||||||
|
" You should be sure to unmount prior to running any part of\n" \
|
||||||
|
" the build, since the image will be automatically mounted\n" \
|
||||||
|
" and then unmounted at the end.\n" \
|
||||||
|
"\n" \
|
||||||
" -c|--clean This will unmount and delete the image, and clear the\n" \
|
" -c|--clean This will unmount and delete the image, and clear the\n" \
|
||||||
" logs.\n" \
|
" logs.\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
@ -256,6 +266,10 @@ EOF
|
|||||||
do
|
do
|
||||||
install_static $file
|
install_static $file
|
||||||
done
|
done
|
||||||
|
if [ -n "$KERNELCONFIG" ]
|
||||||
|
then
|
||||||
|
cp $KERNELCONFIG /boot/config-$KERNELVERS
|
||||||
|
fi
|
||||||
|
|
||||||
# install templates
|
# install templates
|
||||||
install_template ./templates/boot__grub__grub.cfg LFSROOTLABEL
|
install_template ./templates/boot__grub__grub.cfg LFSROOTLABEL
|
||||||
@ -291,7 +305,7 @@ function get_packages {
|
|||||||
wget --quiet --no-clobber --directory-prefix $PACKAGE_DIR --input-file - <<EOF
|
wget --quiet --no-clobber --directory-prefix $PACKAGE_DIR --input-file - <<EOF
|
||||||
$(cat $PACKAGE_LIST | cut -d"=" -f2)
|
$(cat $PACKAGE_LIST | cut -d"=" -f2)
|
||||||
EOF
|
EOF
|
||||||
cp ./pkgs/*.tar.* ./pkgs/*.patch $LFS/sources
|
cp ./pkgs/* $LFS/sources
|
||||||
echo "done."
|
echo "done."
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +315,7 @@ function mount_image {
|
|||||||
LOOP_P1=${LOOP}p1
|
LOOP_P1=${LOOP}p1
|
||||||
LOOP_P2=${LOOP}p2
|
LOOP_P2=${LOOP}p2
|
||||||
losetup -P $LOOP $LFS_IMG
|
losetup -P $LOOP $LFS_IMG
|
||||||
sleep 1
|
sleep 1 # give the kernel a sec
|
||||||
|
|
||||||
# mount root fs
|
# mount root fs
|
||||||
mount $LOOP_P2 $LFS
|
mount $LOOP_P2 $LFS
|
||||||
@ -310,7 +324,6 @@ function mount_image {
|
|||||||
mount -t vfat $LOOP_P1 $LFS/boot/efi
|
mount -t vfat $LOOP_P1 $LFS/boot/efi
|
||||||
|
|
||||||
# mount stuff from the host onto the target disk
|
# mount stuff from the host onto the target disk
|
||||||
echo "mounting the rest of the shit"
|
|
||||||
mount --bind /dev $LFS/dev
|
mount --bind /dev $LFS/dev
|
||||||
mount --bind /dev/pts $LFS/dev/pts
|
mount --bind /dev/pts $LFS/dev/pts
|
||||||
mount -t proc proc $LFS/proc
|
mount -t proc proc $LFS/proc
|
||||||
@ -348,6 +361,7 @@ function build_package {
|
|||||||
local BUILD_INSTR="
|
local BUILD_INSTR="
|
||||||
set -e
|
set -e
|
||||||
pushd sources > /dev/null
|
pushd sources > /dev/null
|
||||||
|
rm -rf $NAME
|
||||||
mkdir $NAME
|
mkdir $NAME
|
||||||
tar -xf $PKG_NAME -C $NAME --strip-components=1
|
tar -xf $PKG_NAME -C $NAME --strip-components=1
|
||||||
cd $NAME
|
cd $NAME
|
||||||
@ -366,6 +380,7 @@ function build_package {
|
|||||||
MAKEFLAGS=$MAKEFLAGS \
|
MAKEFLAGS=$MAKEFLAGS \
|
||||||
ROOT_PASSWD=$ROOT_PASSWD \
|
ROOT_PASSWD=$ROOT_PASSWD \
|
||||||
RUN_TESTS=$RUN_TESTS \
|
RUN_TESTS=$RUN_TESTS \
|
||||||
|
KERNELVERS=$KERNELVERS \
|
||||||
$(cat $PACKAGE_LIST) \
|
$(cat $PACKAGE_LIST) \
|
||||||
/usr/bin/bash +h -c "$BUILD_INSTR" &> $LOG_FILE
|
/usr/bin/bash +h -c "$BUILD_INSTR" &> $LOG_FILE
|
||||||
then
|
then
|
||||||
@ -398,7 +413,7 @@ function build_phase {
|
|||||||
|
|
||||||
if [ -n "$STARTPHASE" ]
|
if [ -n "$STARTPHASE" ]
|
||||||
then
|
then
|
||||||
if [ $PHASE -lt $STARTPHASE ] || $FOUNDSTARTPHASE && $ONEOFF
|
if [ $PHASE -lt $STARTPHASE ] || { $FOUNDSTARTPHASE && $ONEOFF; }
|
||||||
then
|
then
|
||||||
echo "Skipping phase $PHASE"
|
echo "Skipping phase $PHASE"
|
||||||
return 0
|
return 0
|
||||||
@ -506,6 +521,19 @@ while [ $# -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-k|--kernel-config)
|
||||||
|
KERNELCONFIG="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-m|--mount)
|
||||||
|
mount_image
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
-u|--umount)
|
||||||
|
unmount_image
|
||||||
|
exit
|
||||||
|
;;
|
||||||
-c|--clean)
|
-c|--clean)
|
||||||
clean_image
|
clean_image
|
||||||
exit
|
exit
|
||||||
@ -594,11 +622,11 @@ trap "{ unmount_image; exit 1; }" ERR SIGINT
|
|||||||
|
|
||||||
build_phase 1
|
build_phase 1
|
||||||
|
|
||||||
$ONEOFF && $FOUNDSTARTPHASE && unmount && exit
|
$ONEOFF && $FOUNDSTARTPHASE && unmount_image && exit
|
||||||
|
|
||||||
build_phase 2
|
build_phase 2
|
||||||
|
|
||||||
$ONEOFF && $FOUNDSTARTPHASE && unmount && exit
|
$ONEOFF && $FOUNDSTARTPHASE && unmount_image && exit
|
||||||
|
|
||||||
build_phase 3
|
build_phase 3
|
||||||
|
|
||||||
@ -607,7 +635,7 @@ rm -rf $LFS/usr/share/{info,man,doc}/*
|
|||||||
find $LFS/usr/{lib,libexec} -name \*.la -delete
|
find $LFS/usr/{lib,libexec} -name \*.la -delete
|
||||||
rm -rf $LFS/tools
|
rm -rf $LFS/tools
|
||||||
|
|
||||||
$ONEOFF && $FOUNDSTARTPHASE && unmount && exit
|
$ONEOFF && $FOUNDSTARTPHASE && unmount_image && exit
|
||||||
|
|
||||||
build_phase 4
|
build_phase 4
|
||||||
|
|
||||||
|
@ -21,10 +21,11 @@ export LFSHOSTNAME=lfs
|
|||||||
export LFSROOTLABEL=LFSROOT
|
export LFSROOTLABEL=LFSROOT
|
||||||
export LFSEFILABEL=LFSEFI
|
export LFSEFILABEL=LFSEFI
|
||||||
export LFSFSTYPE=ext4
|
export LFSFSTYPE=ext4
|
||||||
|
export KERNELVERS=5.16.9
|
||||||
|
|
||||||
KEYS="MAKEFLAGS PACKAGE_LIST PACKAGE_DIR LOG_DIR KEEP_LOGS"\
|
KEYS="MAKEFLAGS PACKAGE_LIST PACKAGE_DIR LOG_DIR KEEP_LOGS"\
|
||||||
" LFS LFS_TGT LFS_FS LFS_IMG LFS_IMG_SIZE ROOT_PASSWD RUN_TESTS TESTLOG_DIR"\
|
" LFS LFS_TGT LFS_FS LFS_IMG LFS_IMG_SIZE ROOT_PASSWD RUN_TESTS TESTLOG_DIR"\
|
||||||
" LFSHOSTNAME LFSROOTLABEL LFSEFILABEL LFSFSTYPE"
|
" LFSHOSTNAME LFSROOTLABEL LFSEFILABEL LFSFSTYPE KERNELVERS"
|
||||||
|
|
||||||
for KEY in $KEYS
|
for KEY in $KEYS
|
||||||
do
|
do
|
||||||
|
@ -72,6 +72,7 @@ e2fsprogs
|
|||||||
sysklogd
|
sysklogd
|
||||||
sysvinit
|
sysvinit
|
||||||
lfsbootscripts
|
lfsbootscripts
|
||||||
|
linux
|
||||||
|
|
||||||
# UEFI Boot Dependencies
|
# UEFI Boot Dependencies
|
||||||
popt
|
popt
|
||||||
|
@ -21,7 +21,7 @@ make install
|
|||||||
mv /etc/bash_completion.d/grub /usr/share/bash-completion/completions
|
mv /etc/bash_completion.d/grub /usr/share/bash-completion/completions
|
||||||
|
|
||||||
GRUB_OUTPUT=$(grub-install --bootloader-id=LFS --recheck)
|
GRUB_OUTPUT=$(grub-install --bootloader-id=LFS --recheck)
|
||||||
if ! echo $GRUB_OUTPUT | grep "No error reported"
|
if [ -n "$(echo $GRUB_OUTPUT | grep "No error reported")" ]
|
||||||
then
|
then
|
||||||
echo "An error occured while installing GRUB:"
|
echo "An error occured while installing GRUB:"
|
||||||
echo $GRUB_OUTPUT
|
echo $GRUB_OUTPUT
|
||||||
|
@ -1,31 +1,25 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# LINUX Phase 4
|
# LINUX Phase 4
|
||||||
# ~~~~~~~~~~~~~
|
CONFIGFILE=config-$KERNELVERS
|
||||||
set -e
|
|
||||||
|
|
||||||
cd /sources
|
|
||||||
|
|
||||||
eval "$(grep LINUX $PACKAGE_LIST)"
|
|
||||||
PKG_LINUX=$(basename $PKG_LINUX)
|
|
||||||
|
|
||||||
tar -xf $PKG_LINUX
|
|
||||||
cd ${PKG_LINUX%.tar*}
|
|
||||||
|
|
||||||
make mrproper
|
make mrproper
|
||||||
|
|
||||||
cp /boot/config-5.16.9 ./.config
|
if [ -f /boot/$CONFIGFILE ]
|
||||||
|
then
|
||||||
|
cp /boot/$CONFIGFILE ./.config
|
||||||
|
else
|
||||||
|
# if kernel config not provided, use default architecture config
|
||||||
|
make defconfig
|
||||||
|
fi
|
||||||
|
|
||||||
make
|
make
|
||||||
|
|
||||||
make modules_install
|
make modules_install
|
||||||
|
|
||||||
cp arch/x86_64/boot/bzImage /boot/vmlinuz-5.16.9-lfs-11.1
|
cp ./.config /boot/$CONFIGFILE
|
||||||
|
|
||||||
cp System.map /boot/System.map-5.16.9
|
cp arch/x86_64/boot/bzImage /boot/vmlinuz-$KERNELVERS-lfs-11.1
|
||||||
|
|
||||||
install -d /usr/share/doc/linux-5.16.9
|
cp System.map /boot/System.map-$KERNELVERS
|
||||||
cp -r Documentation/* /usr/share/doc/linux-5.16.9
|
|
||||||
|
|
||||||
cd /sources
|
install -d /usr/share/doc/linux-$KERNELVERS
|
||||||
rm -rf ${PKG_LINUX%.tar*}
|
cp -r Documentation/* /usr/share/doc/linux-$KERNELVERS
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user