source: install-blfs-tools.sh@ 875366f

ablfs-more trunk
Last change on this file since 875366f was 9b99ada, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Change variable names and logic for BLFS book

Only use BLFS_COMMIT instead of BLFS_BRANCH_ID, BLFS_TREE, BLFS_BOOK
Same for le LFS_BLFS variables

  • Property mode set to 100755
File size: 6.3 KB
Line 
1#!/bin/bash
2
3set -e
4
5: << inline_doc
6Installs a set-up to build BLFS packages.
7You can set these variables:
8TRACKING_DIR : where the installed package file is kept.
9 (default /var/lib/jhalfs/BLFS)
10INITSYS : which books do you want? 'sysv' or 'systemd' (default sysv)
11BLFS_ROOT : where the installed tools will be installed, relative to $HOME.
12 Must start with a '/' (default /blfs_root)
13BLFS_COMMIT : any commit (branch/tag/sha)
14 (default trunk)
15LFS_COMMIT : any commit (branch/tag/sha)
16 (default trunk)
17Examples:
181 - If you plan to use the tools to build BLFS on top of LFS, but you did not
19use jhalfs, or forgot to include the jhalfs-blfs tools:
20(as root) mkdir -p /var/lib/jhalfs/BLFS && chown -R <user> /var/lib/jhalfs
21(as user) INITSYS=<your system> ./install-blfs-tools.sh
222 - To install with only user privileges (default to sysv):
23TRACKING_DIR=$HOME/blfs_root/trackdir ./install-blfs-tools.sh
24
25This script can also be called automatically after running make in this
26directory. The parameters will then be taken from the configuration file.
27inline_doc
28
29
30# VT100 colors
31declare -r BLACK=$'\e[1;30m'
32declare -r DK_GRAY=$'\e[0;30m'
33
34declare -r RED=$'\e[31m'
35declare -r GREEN=$'\e[32m'
36declare -r YELLOW=$'\e[33m'
37declare -r BLUE=$'\e[34m'
38declare -r MAGENTA=$'\e[35m'
39declare -r CYAN=$'\e[36m'
40declare -r WHITE=$'\e[37m'
41
42declare -r OFF=$'\e[0m'
43declare -r BOLD=$'\e[1m'
44declare -r REVERSE=$'\e[7m'
45declare -r HIDDEN=$'\e[8m'
46
47declare -r tab_=$'\t'
48declare -r nl_=$'\n'
49
50declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
51declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
52declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
53declare -r dotSTR=".................." # Format display of parameters and versions
54
55# bold yellow > < pair
56declare -r R_arrow=$'\e[1;33m>\e[0m'
57declare -r L_arrow=$'\e[1;33m<\e[0m'
58VERBOSITY=1
59
60# Take parameters from "configuration" if $1="auto"
61if [ "$1" = auto ]; then
62 [[ $VERBOSITY > 0 ]] && echo -n "Loading configuration ... "
63 source configuration
64 [[ $? > 0 ]] && echo -e "\nconfiguration could not be loaded" && exit 2
65 [[ $VERBOSITY > 0 ]] && echo "OK"
66fi
67
68if [ "$BOOK_BLFS" = y ]; then
69## Read variables and sanity checks
70 [[ "$BRANCH" = y ]] && BLFS_COMMIT=$COMMIT
71 [[ "$WORKING_COPY" = y ]] && BLFS_BOOK=$BOOK
72 [[ "$BOOK" = "**EDIT ME**" ]] &&
73 echo You have not set the BLFS working copy location && exit 1
74 [[ "$LFS_BRANCH" = y ]] && LFS_COMMIT=$BLFS_LFS_COMMIT
75 [[ "$LFS_WORKING_COPY" = y ]] && LFS_BOOK=$BLFS_LFS_BOOK
76 [[ "$LFS_BOOK" = "**EDIT ME**" ]] &&
77 echo You have not set the LFS working copy location && exit 1
78fi
79
80COMMON_DIR="common"
81# blfs-tool envars
82BLFS_TOOL='y'
83BUILDDIR=$(cd ~;pwd)
84BLFS_ROOT="${BLFS_ROOT:=/blfs_root}"
85TRACKING_DIR="${TRACKING_DIR:=/var/lib/jhalfs/BLFS}"
86INITSYS="${INITSYS:=sysv}"
87BLFS_COMMIT=${BLFS_COMMIT:=trunk}
88LFS_COMMIT=${LFS_COMMIT:=trunk}
89BLFS_XML=${BLFS_XML:=blfs-xml}
90LFS_XML=${LFS_XML:=lfs-xml}
91
92# Validate the configuration:
93PARAMS="BLFS_ROOT TRACKING_DIR INITSYS BLFS_XML LFS_XML"
94if [ "$WORKING_COPY" = y ]; then
95 PARAMS="$PARAMS WORKING_COPY BLFS_BOOK"
96else
97 PARAMS="$PARAMS BLFS_COMMIT"
98fi
99if [ "$LFS_WORKING_COPY" = y ]; then
100 PARAMS="$PARAMS LFS_WORKING_COPY LFS_BOOK"
101else
102 PARAMS="$PARAMS LFS_COMMIT"
103fi
104# Format for displaying parameters:
105declare -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
106
107for config_param in $PARAMS; do
108 echo -e "`eval echo $PARAM_VALS`"
109done
110
111echo "${SD_BORDER}${nl_}"
112echo -n "Are you happy with these settings? yes/no (no): "
113read ANSWER
114if [ x$ANSWER != "xyes" ] ; then
115 echo "${nl_}Rerun make and fix your settings.${nl_}"
116 exit
117fi
118[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
119
120#*******************************************************************#
121[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh> ..."
122source $COMMON_DIR/libs/func_check_version.sh
123[[ $? > 0 ]] && echo " function module did not load.." && exit 2
124[[ $VERBOSITY > 0 ]] && echo " OK"
125
126[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
127
128# Check for build prerequisites.
129echo
130 check_alfs_tools
131echo "${SD_BORDER}${nl_}"
132
133# Install the files
134[[ $VERBOSITY > 0 ]] && echo -n "Populating the ${BUILDDIR}${BLFS_ROOT} directory "
135[[ ! -d ${BUILDDIR}${BLFS_ROOT} ]] && mkdir -pv ${BUILDDIR}${BLFS_ROOT}
136rm -rf ${BUILDDIR}${BLFS_ROOT}/*
137cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
138cp -r menu ${BUILDDIR}${BLFS_ROOT}
139cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
140cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
141[[ $VERBOSITY > 0 ]] && echo "... OK"
142
143# Clean-up
144[[ $VERBOSITY > 0 ]] && echo -n "Cleaning the ${BUILDDIR}${BLFS_ROOT} directory "
145# We do not want to keep an old version of the book:
146rm -rf ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
147rm -rf ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
148
149# Set some harcoded envars to their proper values
150sed -i s@tracking-dir@$TRACKING_DIR@ \
151 ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh,gen_pkg_book.sh}
152
153# Ensures the tracking directory exists.
154# Throws an error if it does not exist and the user does not
155# have write permission to create it.
156# If it exists, does nothing.
157mkdir -p $TRACKING_DIR
158[[ $VERBOSITY > 0 ]] && echo "... OK"
159
160[[ -z "$BLFS_BOOK" ]] ||
161[[ $BLFS_BOOK = $BUILDDIR$BLFS_ROOT/$BLFS_XML ]] || {
162[[ $VERBOSITY > 0 ]] && echo -n "Retrieving BLFS working copy (may take some time) "
163cp -a $BLFS_BOOK $BUILDDIR$BLFS_ROOT/$BLFS_XML
164[[ $VERBOSITY > 0 ]] && echo "... OK"
165}
166
167[[ -z "$LFS_BOOK" ]] ||
168[[ $LFS_BOOK = $BUILDDIR$BLFS_ROOT/$LFS_XML ]] || {
169[[ $VERBOSITY > 0 ]] && echo -n "Retrieving the LFS working copy (may take some time) "
170cp -a $LFS_BOOK $BUILDDIR$BLFS_ROOT/$LFS_XML
171[[ $VERBOSITY > 0 ]] && echo "... OK"
172}
173
174[[ $VERBOSITY > 0 ]] && echo "Initializing the BLFS tool directory "
175make -j1 -C $BUILDDIR$BLFS_ROOT \
176 TRACKING_DIR=$TRACKING_DIR \
177 REV=$INITSYS \
178 LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
179 LFS-BRANCH=${LFS_COMMIT} \
180 BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
181 BLFS-BRANCH=${BLFS_COMMIT} \
182 $BUILDDIR$BLFS_ROOT/packages.xml
183[[ $VERBOSITY > 0 ]] && echo "... OK"
184
Note: See TracBrowser for help on using the repository browser.