LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Building LFS v7.5-rc1 via scripts (https://www.linuxquestions.org/questions/linux-from-scratch-13/building-lfs-v7-5-rc1-via-scripts-4175495291/)

stoat 02-17-2014 06:05 PM

Building LFS v7.5-rc1 via scripts
 
I know some folks here routinely build with scripts. I've used scripts occasionally and just for certain parts. But today I'm doing the whole rc1 thing with scripts. I just wondered how other people do that and how they create their scripts. For example, one huge script doesn't seem to be practical since it will stop when new shells are opened. I ended up with about five of them. And how do others create their build scripts? This time I printed the nochunks book to a text file and manually turned it into scripts by deleting everything that wasn't a command. I created pauses after tests and resumed if they were okay. And so on. It worked well and pretty quick since I could read it at the same time. The third one is running now. It would be nice though to have some killer sed command to fish out the commands from the html version using the tags. It is possible?

ReaperX7 02-17-2014 06:23 PM

I thoroughly read the book and draft Bash scripts for batch works. Works very well and all I have to do is execute each script in sequence. Easy as pie.

Keith Hedger 02-18-2014 04:02 PM

I used to do a similar thing, one script for the tools, one for the basic system, one to create the filesystem and kernel, one for xorg etc, it does make correcting mistakes easier as you just correct the script and re-run it.

ReaperX7 02-18-2014 09:42 PM

Yep, once you have all the bugs worked out, you can create a master batch script, execute it, walk away, and come back four hours later to a brand new OS.

Johnburrell 02-19-2014 01:03 PM

"It would be nice though to have some killer sed command to fish out the commands from the html version using the tags. It is possible?"

Why don't you download the xml files from svn and use the included Makefile to create the commands? This will create dirs lfs-commands and lfs-html. You can then use the lfs-commands dir to build your scripts.

jb.

Keith Hedger 02-22-2014 10:04 AM

Quote:

Originally Posted by Johnburrell (Post 5121065)
...Why don't you download the xml files from svn and use the included Makefile to create the commands? This will create dirs lfs-commands and lfs-html. You can then use the lfs-commands dir to build your scripts.

Didn't know I could do that! Thanks for that tip it will make it LOTS easier to update my build scripts, Thanks.

Johnburrell 02-22-2014 12:17 PM

This is the function in my script that gets the book

Quote:

CheckoutSVN () {
local bookdir=$1
local book_version=$2
#
Url="${SVN_URL}${type}/${book_version}"
Tag=$book_version
#
echo "Will svn the LFS book at $Url"
echo "and place it in ${bookdir}/${Tag}"
svn co $Url ${bookdir}/${Tag} # get the requested book
#
} # end CheckoutSVN
where:

SVN_URL="svn://svn.linuxfromscratch.org/LFS/"
type = trunk, branches or tags, depending on which book is requested.

As you can see, you specify which book in $Url and store it on you machine at ${bookdir}/${Tag}

HTH

jb.

Lennie 02-23-2014 12:53 AM

Quote:

Originally Posted by Johnburrell (Post 5121065)
Why don't you download the xml files from svn and use the included Makefile to create the commands? This will create dirs lfs-commands and lfs-html. You can then use the lfs-commands dir to build your scripts.

When I run make I didn't get the dir lfs-commands. Should one run a different command for that? I didn't find it in the README or install files.

Keith Hedger 02-23-2014 07:25 AM

Code:

make dump-commands
Always handy to look at the Makefile and see what bits can be made/installed, a lot of Makefiles have different targets to do different thing and not every thing is built with just 'make'.

Johnburrell 02-23-2014 05:48 PM

Here is how I make lfs-commands and lfs-html:

Quote:

# need to define these somewhere in your script
DumpedCommands=${LFS}/lfs-commands
Dumpedhtml=${LFS}/lfs-html
#
DumpCommands () {
# $1 is the Repository - LFS in this case
local bookdir=$2
local book_version=$3
if [ "$book_version" = systemd ]; then book_version="systemd/BOOK/"; fi
#
REPODIR=${bookdir}/${book_version}
target=$( echo $1 | awk '{print tolower($1)}')
SVNINFO="$(svn info $REPODIR | awk '{printf $0"|"}')"
SVNrevision=$( echo $SVNINFO | awk 'BEGIN{ RS = "|" };/Revision/ {print $0}' )
#
for dir in $DumpedCommands
do
if [ ! -d $dir ]; then
install -vd $dir
install -vd $Dumpedhtml
touch ${dir}/.revision
fi
done
#
for dir in $DumpedCommands
do
if [ -e "$dir" -a "$SVNrevision" != "$( cat $dir/.revision | awk '/Revision/ {print $0}')" ]; then
rm -rf $dir # remove these dirs if they exist but are not the latest revision
rm -rf $Dumpedhtml
install -d $dir
install -d $Dumpedhtml
pushd $REPODIR
make -j1 DUMPDIR=$DumpedCommands BASEDIR=$Dumpedhtml $target dump-commands
for dir in $DumpedCommands $Dumpedhtml
do
echo $SVNINFO | awk 'BEGIN{ RS = "|" }; {print $0}' > ${dir}/.revision
done
popd
break
fi
done
} # end of DumpCommands

jb.

ReaperX7 02-23-2014 10:25 PM

I've never relied on a dumper to extract commands from the book for a good reason. There are extra commands in the book(s) meant for x86 PCs rather than x64 as well as sample commands as well, that don't often need to be ran on various systems.


All times are GMT -5. The time now is 05:32 AM.