source: install-blfs-tools.sh@ 085739c

new_features
Last change on this file since 085739c was 50618eeb, checked in by Pierre Labastie <pierre@…>, 8 years ago

Add the possibility to choose build and source dirs, and whether subdirs are
used in blfs tools, + various fixes

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