1
|
#!/bin/sh
|
2
|
# Functions which check and load any optional modules specified in the config
|
3
|
|
4
|
. ${BACKEND}/functions.sh
|
5
|
. ${BACKEND}/functions-parse.sh
|
6
|
|
7
|
copy_component()
|
8
|
{
|
9
|
COMPONENT="$1"
|
10
|
FAILED="0"
|
11
|
CFILES=""
|
12
|
|
13
|
# Check the type, and set the components subdir properly
|
14
|
TYPE="`grep 'type:' ${COMPDIR}/${COMPONENT}/component.cfg | cut -d ' ' -f 2`"
|
15
|
if [ "${TYPE}" = "PBI" ]
|
16
|
then
|
17
|
SUBDIR="PBI"
|
18
|
else
|
19
|
SUBDIR="components"
|
20
|
fi
|
21
|
|
22
|
# Lets start by downloading / copying the files this component needs
|
23
|
while read line
|
24
|
do
|
25
|
CFILE="`echo $line | cut -d ':' -f 1`"
|
26
|
CFILEMD5="`echo $line | cut -d ':' -f 2`"
|
27
|
CFILE2MD5="`echo $line | cut -d ':' -f 3`"
|
28
|
|
29
|
|
30
|
case ${INSTALLMEDIUM} in
|
31
|
dvd|usb) # On both dvd / usb, we can just copy the file
|
32
|
cp ${CDMNT}/${COMPFILEDIR}/${SUBDIR}/${CFILE} \
|
33
|
${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
|
34
|
RESULT="$?"
|
35
|
;;
|
36
|
ftp) get_value_from_cfg ftpPath
|
37
|
if [ -z "$VAL" ]
|
38
|
then
|
39
|
exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!"
|
40
|
fi
|
41
|
FTPPATH="${VAL}"
|
42
|
|
43
|
fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0"
|
44
|
RESULT="$?"
|
45
|
;;
|
46
|
esac
|
47
|
|
48
|
if [ "${RESULT}" != "0" ]
|
49
|
then
|
50
|
echo_log "WARNING: Failed to copy ${CFILE}"
|
51
|
FAILED="1"
|
52
|
else
|
53
|
# Now lets check the MD5 to confirm the file is valid
|
54
|
CHECKMD5=`md5 -q ${FSMNT}/${COMPTMPDIR}/${CFILE}`
|
55
|
if [ "${CHECKMD5}" != "${CFILEMD5}" -a "${CHECKMD5}" != "${CFILE2MD5}" ]
|
56
|
then
|
57
|
echo_log "WARNING: ${CFILE} failed md5 checksum"
|
58
|
FAILED="1"
|
59
|
else
|
60
|
if [ -z "${CFILES}" ]
|
61
|
then
|
62
|
CFILES="${CFILE}"
|
63
|
else
|
64
|
CFILES="${CFILES},${CFILE}"
|
65
|
fi
|
66
|
fi
|
67
|
fi
|
68
|
|
69
|
|
70
|
done < ${COMPDIR}/${COMPONENT}/distfiles
|
71
|
|
72
|
if [ "${FAILED}" = "0" ]
|
73
|
then
|
74
|
# Now install the component
|
75
|
run_component_install ${COMPONENT} ${CFILES}
|
76
|
fi
|
77
|
|
78
|
};
|
79
|
|
80
|
run_component_install()
|
81
|
{
|
82
|
COMPONENT="$1"
|
83
|
CFILES="$1"
|
84
|
|
85
|
# Lets install this component now
|
86
|
# Start by making a wrapper script which sets the variables
|
87
|
# for the component to use
|
88
|
echo "#!/bin/sh
|
89
|
COMPTMPDIR=\"${COMPTMPDIR}\"
|
90
|
export COMPTMPDIR
|
91
|
CFILE=\"${CFILE}\"
|
92
|
export CFILE
|
93
|
|
94
|
sh ${COMPTMPDIR}/install.sh
|
95
|
|
96
|
" >${FSMNT}/.componentwrapper.sh
|
97
|
chmod 755 ${FSMNT}/.componentwrapper.sh
|
98
|
|
99
|
# Copy over the install script for this component
|
100
|
cp ${COMPDIR}/${COMPONENT}/install.sh ${FSMNT}/${COMPTMPDIR}/
|
101
|
|
102
|
echo_log "INSTALL COMPONENT: ${i}"
|
103
|
chroot ${FSMNT} /.componentwrapper.sh >>${LOGOUT} 2>>${LOGOUT}
|
104
|
rm ${FSMNT}/.componentwrapper.sh
|
105
|
|
106
|
|
107
|
};
|
108
|
|
109
|
# Check for any modules specified, and begin loading them
|
110
|
install_components()
|
111
|
{
|
112
|
# First, lets check and see if we even have any optional modules
|
113
|
get_value_from_cfg installComponents
|
114
|
if [ ! -z "${VAL}" ]
|
115
|
then
|
116
|
# Lets start by cleaning up the string and getting it ready to parse
|
117
|
strip_white_space ${VAL}
|
118
|
COMPONENTS=`echo ${VAL} | sed -e "s|,| |g"`
|
119
|
for i in $COMPONENTS
|
120
|
do
|
121
|
if [ ! -e "${COMPDIR}/${i}/install.sh" -o ! -e "${COMPDIR}/${i}/distfiles" ]
|
122
|
then
|
123
|
echo_log "WARNING: Component ${i} doesn't seem to exist"
|
124
|
else
|
125
|
|
126
|
# Make the tmpdir on the disk
|
127
|
mkdir -p ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
|
128
|
|
129
|
# Start by grabbing the component files
|
130
|
copy_component ${i}
|
131
|
|
132
|
# Remove the tmpdir now
|
133
|
rm -rf ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
|
134
|
|
135
|
fi
|
136
|
done
|
137
|
|
138
|
fi
|
139
|
|
140
|
};
|