Replace pkg-tools with pkgng.

This commit is contained in:
Devin Teske 2013-11-07 12:40:42 +00:00
parent 3d5fedd33e
commit 632d9a080c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=257795
5 changed files with 266 additions and 77 deletions

View File

@ -49,7 +49,7 @@ msg_assume_yes_to_all_non_critical_dialogs="Assume \"Yes\" answers to all non-cr
msg_astro_desc="Applications related to astronomy."
msg_attempt_automatic_dhcp_configuration="Attempt automatic DHCP configuration of interfaces"
msg_attempt_ipv6_configuration_of_interfaces="Attempt IPv6 configuration of interfaces"
msg_attempting_to_fetch_file_from_selected_media="Attempting to fetch %s file from selected media."
msg_attempting_to_update_repository_catalogue="Attempting to update repository catalogue from selected media."
msg_audio_desc="Audio utilities - most require a supported sound card."
msg_australia="Australia"
msg_austria="Austria"
@ -138,9 +138,12 @@ msg_ftp_desc="FTP client and server utilities."
msg_ftp_passive="FTP Passive"
msg_ftp_username="FTP username"
msg_games_desc="Various games and sundry amusements."
msg_generating_index_from_pkg_database="Generating INDEX from pkg(8) database\n(this can take a while)..."
msg_geography_desc="Geography-related software."
msg_german_desc="Ported software for Germanic countries."
msg_germany="Germany"
msg_getting_package_categories_via_pkg_rquery="Getting package categories via pkg-rquery(8)..."
msg_getting_package_dependencies_via_pkg_rquery="Getting package dependencyes via pkg-rquery(8)\n(this can take a while)..."
msg_gnome_desc="Components of the Gnome Desktop environment."
msg_gnustep_desc="Software for GNUstep desktop environment."
msg_graphics_desc="Graphics libraries and utilities."
@ -176,7 +179,7 @@ msg_invalid_name_server_ip_address_specified="Invalid name server IP address spe
msg_invalid_netmask_value="Invalid netmask value"
msg_invalid_nfs_path_specification="Invalid NFS path specification. Must be of the form:\nhost:/full/pathname/to/FreeBSD/distdir"
msg_io_error_while_reading_in_the_package="I/O error while reading in the %s package."
msg_io_or_format_error_on_index_file="I/O or format error on %s file.\nPlease verify media (or path to media) and try again."
msg_io_or_format_error_on_index_file="I/O or format error on INDEX file.\nPlease verify media (or path to media) and try again."
msg_ipv4_address="IPv4 Address"
msg_ipv4_gateway="IPv4 Gateway"
msg_ipv6="IPv6"
@ -246,6 +249,7 @@ msg_no_gateway_has_been_set="No gateway has been set. You will be unable to acce
msg_no_network_devices="No network devices available!"
msg_no_package_name_passed_in_package_variable="No package name passed in package variable"
msg_no_packages_were_selected_for_extraction="No packages were selected for extraction."
msg_no_pkg_database_found="No pkg(8) database found!"
msg_no_such_file_or_directory="%s: %s: No such file or directory"
msg_no_usb_devices_found="No USB devices found (try Options/Re-scan Devices)"
msg_no_username="No username provided!"
@ -257,10 +261,9 @@ msg_ok="OK"
msg_options="Options"
msg_options_editor="Options Editor"
msg_other="other"
msg_pkg_delete_failed="Warning: pkg_delete of %s failed.\n Run with debugging for details."
msg_pkg_delete_failed="Warning: pkg-delete(8) of %s failed.\n Run with debugging for details."
msg_package_is_needed_by_other_installed_packages="Warning: Package %s is needed by\n %d other installed package%s."
msg_package_not_installed_cannot_delete="Warning: package %s not installed\n No package can be deleted."
msg_package_read_successfully_waiting_for_pkg_add="Package %s read successfully - waiting for pkg_add(1)"
msg_package_temp="Package Temp"
msg_package_was_added_successfully="Package %s was added successfully"
msg_packages="packages"
@ -270,7 +273,7 @@ msg_parallel_desc="Applications dealing with parallelism in computing."
msg_pear_desc="Software related to the Pear PHP framework."
msg_perl5_desc="Utilities/modules for the PERL5 language."
msg_permission_denied="%s: %s: Permission denied"
msg_pkg_add_apparently_did_not_like_the_package="pkg_add(1) apparently did not like the %s package."
msg_pkg_install_apparently_did_not_like_the_package="pkg-install(8) apparently did not like the %s package."
msg_plan9_desc="Software from the Plan9 operating system."
msg_please_check_the_url_and_try_again="No such directory: %s\nplease check the URL and try again.\n"
msg_please_enter_password="Please enter your password for sudo(8):"
@ -372,10 +375,13 @@ msg_unable_to_get_file_from_selected_media="Unable to get %s file from selected
msg_unable_to_get_proper_ftp_path="Unable to get proper FTP path. FTP media not initialized."
msg_unable_to_initialize_media_type_for_package_extract="Unable to initialize media type for package extract."
msg_unable_to_make_directory_mountpoint="Unable to make %s directory mountpoint for %s!"
msg_unable_to_pkg_rquery_package_dependeices="Unable to pkg-rquery(8) package dependencies!"
msg_unable_to_pkg_rquery_package_categories="Unable to pkg-rquery(8) package categories!"
msg_unable_to_open="Unable to open %s"
msg_unable_to_update_pkg_from_selected_media="Unable to update pkg(8) from selected media."
msg_uninstall="Uninstall"
msg_uninstall_desc="Mark this package for deletion"
msg_uninstalling_package_waiting_for_pkg_delete="Uninstalling %s package - waiting for pkg_delete(1)"
msg_uninstalling_package_waiting_for_pkg_delete="Uninstalling %s package - waiting for pkg-delete(8)"
msg_unknown="unknown"
msg_unknown_user="Unknown user: %s"
msg_url_was_not_found="%s was not found, maybe directory or release-version are wrong?"

