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