Deleted Added
full compact
functions-extractimage.sh (211487) functions-extractimage.sh (211730)
1#!/bin/sh
2#-
3# Copyright (c) 2010 iXsystems, Inc. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
1#!/bin/sh
2#-
3# Copyright (c) 2010 iXsystems, Inc. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh 211487 2010-08-19 06:02:31Z imp $
26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh 211730 2010-08-24 06:11:46Z imp $
27
28# Functions which perform the extraction / installation of system to disk
29
30. ${BACKEND}/functions-mountoptical.sh
31
32# Performs the extraction of data to disk from a uzip or tar archive
33start_extract_uzip_tar()
34{

--- 14 unchanged lines hidden (view full) ---

49 TAROPTS="-X ${PROGDIR}/conf/exclude-from-upgrade"
50 else
51 TAROPTS=""
52 fi
53
54 echo_log "pc-sysinstall: Starting Extraction"
55
56 case ${PACKAGETYPE} in
27
28# Functions which perform the extraction / installation of system to disk
29
30. ${BACKEND}/functions-mountoptical.sh
31
32# Performs the extraction of data to disk from a uzip or tar archive
33start_extract_uzip_tar()
34{

--- 14 unchanged lines hidden (view full) ---

49 TAROPTS="-X ${PROGDIR}/conf/exclude-from-upgrade"
50 else
51 TAROPTS=""
52 fi
53
54 echo_log "pc-sysinstall: Starting Extraction"
55
56 case ${PACKAGETYPE} in
57 uzip) # Start by mounting the uzip image
58 MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}`
59 mkdir -p ${FSMNT}.uzip
60 mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip
61 if [ "$?" != "0" ]
62 then
63 exit_err "ERROR: Failed mounting the ${INSFILE}"
64 fi
65 cd ${FSMNT}.uzip
57 uzip)
58 # Start by mounting the uzip image
59 MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}`
60 mkdir -p ${FSMNT}.uzip
61 mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip
62 if [ "$?" != "0" ]
63 then
64 exit_err "ERROR: Failed mounting the ${INSFILE}"
65 fi
66 cd ${FSMNT}.uzip
66
67
67 # Copy over all the files now!
68 tar cvf - . 2>/dev/null | tar -xpv -C ${FSMNT} ${TAROPTS} -f - 2>&1 | tee -a ${FSMNT}/.tar-extract.log
69 if [ "$?" != "0" ]
70 then
71 cd /
72 echo "TAR failure occured:" >>${LOGOUT}
73 cat ${FSMNT}/.tar-extract.log | grep "tar:" >>${LOGOUT}
74 umount ${FSMNT}.uzip
75 mdconfig -d -u ${MDDEVICE}
76 exit_err "ERROR: Failed extracting the tar image"
77 fi
68 # Copy over all the files now!
69 tar cvf - . 2>/dev/null | tar -xpv -C ${FSMNT} ${TAROPTS} -f - 2>&1 | tee -a ${FSMNT}/.tar-extract.log
70 if [ "$?" != "0" ]
71 then
72 cd /
73 echo "TAR failure occured:" >>${LOGOUT}
74 cat ${FSMNT}/.tar-extract.log | grep "tar:" >>${LOGOUT}
75 umount ${FSMNT}.uzip
76 mdconfig -d -u ${MDDEVICE}
77 exit_err "ERROR: Failed extracting the tar image"
78 fi
78
79
79 # All finished, now lets umount and cleanup
80 cd /
81 umount ${FSMNT}.uzip
82 mdconfig -d -u ${MDDEVICE}
83 ;;
84 tar) tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1
85 if [ "$?" != "0" ]
86 then
87 exit_err "ERROR: Failed extracting the tar image"
88 fi
89 ;;
80 # All finished, now lets umount and cleanup
81 cd /
82 umount ${FSMNT}.uzip
83 mdconfig -d -u ${MDDEVICE}
84 ;;
85 tar)
86 tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1
87 if [ "$?" != "0" ]
88 then
89 exit_err "ERROR: Failed extracting the tar image"
90 fi
91 ;;
90 esac
91
92 # Check if this was a FTP download and clean it up now
93 if [ "${INSTALLMEDIUM}" = "ftp" ]
94 then
95 echo_log "Cleaning up downloaded archive"
96 rm ${INSFILE}
97 rm ${INSFILE}.count >/dev/null 2>/dev/null