View File

@ -60,7 +60,15 @@ FAILURE=1
#
export UNAME_S="$(uname -s)" # Operating System (i.e. FreeBSD)
export UNAME_P="$(uname -p)" # Processor Architecture (i.e. i386)
export UNAME_M="$(uname -m)" # Machine platform (i.e. i386)
export UNAME_R="$(uname -r)" # Release Level (i.e. X.Y-RELEASE)
if [ ! "$UNAME_PKG" ]; then
case "$UNAME_M:$UNAME_P" in
i386:i386) UNAME_PKG="x86:32" ;;
amd64:amd64) UNAME_PKG="x86:64" ;;
*) UNAME_PKG="$UNAME_M:$UNAME_P"
esac
fi
#
# Default behavior is to call f_debug_init() automatically when loaded.

View File

@ -77,7 +77,8 @@ f_dialog_menu_media_http()
f_dialog_title_restore
local prompt="$msg_please_select_the_site_closest_to_you_or_other"
local menu_list="
'$msg_main_site' 'ftp.freebsd.org'
'dist $msg_main_site' 'ftp.freebsd.org'
'pkg $msg_main_site' 'pkg.freebsd.org'
'URL' '$msg_specify_some_other_http_site'
" # END-QUOTE
local hline="$msg_select_a_site_thats_close"
@ -321,7 +322,7 @@ f_media_set_http()
device_http set type $DEVICE_TYPE_HTTP
device_http set init f_media_init_http
device_http set get f_media_get_http
device_http set shutdown :
device_http set shutdown f_media_shutdown_http
device_http set private network
f_struct_copy device_http device_media
f_struct_free device_http
@ -452,6 +453,11 @@ f_media_init_http()
local dev="$1"
f_dprintf "Init routine called for HTTP device. dev=[%s]" "$dev"
if [ "$HTTP_INITIALIZED" ]; then
f_dprintf "HTTP device already initialized."
return $SUCCESS
fi
#
# First verify access
#
@ -493,22 +499,31 @@ f_media_init_http()
#
local fdir hp
f_getvar $VAR_HTTP_PATH%/ hp
for fdir in $HTTP_DIRS; do
setvar $VAR_HTTP_PATH "$hp/$fdir/$rel"
if f_http_check_access; then
http_found=$SUCCESS
break
fi
done
setvar $VAR_HTTP_PATH \
"$hp/freebsd:${UNAME_R%%.*}:$UNAME_PKG/latest"
if f_http_check_access; then
http_found=$SUCCESS
else
for fdir in $HTTP_DIRS; do
setvar $VAR_HTTP_PATH "$hp/$fdir/$rel"
if f_http_check_access; then
http_found=$SUCCESS
break
fi
done
fi
esac
[ $http_found -eq $SUCCESS ] && break
if [ $http_found -eq $SUCCESS ]; then
HTTP_INITIALIZED=YES
break
fi
f_getvar $VAR_HTTP_PATH http_path
f_show_msg "$msg_please_check_the_url_and_try_again" \
"$http_path"
unset $VAR_HTTP_PATH
unset HTTP_INITIALIZED $VAR_HTTP_PATH
f_media_set_http || break
done
@ -558,6 +573,11 @@ f_media_get_http()
f_getvar $VAR_HTTP_HOST http_host
f_getvar $VAR_HTTP_PORT http_port
if [ ! "$HTTP_INITIALIZED" ]; then
f_dprintf "No HTTP connection open, can't get file %s" "$file"
return $FAILURE
fi
if ! {
f_validate_ipaddr "$http_host" ||
f_validate_ipaddr6 "$http_host" ||
@ -649,6 +669,18 @@ f_media_get_http()
return $FAILURE
}
# f_media_shutdown_http $device
#
# Shuts down the HTTP device. Return status should be ignored. Note that since
# we don't maintain an open connection to the HTTP server, nothing to do.
#
f_media_shutdown_http()
{
[ "$HTTP_INITIALIZED" ] || return $SUCCESS
unset HTTP_INITIALIZED
}
############################################################ MAIN
f_dprintf "%s: Successfully loaded." media/http.subr

