xref: /freebsd/usr.sbin/bsdconfig/examples/browse_packages_http.sh (revision f4b37ed0f8b307b1f3f0f630ca725d68f1dff30d)
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
14nonInteractive=1
15f_musthavepkg_init # Make sure we have a usable pkg(8) with $PKG_ABI
16TMPDIR=/tmp
17PKGDIR=$TMPDIR/packages/$PKG_ABI
18[ -d "$PKGDIR" ] || mkdir -p "$PKGDIR" || exit 1
19for 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
29done
30_directoryPath=$TMPDIR
31mediaSetDirectory
32configPackages
33