]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - usr.sbin/bsdconfig/examples/browse_packages_http.sh
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / usr.sbin / bsdconfig / examples / browse_packages_http.sh
1 #!/bin/sh
2 # $FreeBSD$
3 #
4 # This sample downloads the package digests.txz and packagesite.txz files from
5 # HTTP to /tmp (if they don't already exist) and then displays the package
6 # configuration/management screen using the local files (resulting in faster
7 # browsing of packages from-start since digests.txz/packagesite.txz can be
8 # loaded from local media).
9 #
10 # NOTE: Packages cannot be installed unless staged to
11 #       /tmp/packages/$PKG_ABI/All
12 #
13 [ "$_SCRIPT_SUBR" ] || . /usr/share/bsdconfig/script.subr || exit 1
14 nonInteractive=1
15 f_musthavepkg_init # Make sure we have a usable pkg(8) with $PKG_ABI
16 TMPDIR=/tmp
17 PKGDIR=$TMPDIR/packages/$PKG_ABI
18 [ -d "$PKGDIR" ] || mkdir -p "$PKGDIR" || exit 1
19 for file in digests.txz packagesite.txz; do
20         [ -s "$PKGDIR/$file" ] && continue
21         if [ ! "$HTTP_INITIALIZED" ]; then
22                 _httpPath=http://pkg.freebsd.org
23                 mediaSetHTTP
24                 mediaOpen
25         fi
26         f_show_info "Downloading %s from\n %s" "$file" "$_httpPath"
27         f_device_get device_media "/$PKG_ABI/latest/$file" > $PKGDIR/$file ||
28                 exit 1
29 done
30 _directoryPath=$TMPDIR
31 mediaSetDirectory
32 configPackages