--- 17 unchanged lines hidden (view full) ---

115 # Used by install.sh
116 DESTDIR="${FSMNT}"
117 export DESTDIR
118
119 HERE=`pwd`
120 DIRS=`ls -d ${INSDIR}/*|grep -Ev '(uzip|kernels|src)'`
121 for dir in ${DIRS}
122 do
92 esac
93
94 # Check if this was a FTP download and clean it up now
95 if [ "${INSTALLMEDIUM}" = "ftp" ]
96 then
97 echo_log "Cleaning up downloaded archive"
98 rm ${INSFILE}
99 rm ${INSFILE}.count >/dev/null 2>/dev/null

--- 17 unchanged lines hidden (view full) ---

117 # Used by install.sh
118 DESTDIR="${FSMNT}"
119 export DESTDIR
120
121 HERE=`pwd`
122 DIRS=`ls -d ${INSDIR}/*|grep -Ev '(uzip|kernels|src)'`
123 for dir in ${DIRS}
124 do
123 cd "${dir}"
124 if [ -f "install.sh" ]
125 then
126 echo_log "Extracting" `basename ${dir}`
125 cd "${dir}"
126 if [ -f "install.sh" ]
127 then
128 echo_log "Extracting" `basename ${dir}`
127 echo "y" | sh install.sh >/dev/null
128 if [ "$?" != "0" ]
129 then
130 exit_err "ERROR: Failed extracting ${dir}"
131 fi
132 else
133 exit_err "ERROR: ${dir}/install.sh does not exist"
134 fi
135 done
136 cd "${HERE}"
137
138 KERNELS=`ls -d ${INSDIR}/*|grep kernels`
139 cd "${KERNELS}"
140 if [ -f "install.sh" ]
141 then
129 echo "y" | sh install.sh >/dev/null
130 if [ "$?" != "0" ]
131 then
132 exit_err "ERROR: Failed extracting ${dir}"
133 fi
134 else
135 exit_err "ERROR: ${dir}/install.sh does not exist"
136 fi
137 done
138 cd "${HERE}"
139
140 KERNELS=`ls -d ${INSDIR}/*|grep kernels`
141 cd "${KERNELS}"
142 if [ -f "install.sh" ]
143 then
142 echo_log "Extracting" `basename ${KERNELS}`
144 echo_log "Extracting" `basename ${KERNELS}`
143 echo "y" | sh install.sh generic >/dev/null
144 if [ "$?" != "0" ]
145 then
146 exit_err "ERROR: Failed extracting ${KERNELS}"
147 fi
145 echo "y" | sh install.sh generic >/dev/null
146 if [ "$?" != "0" ]
147 then
148 exit_err "ERROR: Failed extracting ${KERNELS}"
149 fi
148 echo 'kernel="GENERIC"' > "${FSMNT}/boot/loader.conf"
150 mv "${FSMNT}/boot/GENERIC" "${FSMNT}/boot/kernel"
149 else
150 exit_err "ERROR: ${KERNELS}/install.sh does not exist"
151 fi
152 cd "${HERE}"
153
154 SOURCE=`ls -d ${INSDIR}/*|grep src`
155 cd "${SOURCE}"
156 if [ -f "install.sh" ]
157 then
151 else
152 exit_err "ERROR: ${KERNELS}/install.sh does not exist"
153 fi
154 cd "${HERE}"
155
156 SOURCE=`ls -d ${INSDIR}/*|grep src`
157 cd "${SOURCE}"
158 if [ -f "install.sh" ]
159 then
158 echo_log "Extracting" `basename ${SOURCE}`
160 echo_log "Extracting" `basename ${SOURCE}`
159 echo "y" | sh install.sh all >/dev/null
160 if [ "$?" != "0" ]
161 then
162 exit_err "ERROR: Failed extracting ${SOURCE}"
163 fi
164 else
165 exit_err "ERROR: ${SOURCE}/install.sh does not exist"
166 fi

