mirror of
https://github.com/krizsipeti/custom_blfs_packages.git
synced 2025-01-23 05:52:22 +08:00
Added LFS setup script and syntax by shellcheck
This commit is contained in:
parent
44d6e1890f
commit
d48579d874
157
configuration
Normal file
157
configuration
Normal file
@ -0,0 +1,157 @@
|
||||
# Generated by Kconfiglib (https://github.com/ulfalizer/Kconfiglib)
|
||||
HAVE_NPROC=y
|
||||
|
||||
#
|
||||
# BOOK Settings
|
||||
#
|
||||
# BOOK_LFS is not set
|
||||
BOOK_LFS_SYSD=y
|
||||
# BOOK_BLFS is not set
|
||||
INITSYS="systemd"
|
||||
RUN_ME="./jhalfs run"
|
||||
BRANCH=y
|
||||
# WORKING_COPY is not set
|
||||
COMMIT="trunk"
|
||||
LFS_MULTILIB_NO=y
|
||||
# LFS_MULTILIB_I686 is not set
|
||||
# LFS_MULTILIB_X32 is not set
|
||||
# LFS_MULTILIB_ALL is not set
|
||||
MULTILIB="default"
|
||||
BUILD_CHROOT=y
|
||||
# BUILD_BOOT is not set
|
||||
METHOD="chroot"
|
||||
BLFS_TOOL=y
|
||||
|
||||
#
|
||||
# blfs-tool dependencies
|
||||
#
|
||||
DEP_LIBXML=y
|
||||
DEP_LIBXSLT=y
|
||||
DEP_DBXML=y
|
||||
DEP_LYNX=y
|
||||
DEP_SUDO=y
|
||||
DEP_WGET=y
|
||||
DEP_GPM=y
|
||||
DEP_GIT=y
|
||||
# end of blfs-tool dependencies
|
||||
|
||||
BLFS_BRANCH=y
|
||||
# BLFS_WORKING_COPY is not set
|
||||
BLFS_COMMIT="trunk"
|
||||
BLFS_ROOT="/blfs_root"
|
||||
BLFS_XML="blfs-xml"
|
||||
LFS_XML="lfs-xml"
|
||||
# CUSTOM_TOOLS is not set
|
||||
TRACKING_DIR="/var/lib/jhalfs/BLFS"
|
||||
# end of BOOK Settings
|
||||
|
||||
#
|
||||
# General Settings
|
||||
#
|
||||
LUSER="lfs"
|
||||
LGROUP="lfs"
|
||||
LHOME="/home"
|
||||
BUILDDIR="xxx"
|
||||
GETPKG=y
|
||||
SRC_ARCHIVE="$SRC_ARCHIVE"
|
||||
RETRYSRCDOWNLOAD=y
|
||||
RETRYDOWNLOADCNT=20
|
||||
DOWNLOADTIMEOUT=30
|
||||
# RUNMAKE is not set
|
||||
# CLEAN is not set
|
||||
# end of General Settings
|
||||
|
||||
#
|
||||
# Build Settings
|
||||
#
|
||||
|
||||
#
|
||||
# Parallelism settings
|
||||
#
|
||||
ALL_CORES=y
|
||||
# REALSBU is not set
|
||||
# end of Parallelism settings
|
||||
|
||||
# CONFIG_TESTS is not set
|
||||
TEST=0
|
||||
# PKGMNGT is not set
|
||||
# INSTALL_LOG is not set
|
||||
STRIP=y
|
||||
NO_PROGRESS_BAR=y
|
||||
# end of Build Settings
|
||||
|
||||
#
|
||||
# System configuration
|
||||
#
|
||||
HAVE_FSTAB=y
|
||||
FSTAB="xxx"
|
||||
CONFIG_BUILD_KERNEL=y
|
||||
CONFIG="xxx"
|
||||
# NCURSES5 is not set
|
||||
TIMEZONE="Europe/Budapest"
|
||||
LANG="hu_HU.UTF-8"
|
||||
FULL_LOCALE=y
|
||||
# PAGE_LETTER is not set
|
||||
PAGE_A4=y
|
||||
PAGE="A4"
|
||||
HOSTNAME="PKR-LINUX"
|
||||
|
||||
#
|
||||
# Network configuration
|
||||
#
|
||||
INTERFACE="eth0"
|
||||
IP_ADDR="192.168.1.82"
|
||||
GATEWAY="192.168.1.1"
|
||||
PREFIX="24"
|
||||
BROADCAST="192.168.1.255"
|
||||
DOMAIN="local"
|
||||
DNS1="192.168.1.1"
|
||||
DNS2="8.8.8.8"
|
||||
# end of Network configuration
|
||||
|
||||
#
|
||||
# Console configuration
|
||||
#
|
||||
FONT="lat2-16"
|
||||
KEYMAP="us"
|
||||
# LOCAL is not set
|
||||
# end of Console configuration
|
||||
# end of System configuration
|
||||
|
||||
#
|
||||
# Advanced Features
|
||||
#
|
||||
CONFIG_OPTIMIZE=y
|
||||
|
||||
#
|
||||
# Optimization settings
|
||||
#
|
||||
OPT_1=y
|
||||
# OPT_2 is not set
|
||||
# end of Optimization settings
|
||||
|
||||
OPTIMIZE=1
|
||||
# REPORT is not set
|
||||
# SAVE_CH5 is not set
|
||||
# COMPARE is not set
|
||||
|
||||
#
|
||||
# Internal Settings (WARNING: for jhalfs developers only)
|
||||
#
|
||||
SCRIPT_ROOT="jhalfs"
|
||||
JHALFSDIR="$BUILDDIR/$SCRIPT_ROOT"
|
||||
LOGDIRBASE="logs"
|
||||
LOGDIR="$JHALFSDIR/$LOGDIRBASE"
|
||||
TESTLOGDIRBASE="test-logs"
|
||||
TESTLOGDIR="$JHALFSDIR/$TESTLOGDIRBASE"
|
||||
FILELOGDIRBASE="installed-files"
|
||||
FILELOGDIR="$JHALFSDIR/$FILELOGDIRBASE"
|
||||
ICALOGDIR="$LOGDIR/ICA"
|
||||
MKFILE="$JHALFSDIR/Makefile"
|
||||
XSL="lfs.xsl"
|
||||
PKG_LST="unpacked"
|
||||
DEL_LA_FILES=y
|
||||
# end of Internal Settings (WARNING: for jhalfs developers only)
|
||||
# end of Advanced Features
|
||||
|
||||
# REBUILD_MAKEFILE is not set
|
139
lfsSetup.sh
Executable file
139
lfsSetup.sh
Executable file
@ -0,0 +1,139 @@
|
||||
#!/bin/bash
|
||||
# Script that setups LFS installer
|
||||
|
||||
set -e
|
||||
|
||||
# Helper function to pach the packages.ent
|
||||
# Parameters are in this order: major, minor, patch, md5 and full path to packages.ent
|
||||
patchKernelVersion()
|
||||
{
|
||||
if [ ! -f "$5" ] ; then
|
||||
echo "The packages.ent file is not exist or not defined." >&2
|
||||
echo "File: $5"
|
||||
return 4
|
||||
fi
|
||||
|
||||
sed -i -E "s@(<\!ENTITY linux-major-version \"+)(.+\">)@\1$1\">@" "$5"
|
||||
sed -i -E "s@(<\!ENTITY linux-minor-version \"+)(.+\">)@\1$2\">@" "$5"
|
||||
sed -i -E "s@(<\!ENTITY linux-md5 \"+)(.+\">)@\1$4\">@" "$5"
|
||||
|
||||
if [ "-" == "$3" ] ; then
|
||||
sed -i -E '/<!--/ n; /<\!ENTITY linux-patch-version "/{s/<!E/<!--<!E/g;s/">/">-->/g;}' "$5"
|
||||
sed -i -E '/linux-minor-version;">-->/{s/<!--//g;s/-->//g;}' "$5"
|
||||
sed -i -E '/<!--/ n; /linux-patch-version;">/{s/<!E/<!--<!E/g;s/;">/;">-->/g;}' "$5"
|
||||
else
|
||||
sed -i -E '/<!ENTITY linux-patch-version "/{s/<!--//g;s/-->//g;}' "$5"
|
||||
sed -i -E "s@(<\!ENTITY linux-patch-version \"+)(.+\">)@\1$3\">@" "$5"
|
||||
sed -i -E '/linux-patch-version;">-->/{s/<!--//g;s/-->//g;}' "$5"
|
||||
sed -i -E '/<!--/ n; /linux-minor-version;">/{s/<!E/<!--<!E/g;s/;">/;">-->/g;}' "$5"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if the lfs mount point folder is specified as the first argument
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Please specify the lfs mount point folder as the first argument!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the lfs folder is exists
|
||||
if [ ! -d "$1" ]
|
||||
then
|
||||
echo "LFS mount point folder does not exist!" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Check if jhalfs folder is already exist and delete it if yes
|
||||
DIR_JHALFS="$1/jhalfs"
|
||||
if [ -d "$DIR_JHALFS" ]
|
||||
then
|
||||
echo Deleting old jhalfs folder: "$DIR_JHALFS"
|
||||
sudo rm -rf "$DIR_JHALFS"
|
||||
echo Done!
|
||||
fi
|
||||
|
||||
# Now create the jhalfs folder and book-source sub-folder owned by the current user
|
||||
DIR_BOOK="$DIR_JHALFS/book-source"
|
||||
U="$(id -un)" # current user
|
||||
G="$(id -gn)" # current group
|
||||
echo Creating jhalfs folder...
|
||||
sudo install -v -o "$U" -g root -m 1777 -d "$DIR_JHALFS"
|
||||
sudo install -v -o "$U" -g "$G" -m 1777 -d "$DIR_BOOK"
|
||||
|
||||
# Clone the LFS book repository to book-source folder
|
||||
echo Cloning lfs book sources...
|
||||
git clone https://git.linuxfromscratch.org/lfs.git "$DIR_BOOK"
|
||||
|
||||
# Get the latest kernel version and download link from kernel.org
|
||||
echo Getting latest kernel from kernel.org...
|
||||
LATEST_KERNEL_URL="$(curl -v --silent https://www.kernel.org/ 2>&1 | sed -n '/<td id="latest_link">/{n; p}' | cut -d '"' -f 2)"
|
||||
LATEST_KERNEL_VER="$(cut -d '-' -f 2 <<< "$LATEST_KERNEL_URL" | rev | cut -c8- | rev)"
|
||||
echo Latest kernel version: "$LATEST_KERNEL_VER"
|
||||
echo Download URL: "$LATEST_KERNEL_URL"
|
||||
|
||||
# Check sources folder existence and create if needed
|
||||
DIR_SOURCES="$1/sources"
|
||||
if [ ! -d "$DIR_SOURCES" ] ; then
|
||||
sudo install -v -o "$U" -g "$G" -m 1777 -d "$DIR_SOURCES"
|
||||
else
|
||||
sudo chmod -v 1777 "$DIR_SOURCES"
|
||||
fi
|
||||
|
||||
# Download latest kernel if not done yet
|
||||
KERNEL_FILE_NAME="$(rev <<< "$LATEST_KERNEL_URL" | cut -d '/' -f1 | rev)"
|
||||
if [ ! -f "$DIR_SOURCES/$KERNEL_FILE_NAME" ] ; then
|
||||
echo Downloading kernel tar ball...
|
||||
wget -T 30 -t 5 --directory-prefix="$DIR_SOURCES" "$LATEST_KERNEL_URL"
|
||||
echo Done!
|
||||
fi
|
||||
|
||||
# Patch packages.ent with latest kernel
|
||||
MD5_SUM="$(md5sum "$DIR_SOURCES/$KERNEL_FILE_NAME" | cut -d ' ' -f 1)"
|
||||
NUM_VER_DOTS="$(awk -F. '{print NF-1}' <<< "$LATEST_KERNEL_VER")"
|
||||
if [ "2" == "$NUM_VER_DOTS" ] ; then
|
||||
MAIN_VER="$(awk -F. '{print $(NF-2)}' <<< "$LATEST_KERNEL_VER")"
|
||||
MINOR_VER="$(awk -F. '{print $(NF-1)}' <<< "$LATEST_KERNEL_VER")"
|
||||
PATCH_VER="$(awk -F. '{print $(NF)}' <<< "$LATEST_KERNEL_VER")"
|
||||
elif [ "1" == "$NUM_VER_DOTS" ] ; then
|
||||
MAIN_VER="$(awk -F. '{print $(NF-1)}' <<< "$LATEST_KERNEL_VER")"
|
||||
MINOR_VER="$(awk -F. '{print $(NF)}' <<< "$LATEST_KERNEL_VER")"
|
||||
PATCH_VER="-"
|
||||
else
|
||||
echo Invalid count of version dots: "$NUM_VER_DOTS" >&2
|
||||
echo Where version number is: "$LATEST_KERNEL_VER" >&2
|
||||
exit 3
|
||||
fi
|
||||
patchKernelVersion "$MAIN_VER" "$MINOR_VER" "$PATCH_VER" "$MD5_SUM" "$DIR_BOOK/packages.ent"
|
||||
|
||||
# Check if setup folder is already exist and delete it if yes
|
||||
DIR_SETUP="$1/setup"
|
||||
if [ -d "$DIR_SETUP" ]
|
||||
then
|
||||
echo Deleting old setup folder: "$DIR_SETUP"
|
||||
sudo rm -rf "$DIR_SETUP"
|
||||
echo Done!
|
||||
fi
|
||||
|
||||
# Now create the setup folder owned by the current user
|
||||
echo Creating setup folder...
|
||||
sudo install -v -o "$U" -g "$G" -m 755 -d "$DIR_SETUP"
|
||||
|
||||
# Clone the jhalfs repository to setup folder
|
||||
echo Cloning jhalfs sources...
|
||||
git clone https://git.linuxfromscratch.org/jhalfs.git "$DIR_SETUP"
|
||||
|
||||
# Patch opt_config to use -O3 -pipe -march=native
|
||||
echo Patching optimization config file...
|
||||
sed -i -E '/DEF_OPT_MODE=/s/noOpt/O3pipe_march/g' "$DIR_SETUP/optimize/opt_config"
|
||||
|
||||
# Copy jhalfs config file and adjust some settings in it
|
||||
cp -iv configuration "$DIR_SETUP/"
|
||||
echo Patching setup configuration file...
|
||||
FILE_CFG="$DIR_SETUP/configuration"
|
||||
sed -i -E "\@BUILDDIR=\"xxx\"@s@xxx@$1@g" "$FILE_CFG"
|
||||
sed -i -E "\@FSTAB=\"xxx\"@s@xxx@/home/$U/fstab@g" "$FILE_CFG"
|
||||
sed -i -E "\@CONFIG=\"xxx\"@s@xxx@/home/$U/config-$LATEST_KERNEL_VER@g" "$FILE_CFG"
|
||||
|
||||
# Enter to setup folder and start installer
|
||||
cd "$DIR_SETUP"
|
||||
yes "yes" | ./jhalfs run
|
44
rmscripts.sh
44
rmscripts.sh
@ -2,24 +2,42 @@
|
||||
# first parameter is the blfs tool's script folder
|
||||
# second parameter is the blfs tool's installed packages xml file
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Please specify the blfs tool's script folder as the first argument!"
|
||||
exit -1
|
||||
set -e
|
||||
|
||||
# Check if the script folder is specified as an argument
|
||||
if [ -z "$1" ] ; then
|
||||
echo "Please specify the blfs tool's script folder as the first argument!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]
|
||||
then
|
||||
echo "Please specify the blfs tool's installed packages xml file as the second argument!"
|
||||
exit -1
|
||||
# Check if the given script folder exists
|
||||
if [ ! -d "$1" ] ; then
|
||||
echo "The given script folder is not exist!" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ "$1" != */ ]]
|
||||
then
|
||||
SCRIPTPATH=$(echo "$1"/)
|
||||
# Check if the installed packages xml is specified as an argument
|
||||
if [ -z "$2" ] ; then
|
||||
echo "Please specify the blfs tool's installed packages xml file as the second argument!" >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Check if installed packages xml file exists
|
||||
if [ ! -f "$2" ] ; then
|
||||
echo "The given installed packages xml file is not exist!" >&2
|
||||
exit 4
|
||||
fi
|
||||
|
||||
# Add slash to script path if not there yet
|
||||
if [[ "$1" != */ ]] ; then
|
||||
SCRIPTPATH="$1/"
|
||||
else
|
||||
SCRIPTPATH="$1"
|
||||
fi
|
||||
|
||||
grep "$2" -f <(ls "$SCRIPTPATH" | awk -F'-z-' '{print "<name>"$2"</name>"}') | while read line ; do rm -v "$SCRIPTPATH"$(echo "$line" | sed 's/<name>/*-/g' | sed 's|</name>||g') ; done
|
||||
|
||||
# Find and remove all the scripts which would install a package that is already mentioned in the installed packages file
|
||||
grep "$2" -f <(find "$SCRIPTPATH" -type f -printf '%f\n' | awk -F'-z-' '{print "<name>"$2"</name>"}') | \
|
||||
while read -r line
|
||||
do
|
||||
rm -v "$(find "$SCRIPTPATH" -name "$(echo "$line" | sed 's/<name>/*-/g' | sed 's|</name>||g')" -type f)"
|
||||
done
|
||||
|
@ -1,47 +1,49 @@
|
||||
#!/bin/bash
|
||||
# This script checks and updates the latest versions of the packages
|
||||
|
||||
set -e
|
||||
|
||||
# Prints which package is about to update.
|
||||
greetMsg()
|
||||
{
|
||||
printf "\nUpdating package: $1\n"
|
||||
printf "\nUpdating package: %s\n" "$1"
|
||||
}
|
||||
|
||||
# Does the actual update of the package with the found version.
|
||||
updatePkg()
|
||||
{
|
||||
sed -i -E "s@($1-version \"+)(.+\">)@\1$2\">@" add_packages.sh
|
||||
sed -i -E "s@($1-download-http \"+)(.+\">)@\1$3\">@" ./$4/$1.xml
|
||||
sed -i -E "s@($1-download-http \"+)(.+\">)@\1$3\">@" ./"$4"/"$1".xml
|
||||
echo "Latest version: $2"
|
||||
printf "Found package: $3\n"
|
||||
printf "Found package: %s\n" "$3"
|
||||
}
|
||||
|
||||
# Function that gets the latest release of a specific package.
|
||||
# This function works only with packages stored on github.
|
||||
getLatestGithubRelease()
|
||||
{
|
||||
greetMsg $2
|
||||
URL=`curl -v --silent "https://github.com/$1/releases" 2>&1 | grep 'loading="lazy" src=' | tr '"' '\n' | grep /releases/ -m1`
|
||||
URL="https://github.com`curl -v --silent $URL 2>&1 | grep '<a href=' | grep '.tar.' -m1 | tr '"' '\n' | grep /releases/`"
|
||||
VER=`echo $URL | awk -F/ '{ print $(NF-1) }' | awk -F- '{ print $NF }'`
|
||||
greetMsg "$2"
|
||||
URL=$(curl -v --silent "https://github.com/$1/releases" 2>&1 | grep 'loading="lazy" src=' | tr '"' '\n' | grep /releases/ -m1)
|
||||
URL="https://github.com$(curl -v --silent "$URL" 2>&1 | grep '<a href=' | grep '.tar.' -m1 | tr '"' '\n' | grep /releases/)"
|
||||
VER=$(echo "$URL" | awk -F/ '{ print $(NF-1) }' | awk -F- '{ print $NF }')
|
||||
if [[ $4 ]]; then
|
||||
VER=`echo $VER | cut -c$4`
|
||||
VER=$(echo "$VER" | cut -c"$4")
|
||||
fi
|
||||
updatePkg $2 $VER $URL $3
|
||||
updatePkg "$2" "$VER" "$URL" "$3"
|
||||
}
|
||||
|
||||
# Function that gets the latest release of a specific package.
|
||||
# This function works only with packages stored on sourceforge.
|
||||
getLatestSourceforgeRelease()
|
||||
{
|
||||
greetMsg $2
|
||||
URL=`curl -v --silent "https://sourceforge.net/projects/$1/files/$2/" 2>&1 | grep net.sf.files | tr '"' '\n' | grep http -m1 | rev | cut -c10- | rev`
|
||||
VER=`echo $URL | awk -F/ '{ print $NF }'`
|
||||
greetMsg "$2"
|
||||
URL=$(curl -v --silent "https://sourceforge.net/projects/$1/files/$2/" 2>&1 | grep net.sf.files | tr '"' '\n' | grep http -m1 | rev | cut -c10- | rev)
|
||||
VER=$(echo "$URL" | awk -F/ '{ print $NF }')
|
||||
if [[ $4 ]]; then
|
||||
VER=`echo $VER | cut -c$4`
|
||||
VER=$(echo "$VER" | cut -c"$4")
|
||||
fi
|
||||
URL=$URL/$2-$VER.tar.gz
|
||||
updatePkg $2 $VER $URL $3
|
||||
updatePkg "$2" "$VER" "$URL" "$3"
|
||||
}
|
||||
|
||||
#minidlna
|
||||
|
Loading…
Reference in New Issue
Block a user