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-packages.sh 220059 2011-03-27 16:57:54Z jpaetzel $
27
28# Functions which runs commands on the system
29
30. ${BACKEND}/functions.sh
31. ${BACKEND}/functions-parse.sh
32. ${BACKEND}/functions-ftp.sh
33
34
--- 5 unchanged lines hidden (view full) ---
40 FTP_SERVER="${1}"
41 INDEX_FILE="INDEX"
42 USE_BZIP2=0
43
44 if [ -f "/usr/bin/bzip2" ]
45 then
46 INDEX_FILE="${INDEX_FILE}.bz2"
47 USE_BZIP2=1
48 fi
49
50 INDEX_PATH="${CONFDIR}/${INDEX_FILE}"
51 fetch_file "${FTP_SERVER}/${INDEX_FILE}" "${INDEX_PATH}" "1"
52 if [ -f "${INDEX_PATH}" ] && [ "${USE_BZIP2}" -eq "1" ]
53 then
54 bzip2 -d "${INDEX_PATH}"
55 fi
56};
57
58get_package_index_by_fs()
59{
60 local INDEX_FILE
61
62 INDEX_FILE="${CDMNT}/packages/INDEX"
63 fetch_file "${INDEX_FILE}" "${CONFDIR}/" "0"
64};
65
66get_package_index_size()
67{
68 if [ -f "${CONFDIR}/INDEX" ]
69 then
70 SIZE=`ls -l ${CONFDIR}/INDEX | awk '{ print $5 }'`
71 else
72 get_ftp_mirror
73 FTPHOST="${VAL}"
74
75 FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}"
76 FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages"
77
78 fetch -s "${FTPPATH}/INDEX.bz2"
--- 10 unchanged lines hidden (view full) ---
89 FTPHOST="${VAL}"
90
91 FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}"
92 FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages"
93
94 get_package_index_by_ftp "${FTPPATH}"
95
96 else
97 get_value_from_cfg ftpHost
98 if [ -z "$VAL" ]
99 then
100 exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
101 fi
102
103 FTPHOST="${VAL}"
104
105 get_value_from_cfg ftpDir
106 if [ -z "$VAL" ]
107 then
108 exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
109 fi
110
111 FTPDIR="${VAL}"
112 FTPPATH="ftp://${FTPHOST}${FTPDIR}"
113
114 case "${INSTALLMEDIUM}" in
115 usb|dvd) get_package_index_by_fs ;;
116 ftp) get_package_index_by_ftp "${FTPPATH}" ;;
117 sftp) ;;
118 *) RES=1 ;;
119 esac
120
121 fi
122
123 return ${RES}
124};
125
126parse_package_index()
127{
128 INDEX_FILE="${PKGDIR}/INDEX"
129
130 exec 3<&0
131 exec 0<"${INDEX_FILE}"
132
133 while read -r line
134 do
135 PKGNAME=""
136 CATEGORY=""
137 PACKAGE=""
138 DESC=""
139 DEPS=""
--- 112 unchanged lines hidden (view full) ---
252
253 return ${RES}
254};
255
256get_package_name()
257{
258 PACKAGE="${1}"
259 RES=0
260
261 INDEX_FILE="${PKGDIR}/INDEX.deps"
262 REGEX="^${PACKAGE}|"
263
264 LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
265 NAME=`echo "${LINE}"|cut -f2 -d'|'`
266
267 export VAL="${NAME}"
268
269 if [ -z "${VAL}" ]
270 then
271 RES=1
272 fi
273
274 return ${RES}
275};
276
277get_package_short_name()
278{
279 PACKAGE="${1}"
280 RES=0
281
--- 47 unchanged lines hidden (view full) ---
329
330 get_value_from_cfg ftpDir
331 if [ -z "$VAL" ]
332 then
333 exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
334 fi
335 FTPDIR="${VAL}"
336
337 PACKAGE="${PACKAGE}.tbz"
338 FTP_SERVER="ftp://${FTPHOST}${FTPDIR}"
339
340 if [ ! -f "${SAVEDIR}/${PACKAGE}" ]
341 then
342 PKGPATH="${CATEGORY}/${PACKAGE}"
343 FTP_PATH="${FTP_HOST}/packages/${PKGPATH}"
344 fetch_file "${FTP_PATH}" "${SAVEDIR}/" "0"
345 fi
346};
347
348fetch_package_by_fs()
349{
350 CATEGORY="${1}"
351 PACKAGE="${2}"
352 SAVEDIR="${3}"
353
354 PACKAGE="${PACKAGE}.tbz"
355 if [ ! -f "${SAVEDIR}/${PACKAGE}" ]
356 then
357 fetch_file "${CDMNT}/packages/${CATEGORY}/${PACKAGE}" "${SAVEDIR}/" "0"
358 fi
359};
360
361fetch_package()
362{
363 CATEGORY="${1}"
364 PACKAGE="${2}"
365 SAVEDIR="${3}"
366
367 case "${INSTALLMEDIUM}" in
368 usb|dvd) fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
369 ftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
370 sftp) ;;
371 esac
372};
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-packages.sh 220059 2011-03-27 16:57:54Z jpaetzel $
27
28# Functions which runs commands on the system
29
30. ${BACKEND}/functions.sh
31. ${BACKEND}/functions-parse.sh
32. ${BACKEND}/functions-ftp.sh
33
34
--- 5 unchanged lines hidden (view full) ---
40 FTP_SERVER="${1}"
41 INDEX_FILE="INDEX"
42 USE_BZIP2=0
43
44 if [ -f "/usr/bin/bzip2" ]
45 then
46 INDEX_FILE="${INDEX_FILE}.bz2"
47 USE_BZIP2=1
48 fi
49
50 INDEX_PATH="${CONFDIR}/${INDEX_FILE}"
51 fetch_file "${FTP_SERVER}/${INDEX_FILE}" "${INDEX_PATH}" "1"
52 if [ -f "${INDEX_PATH}" ] && [ "${USE_BZIP2}" -eq "1" ]
53 then
54 bzip2 -d "${INDEX_PATH}"
55 fi
56};
57
58get_package_index_by_fs()
59{
60 local INDEX_FILE
61
62 INDEX_FILE="${CDMNT}/packages/INDEX"
63 fetch_file "${INDEX_FILE}" "${CONFDIR}/" "0"
64};
65
66get_package_index_size()
67{
68 if [ -f "${CONFDIR}/INDEX" ]
69 then
70 SIZE=`ls -l ${CONFDIR}/INDEX | awk '{ print $5 }'`
71 else
72 get_ftp_mirror
73 FTPHOST="${VAL}"
74
75 FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}"
76 FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages"
77
78 fetch -s "${FTPPATH}/INDEX.bz2"
--- 10 unchanged lines hidden (view full) ---
89 FTPHOST="${VAL}"
90
91 FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}"
92 FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages"
93
94 get_package_index_by_ftp "${FTPPATH}"
95
96 else
97 get_value_from_cfg ftpHost
98 if [ -z "$VAL" ]
99 then
100 exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
101 fi
102
103 FTPHOST="${VAL}"
104
105 get_value_from_cfg ftpDir
106 if [ -z "$VAL" ]
107 then
108 exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
109 fi
110
111 FTPDIR="${VAL}"
112 FTPPATH="ftp://${FTPHOST}${FTPDIR}"
113
114 case "${INSTALLMEDIUM}" in
115 usb|dvd) get_package_index_by_fs ;;
116 ftp) get_package_index_by_ftp "${FTPPATH}" ;;
117 sftp) ;;
118 *) RES=1 ;;
119 esac
120
121 fi
122
123 return ${RES}
124};
125
126parse_package_index()
127{
128 INDEX_FILE="${PKGDIR}/INDEX"
129
130 exec 3<&0
131 exec 0<"${INDEX_FILE}"
132
133 while read -r line
134 do
135 PKGNAME=""
136 CATEGORY=""
137 PACKAGE=""
138 DESC=""
139 DEPS=""
--- 112 unchanged lines hidden (view full) ---
252
253 return ${RES}
254};
255
256get_package_name()
257{
258 PACKAGE="${1}"
259 RES=0
260
261 INDEX_FILE="${PKGDIR}/INDEX.deps"
262 REGEX="^${PACKAGE}|"
263
264 LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
265 NAME=`echo "${LINE}"|cut -f2 -d'|'`
266
267 export VAL="${NAME}"
268
269 if [ -z "${VAL}" ]
270 then
271 RES=1
272 fi
273
274 return ${RES}
275};
276
277get_package_short_name()
278{
279 PACKAGE="${1}"
280 RES=0
281
--- 47 unchanged lines hidden (view full) ---
329
330 get_value_from_cfg ftpDir
331 if [ -z "$VAL" ]
332 then
333 exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
334 fi
335 FTPDIR="${VAL}"
336
337 PACKAGE="${PACKAGE}.tbz"
338 FTP_SERVER="ftp://${FTPHOST}${FTPDIR}"
339
340 if [ ! -f "${SAVEDIR}/${PACKAGE}" ]
341 then
342 PKGPATH="${CATEGORY}/${PACKAGE}"
343 FTP_PATH="${FTP_HOST}/packages/${PKGPATH}"
344 fetch_file "${FTP_PATH}" "${SAVEDIR}/" "0"
345 fi
346};
347
348fetch_package_by_fs()
349{
350 CATEGORY="${1}"
351 PACKAGE="${2}"
352 SAVEDIR="${3}"
353
354 PACKAGE="${PACKAGE}.tbz"
355 if [ ! -f "${SAVEDIR}/${PACKAGE}" ]
356 then
357 fetch_file "${CDMNT}/packages/${CATEGORY}/${PACKAGE}" "${SAVEDIR}/" "0"
358 fi
359};
360
361fetch_package()
362{
363 CATEGORY="${1}"
364 PACKAGE="${2}"
365 SAVEDIR="${3}"
366
367 case "${INSTALLMEDIUM}" in
368 usb|dvd) fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
369 ftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
370 sftp) ;;
371 esac
372};