View File

@ -43,24 +43,52 @@ f_include_lang $BSDCFG_LIBE/include/messages.subr
PACKAGE_INDEX=
_INDEX_INITTED=
#
# Default path to pkg(8) repo-packagesite.sqlite database
#
SQLITE_REPO="/var/db/pkg/repo-packagesite.sqlite"
#
# Default path to on-disk cache INDEX file
#
PACKAGES_INDEX_CACHEFILE="/var/run/bsdconfig/packages_INDEX.cache"
#
# INDEX format for FreeBSD-6.0 or higher:
#
# package|port-origin|install-prefix|comment|port-desc-file|maintainer|
# categories|build-deps|run-deps|www-site|reserve|reserve|reserve|disc
#
INDEX_FORMAT="%n-%v" # package
INDEX_FORMAT="$INDEX_FORMAT|/usr/ports/%o" # port-origin
INDEX_FORMAT="$INDEX_FORMAT|%p" # install-prefix
INDEX_FORMAT="$INDEX_FORMAT|%c" # comment
INDEX_FORMAT="$INDEX_FORMAT|/usr/ports/%o/pkg-descr" # port-desc-file
INDEX_FORMAT="$INDEX_FORMAT|%m" # maintainer
INDEX_FORMAT="$INDEX_FORMAT|@CATEGORIES@" # place-holder
INDEX_FORMAT="$INDEX_FORMAT|" # build-deps
INDEX_FORMAT="$INDEX_FORMAT|@RUNDEPS@" # place-holder
INDEX_FORMAT="$INDEX_FORMAT|%w" # www-site
INDEX_FORMAT="$INDEX_FORMAT|" # reserved
INDEX_FORMAT="$INDEX_FORMAT|" # reserved
INDEX_FORMAT="$INDEX_FORMAT|" # reserved
INDEX_FORMAT="$INDEX_FORMAT|" # disc
############################################################ FUNCTIONS
# f_index_initialize $path [$var_to_set]
# f_index_initialize [$var_to_set]
#
# Read and initialize the global index. $path is to be relative to the chosen
# media (not necessarily the filesystem; e.g. FTP) -- this is usually going to
# be `packages/INDEX'. Returns success unless media cannot be initialized for
# any reason (e.g. user cancels media selection dialog) or an error occurs. The
# index is sorted before being loaded into $var_to_set.
# Read and initialize the global index. Returns success unless media cannot be
# initialized for any reason (e.g. user cancels media selection dialog or an
# error occurs). The index is sorted before being loaded into $var_to_set.
#
# NOTE: The index is processed with f_index_read() [below] after being loaded.
#
f_index_initialize()
{
local __path="$1" __var_to_set="${2:-PACKAGE_INDEX}"
local __var_to_set="${2:-PACKAGE_INDEX}"
[ "$_INDEX_INITTED" ] && return $SUCCESS
[ "$__path" ] || return $FAILURE
# Got any media?
f_media_verify || return $FAILURE
@ -68,20 +96,163 @@ f_index_initialize()
# Does it move when you kick it?
f_device_init media || return $FAILURE
f_show_info "$msg_attempting_to_fetch_file_from_selected_media" \
"$__path"
eval "$__var_to_set"='$( f_device_get media "$__path" )'
if [ $? -ne $SUCCESS ]; then
f_show_msg "$msg_unable_to_get_file_from_selected_media" \
"$__path"
f_show_info "$msg_attempting_to_update_repository_catalogue"
#
# Generate $PACKAGESITE variable for pkg(8) based on media type
#
local __type __data __site
device_media get type __type
device_media get private __data
case "$__type" in
$DEVICE_TYPE_UFS|$DEVICE_TYPE_DISK) __site="file://$MOUNTPOINT" ;;
$DEVICE_TYPE_DIRECTORY) __site="file://$__data" ;;
$DEVICE_TYPE_FLOPPY) __site="file://${__data:-$MOUNTPOINT}" ;;
$DEVICE_TYPE_FTP) f_getvar $VAR_FTP_PATH __site ;;
$DEVICE_TYPE_HTTP_PROXY) f_getvar $VAR_HTTP_PROXY_PATH __site ;;
$DEVICE_TYPE_HTTP) f_getvar $VAR_HTTP_PATH __site ;;
$DEVICE_TYPE_CDROM) __site="file://$MOUNTPOINT" ;;
$DEVICE_TYPE_USB) __site="file://$MOUNTPOINT" ;;
$DEVICE_TYPE_DOS) __site="file://$MOUNTPOINT" ;;
$DEVICE_TYPE_NFS) __site="file://$MOUNTPOINT" ;;
esac
if ! PACKAGESITE="$__site" f_quietly pkg update; then
f_show_err "$msg_unable_to_update_pkg_from_selected_media"
f_device_shutdown media
return $FAILURE
fi
#
# Try to get contents from validated on-disk cache
#
#
# Calculate digest used to determine if the on-disk persistant cache
# INDEX (containing this digest on the first line) is valid and can be
# used to quickly populate the environment.
#
local __sqlite_digest
if ! __sqlite_digest=$( md5 < "$SQLITE_REPO" 2> /dev/null ); then
f_show_err "$msg_no_pkg_database_found"
f_device_shutdown media
return $FAILURE
fi
#
# Check to see if the persistant cache INDEX file exists
#
if [ -f "$PACKAGES_INDEX_CACHEFILE" ]; then
#
# Attempt to populate the environment with the (soon to be)
# validated on-disk cache. If validation fails, fall-back to
# generating a fresh cache.
#
if eval $__var_to_set='$(
( # Get digest as the first word on first line
read digest rest_ignored
#
# If the stored digest matches the calculated-
# one populate the environment from the on-disk
# cache and provide success exit status.
#
if [ "$digest" = "$__sqlite_digest" ]; then
cat
exit $SUCCESS
else
# Otherwise, return the current value
eval echo \"\$__var_to_set\"
exit $FAILURE
fi
) < "$PACKAGES_INDEX_CACHEFILE" 2> /dev/null
)'; then
f_show_info \
"$msg_located_index_now_reading_package_data_from_it"
if ! f_index_read "$__var_to_set"; then
f_show_err \
"$msg_io_or_format_error_on_index_file"
return $FAILURE
fi
_INDEX_INITTED=1
return $SUCCESS
fi
# Otherwise, fall-thru to create a fresh cache from scratch
fi
#
# If we reach this point, we need to generate the data from scratch
#
f_show_info "$msg_getting_package_categories_via_pkg_rquery"
if ! eval "$( pkg rquery "%n-%v %C" | awk '
{ categories[$1] = categories[$1] " " $2 }
END {
for (package in categories)
{
cats = categories[package]
sub(/^ /, "", cats)
gsub(/[^[:alnum:]_]/, "_", package)
printf "local _%s_categories=\"%s\";\n", package, cats
}
}' )"; then
f_show_err "$msg_unable_to_pkg_rquery_package_dependeices"
f_device_shutdown media
return $FAILURE
fi
f_show_info "$msg_getting_package_dependencies_via_pkg_rquery"
if ! eval "$( pkg rquery "%n-%v %dn-%dv" | awk '
{ rundeps[$1] = rundeps[$1] " " $2 }
END {
for (package in rundeps)
{
deps = rundeps[package]
sub(/^ /, "", deps)
gsub(/[^[:alnum:]_]/, "_", package)
printf "local _%s_rundeps=\"%s\";\n", package, deps
}
}' )"; then
f_show_err "$msg_unable_to_pkg_rquery_package_dependeices"
f_device_shutdown media
return $FAILURE
fi
f_show_info "$msg_generating_index_from_pkg_database"
eval "$__var_to_set"='$( pkg rquery "$INDEX_FORMAT" |
while read LINE; do
package="${LINE%%|*}";
f_str2varname "$package" varpkg;
eval f_replaceall \"\$LINE\" \"\|@CATEGORIES@\|\" \
\"\|\$_${varpkg}_categories\|\" LINE
eval f_replaceall \"\$LINE\" \"\|@RUNDEPS@\|\" \
\"\|\$_${varpkg}_rundeps\|\" LINE
echo "$LINE"
done
)' # always returns true (status of last item in pipe-chain)
eval "$__var_to_set"='$( debug= f_getvar "$__var_to_set" | sort )'
#
# Attempt to create the persistant on-disk cache
#
# Create a new temporary file to write to
local __tmpfile="$( mktemp -t "$pgm" )"
if [ "$__tmpfile" ]; then
# Write the temporary file contents
echo "$__sqlite_digest" > "$__tmpfile"
debug= f_getvar "$__var_to_set" >> "$__tmpfile"
# Finally, move the temporary file into place
case "$PACKAGES_INDEX_CACHEFILE" in
*/*) f_quietly mkdir -p "${PACKAGES_INDEX_CACHEFILE%/*}"
esac
f_quietly mv -f "$__tmpfile" "$PACKAGES_INDEX_CACHEFILE"
fi
f_show_info "$msg_located_index_now_reading_package_data_from_it"
if ! f_index_read "$__var_to_set"; then
f_show_msg "$msg_io_or_format_error_on_index_file" "$__path"
f_show_err "$msg_io_or_format_error_on_index_file"
return $FAILURE
fi

View File

@ -53,7 +53,7 @@ f_include_lang $BSDCFG_LIBE/include/messages.subr
#
# Package extensions to try
#
PACKAGE_EXTENSIONS=".tbz .tbz2 .tgz"
PACKAGE_EXTENSIONS=".txz .tbz .tbz2 .tgz"
#
# Variables used to track runtime states
@ -164,24 +164,13 @@ f_package_deselect()
# f_package_detect_installed
#
# Detect installed packages. Currently this searches /var/db/pkg for directory
# Detect installed packages. Currently this uses pkg-query(8) for querying
# entries and marks each entry as an installed/selected package.
#
f_package_detect_installed()
{
local installed package varpkg
#
# XXX KLUDGE ALERT! This makes evil assumptions about how XXX
# packages register themselves and should *really* be done with
# `pkg_info -e <name>' except that this is too slow for an
# item check routine.. :-(
#
# NOTE: When transitioning to pkgng, make a single fork to `pkg' to
# produce a list of all installed packages and parse _that_
#
installed=$( find -s /var/db/pkg -mindepth 1 -maxdepth 1 -type d |
sed -e 's:/var/db/pkg/::' )
for package in $installed; do
local package varpkg
for package in $( pkg query "%n-%v" ); do
f_str2varname $package varpkg
export _mark_$varpkg=X # exported for awk(1) ENVIRON[]
f_package_select $package
@ -985,14 +974,10 @@ f_package_extract()
local path
case "$name" in
*/*) path="$name" ;;
*)
case "$name" in
*-*|*_*) path="packages/All/$name" ;;
*) path="packages/Latest/$name"
esac
*) path="All/$name" ;;
esac
# We have a path, call the device strategy routine to get the file
# We have a path, call the device strategy routine to check the file
local pkg_ext found=
for pkg_ext in "" $PACKAGE_EXTENSIONS; do
if f_device_get $device "$path$pkg_ext" $PROBE_EXIST; then
@ -1017,7 +1002,7 @@ f_package_extract()
return $FAILURE
fi
local devname=
local orphan devname=
f_struct device_$device get name devname
if [ "$depended" ]; then
f_show_info "$msg_adding_package_as_a_dependency_from_media" \
@ -1026,27 +1011,14 @@ f_package_extract()
f_show_info "$msg_adding_package_from_media" "$name" "$devname"
fi
# Get package data and pipe into pkg_add(1) while providing feedback
{
if ! f_device_get $device "$path"; then
$alert "$msg_io_error_while_reading_in_the_package" \
"$name" \
>&$DIALOG_TERMINAL_PASSTHRU_FD 2> /dev/null
[ "$no_confirm" ] && sleep 2
else
f_show_info \
"$msg_package_read_successfully_waiting_for_pkg_add" \
"$name" >&$DIALOG_TERMINAL_PASSTHRU_FD 2> /dev/null
fi
} | {
if f_debugging; then
/usr/sbin/pkg_add -v -
else
f_quietly /usr/sbin/pkg_add -
fi
}
# Request the package be added via pkg-install(8)
if f_debugging; then
pkg -d install -y $orphan "$name"
else
f_quietly pkg install -y "$name"
fi
if [ $? -ne $SUCCESS ]; then
$alert "$msg_pkg_add_apparently_did_not_like_the_package" \
$alert "$msg_pkg_install_apparently_did_not_like_the_package" \
"$name"
[ "$no_confirm" ] && sleep 2
else
@ -1172,15 +1144,15 @@ f_package_delete()
#
f_show_info "$msg_uninstalling_package_waiting_for_pkg_delete" "$name"
if f_debugging; then
pkg_delete -v "$name"
pkg -d delete -y "$name"
else
f_quietly pkg_delete "$name"
f_quietly pkg delete -y "$name"
fi
if [ $? -ne $SUCCESS ]; then
f_show_msg "$msg_pkg_delete_failed" "$name"
return $FAILURE
else
f_dprintf "%s: pkg_delete(1) of %s successful" $fname "$name"
f_dprintf "%s: pkg-delete(8) of %s successful" $fname "$name"
f_str2varname "$name" varpkg
setvar _mark_$varpkg ""
fi