source: install-blfs-tools.sh@ 2c603d8

ablfs-more legacy trunk
Last change on this file since 2c603d8 was 2c603d8, checked in by Pierre Labastie <pierre@…>, 6 years ago

Fix a few missing bits of the transition to the new menu subsystem

  • Property mode set to 100755
File size: 7.3 KB
Line 
1#!/bin/bash
2# $Id$
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_BRANCH_ID: development, branch-xxx, xxx (where xxx is a valid tag)
14 (default development)
15LFS_BRANCH_ID : development, branch-xxx, xxx (where xxx is a valid tag)
16 (default development)
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 [[ "$relSVN" = y ]] && BLFS_BRANCH_ID=development
71 [[ "$BRANCH" = y ]] && BLFS_BRANCH_ID=$BRANCH_ID
72 [[ "$WORKING_COPY" = y ]] && BLFS_BOOK=$BOOK
73 [[ "$BRANCH_ID" = "**EDIT ME**" ]] &&
74 echo You have not set the BLFS book version or branch && exit 1
75 [[ "$BOOK" = "**EDIT ME**" ]] &&
76 echo You have not set the BLFS working copy location && exit 1
77 [[ "$LFS_relSVN" = y ]] && LFS_BRANCH_ID=development
78 [[ "$LFS_BRANCH" = y ]] && LFS_BRANCH_ID=$BLFS_LFS_BRANCH_ID
79 [[ "$LFS_WORKING_COPY" = y ]] && LFS_BOOK=$BLFS_LFS_BOOK
80 [[ "$LFS_BRANCH_ID" = "**EDIT ME**" ]] &&
81 echo You have not set the LFS book version or branch && exit 1
82 [[ "$LFS_BOOK" = "**EDIT ME**" ]] &&
83 echo You have not set the LFS working copy location && exit 1
84fi
85
86COMMON_DIR="common"
87# blfs-tool envars
88BLFS_TOOL='y'
89BUILDDIR=$(cd ~;pwd)
90BLFS_ROOT="${BLFS_ROOT:=/blfs_root}"
91TRACKING_DIR="${TRACKING_DIR:=/var/lib/jhalfs/BLFS}"
92INITSYS="${INITSYS:=sysv}"
93BLFS_BRANCH_ID=${BLFS_BRANCH_ID:=development}
94LFS_BRANCH_ID=${LFS_BRANCH_ID:=development}
95BLFS_XML=${BLFS_XML:=blfs-xml}
96LFS_XML=${LFS_XML:=lfs-xml}
97
98# Validate the configuration:
99PARAMS="BLFS_ROOT TRACKING_DIR INITSYS BLFS_XML LFS_XML"
100if [ "$WORKING_COPY" = y ]; then
101 PARAMS="$PARAMS WORKING_COPY BLFS_BOOK"
102else
103 PARAMS="$PARAMS BLFS_BRANCH_ID"
104fi
105if [ "$LFS_WORKING_COPY" = y ]; then
106 PARAMS="$PARAMS LFS_WORKING_COPY LFS_BOOK"
107else
108 PARAMS="$PARAMS LFS_BRANCH_ID"
109fi
110# Format for displaying parameters:
111declare -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
112
113for config_param in $PARAMS; do
114 echo -e "`eval echo $PARAM_VALS`"
115done
116
117echo "${SD_BORDER}${nl_}"
118echo -n "Are you happy with these settings? yes/no (no): "
119read ANSWER
120if [ x$ANSWER != "xyes" ] ; then
121 echo "${nl_}Rerun make and fix your settings.${nl_}"
122 exit
123fi
124[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
125
126#*******************************************************************#
127[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh>..."
128source $COMMON_DIR/libs/func_check_version.sh
129[[ $? > 0 ]] && echo " function module did not load.." && exit 2
130[[ $VERBOSITY > 0 ]] && echo "OK"
131
132[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
133
134case $BLFS_BRANCH_ID in
135 development ) BLFS_TREE=trunk/BOOK ;;
136 branch-6.* ) BLFS_TREE=branches/${BLFS_BRANCH_ID#branch-}/BOOK ;;
137 branch-* ) BLFS_TREE=branches/${BLFS_BRANCH_ID#branch-} ;;
1386.2* | 7.* | 8.* ) BLFS_TREE=tags/${BLFS_BRANCH_ID} ;;
139 * ) BLFS_TREE=tags/${BLFS_BRANCH_ID}/BOOK ;;
140esac
141case $LFS_BRANCH_ID in
142 development ) LFS_TREE=trunk/BOOK ;;
143 branch-6.* ) LFS_TREE=branches/${LFS_BRANCH_ID#branch-}/BOOK ;;
144 branch-* ) LFS_TREE=branches/${LFS_BRANCH_ID#branch-} ;;
145 6.* ) LFS_TREE=tags/${LFS_BRANCH_ID}/BOOK ;;
146 * ) LFS_TREE=tags/${LFS_BRANCH_ID} ;;
147esac
148
149# Check for build prerequisites.
150echo
151 check_alfs_tools
152 check_blfs_tools
153echo "${SD_BORDER}${nl_}"
154
155# Install the files
156[[ $VERBOSITY > 0 ]] && echo -n Populating the ${BUILDDIR}${BLFS_ROOT} directory
157[[ ! -d ${BUILDDIR}${BLFS_ROOT} ]] && mkdir -pv ${BUILDDIR}${BLFS_ROOT}
158rm -rf ${BUILDDIR}${BLFS_ROOT}/*
159cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
160cp -r menu ${BUILDDIR}${BLFS_ROOT}
161cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
162cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
163[[ $VERBOSITY > 0 ]] && echo "... OK"
164
165# Clean-up
166[[ $VERBOSITY > 0 ]] && echo Cleaning the ${BUILDDIR}${BLFS_ROOT} directory
167rm -rf ${BUILDDIR}${BLFS_ROOT}/libs/.svn
168rm -rf ${BUILDDIR}${BLFS_ROOT}/xsl/.svn
169rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/.svn
170# We do not want to keep an old version of the book:
171rm -rf ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
172rm -rf ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
173
174# Set some harcoded envars to their proper values
175sed -i s@tracking-dir@$TRACKING_DIR@ \
176 ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh}
177
178# Ensures the tracking directory exists.
179# Throws an error if it does not exist and the user does not
180# have write permission to create it.
181# If it exists, does nothing.
182mkdir -p $TRACKING_DIR
183[[ $VERBOSITY > 0 ]] && echo "... OK"
184
185[[ $VERBOSITY > 0 ]] &&
186
187[[ -z "$BLFS_BOOK" ]] ||
188[[ $BLFS_BOOK = $BUILDDIR$BLFS_ROOT/$BLFS_XML ]] || {
189echo "Retrieving BLFS working copy (may take some time)" &&
190cp -a $BLFS_BOOK $BUILDDIR$BLFS_ROOT/$BLFS_XML
191}
192
193[[ -z "$LFS_BOOK" ]] ||
194[[ $LFS_BOOK = $BUILDDIR$BLFS_ROOT/$LFS_XML ]] || {
195echo "Retrieving the LFS working copy (may take some time)" &&
196cp -a $LFS_BOOK $BUILDDIR$BLFS_ROOT/$LFS_XML
197}
198
199make -j1 -C $BUILDDIR$BLFS_ROOT \
200 TRACKING_DIR=$TRACKING_DIR \
201 REV=$INITSYS \
202 LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
203 LFS-SVN=svn://svn.linuxfromscratch.org/LFS/$LFS_TREE \
204 BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
205 SVN=svn://svn.linuxfromscratch.org/BLFS/$BLFS_TREE \
206 $BUILDDIR$BLFS_ROOT/packages.xml
207[[ $VERBOSITY > 0 ]] && echo "... OK"
208
Note: See TracBrowser for help on using the repository browser.