--- 34 unchanged lines hidden (view full) ---

201 # Done fetching, now reset the INSFILE to our downloaded archived
202 INSFILE="${OUTFILE}" ; export INSFILE
203
204};
205
206# Function which will download freebsd install files
207fetch_split_files()
208{
161 echo "y" | sh install.sh all >/dev/null
162 if [ "$?" != "0" ]
163 then
164 exit_err "ERROR: Failed extracting ${SOURCE}"
165 fi
166 else
167 exit_err "ERROR: ${SOURCE}/install.sh does not exist"
168 fi

--- 34 unchanged lines hidden (view full) ---

203 # Done fetching, now reset the INSFILE to our downloaded archived
204 INSFILE="${OUTFILE}" ; export INSFILE
205
206};
207
208# Function which will download freebsd install files
209fetch_split_files()
210{
209 get_value_from_cfg ftpHost
211 get_ftpHost
210 if [ -z "$VAL" ]
211 then
212 exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
213 fi
214 FTPHOST="${VAL}"
215
212 if [ -z "$VAL" ]
213 then
214 exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
215 fi
216 FTPHOST="${VAL}"
217
216 get_value_from_cfg ftpDir
218 get_ftpDir
217 if [ -z "$VAL" ]
218 then
219 exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
220 fi
221 FTPDIR="${VAL}"
222
223 # Check if we have a /usr partition to save the download
224 if [ -d "${FSMNT}/usr" ]
225 then
226 OUTFILE="${FSMNT}/usr/.fetch-${INSFILE}"
227 else
228 OUTFILE="${FSMNT}/.fetch-${INSFILE}"
229 fi
230
219 if [ -z "$VAL" ]
220 then
221 exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
222 fi
223 FTPDIR="${VAL}"
224
225 # Check if we have a /usr partition to save the download
226 if [ -d "${FSMNT}/usr" ]
227 then
228 OUTFILE="${FSMNT}/usr/.fetch-${INSFILE}"
229 else
230 OUTFILE="${FSMNT}/.fetch-${INSFILE}"
231 fi
232
233 DIRS="base catpages dict doc games info manpages proflibs kernels src"
234 if [ "${FBSD_ARCH}" = "amd64" ]
235 then
236 DIRS="${DIRS} lib32"
237 fi
238
239 for d in ${DIRS}
240 do
241 mkdir -p "${OUTFILE}/${d}"
242 done
243
244
231 NETRC="${OUTFILE}/.netrc"
232 cat<<EOF>"${NETRC}"
233machine ${FTPHOST}
234login anonymous
235password anonymous
236macdef INSTALL
237bin
238prompt
239EOF
240
245 NETRC="${OUTFILE}/.netrc"
246 cat<<EOF>"${NETRC}"
247machine ${FTPHOST}
248login anonymous
249password anonymous
250macdef INSTALL
251bin
252prompt
253EOF
254
241 DIRS="base catpages dict doc games info manpages proflibs kernels src"
242 if [ "${FBSD_ARCH}" = "amd64" ]
243 then
244 DIRS="${DIRS} lib32"
245 fi
246
247 for d in ${DIRS}
248 do
255 for d in ${DIRS}
256 do
249 cat<<EOF>>"${NETRC}"
257 cat<<EOF>>"${NETRC}"
250cd ${FTPDIR}/${d}
251lcd ${OUTFILE}/${d}
252mreget *
253EOF
254 done
255
258cd ${FTPDIR}/${d}
259lcd ${OUTFILE}/${d}
260mreget *
261EOF
262 done
263
256 cat<<EOF>>"${NETRC}"
264 cat<<EOF>>"${NETRC}"
257bye
258
259
260EOF
261
262 # Fetch the files via ftp
263 echo "$ INSTALL" | ftp -N "${NETRC}" "${FTPHOST}"
264

--- 65 unchanged lines hidden (view full) ---

330 if [ ! -z "${VAL}" ]
331 then
332 INSFILE="${VAL}" ; export INSFILE
333 else
334 # If no installFile specified, try our defaults
335 if [ "$INSTALLTYPE" = "FreeBSD" ]
336 then
337 case $PACKAGETYPE in
265bye
266
267
268EOF
269
270 # Fetch the files via ftp
271 echo "$ INSTALL" | ftp -N "${NETRC}" "${FTPHOST}"
272

--- 65 unchanged lines hidden (view full) ---

338 if [ ! -z "${VAL}" ]
339 then
340 INSFILE="${VAL}" ; export INSFILE
341 else
342 # If no installFile specified, try our defaults
343 if [ "$INSTALLTYPE" = "FreeBSD" ]
344 then
345 case $PACKAGETYPE in
338 uzip) INSFILE="${FBSD_UZIP_FILE}" ;;
339 tar) INSFILE="${FBSD_TAR_FILE}" ;;
340 split)
341 INSDIR="${FBSD_BRANCH_DIR}"
346 uzip) INSFILE="${FBSD_UZIP_FILE}" ;;
347 tar) INSFILE="${FBSD_TAR_FILE}" ;;
348 split)
349 INSDIR="${FBSD_BRANCH_DIR}"
342
350
343 # This is to trick opt_mount into not failing
344 INSFILE="${INSDIR}"
345 ;;
351 # This is to trick opt_mount into not failing
352 INSFILE="${INSDIR}"
353 ;;
346 esac
347 else
348 case $PACKAGETYPE in
354 esac
355 else
356 case $PACKAGETYPE in
349 uzip) INSFILE="${UZIP_FILE}" ;;
350 tar) INSFILE="${TAR_FILE}" ;;
357 uzip) INSFILE="${UZIP_FILE}" ;;
358 tar) INSFILE="${TAR_FILE}" ;;
351 esac
352 fi
353 export INSFILE
354 fi
355
356 # Lets start by figuring out what medium we are using
357 case ${INSTALLMEDIUM} in
359 esac
360 fi
361 export INSFILE
362 fi
363
364 # Lets start by figuring out what medium we are using
365 case ${INSTALLMEDIUM} in
358 dvd|usb) # Lets start by mounting the disk
359 opt_mount
360 if [ ! -z "${INSDIR}" ]
361 then
362 INSDIR="${CDMNT}/${INSDIR}" ; export INSDIR
363 start_extract_split
366 dvd|usb)
367 # Lets start by mounting the disk
368 opt_mount
369 if [ ! -z "${INSDIR}" ]
370 then
371 INSDIR="${CDMNT}/${INSDIR}" ; export INSDIR
372 start_extract_split
364
373
365 else
366 INSFILE="${CDMNT}/${INSFILE}" ; export INSFILE
367 start_extract_uzip_tar
368 fi
369 ;;
370 ftp)
371 if [ "$PACKAGETYPE" = "split" ]
372 then
373 fetch_split_files
374 else
375 INSFILE="${CDMNT}/${INSFILE}" ; export INSFILE
376 start_extract_uzip_tar
377 fi
378 ;;
374
379
375 INSDIR="${INSFILE}" ; export INSDIR
376 start_extract_split
377 else
378 fetch_install_file
379 start_extract_uzip_tar
380 fi
381 ;;
382 rsync) start_rsync_copy
383 ;;
384 *) exit_err "ERROR: Unknown install medium" ;;
380 ftp|sftp)
381 if [ "$PACKAGETYPE" = "split" ]
382 then
383 fetch_split_files
384
385 INSDIR="${INSFILE}" ; export INSDIR
386 start_extract_split
387 else
388 fetch_install_file
389 start_extract_uzip_tar
390 fi
391 ;;
392
393 rsync) start_rsync_copy ;;
394 img)
395 ;;
396 *) exit_err "ERROR: Unknown install medium" ;;
385 esac
386
387};
397 esac
398
399};