Skip to content

Commit

Permalink
Update pkg_replace-20221217
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeguchi committed Dec 17, 2022
1 parent eb55684 commit 23847ab
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
7 changes: 6 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
20221217
*Fix bugs related "-P" or "-PP" option
If binary package file exists,
pkg_replace gets dependencies from it.

20221216
*Fix bugs related -PP option
*Fix bugs related "-PP" option

20221215
*Fix bugs in find_package() and get_binary_pkgname()
Expand Down
4 changes: 2 additions & 2 deletions pkg_replace.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" $Id: pkg_replace.1,v 1.2 2007/01/25 12:25:56 securedog Exp $
.\"
.\" Modified by Ken DEGUCHI (December 16, 2022)"
.Dd December 16, 2022
.\" Modified by Ken DEGUCHI (December 17, 2022)"
.Dd December 17, 2022
.Dt PKG_REPLACE 1
.Os
.Sh NAME
Expand Down
49 changes: 38 additions & 11 deletions pkg_replace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# - Cleanup Code


PKG_REPLACE_VERSION=20221216
PKG_REPLACE_VERSION=20221217
PKG_REPLACE_CONFIG=FreeBSD

usage() {
Expand Down Expand Up @@ -162,6 +162,7 @@ init_pkgtools() {
PKG_DELETE="${PKG_BIN} delete"
PKG_INFO="${PKG_BIN} info"
PKG_QUERY="${PKG_BIN} query"
PKG_RQUERY="${PKG_BIN} rquery"
PKG_SET="${PKG_BIN} set"
}

Expand Down Expand Up @@ -282,6 +283,7 @@ parse_args() {

if installed_pkg=$(get_installed_pkgname ${ARG}); then
if istrue ${opt_depends}; then
[ ${opt_depends} -ge 2 ] && info "'-dd' option is very slow!"
upgrade_pkgs="${upgrade_pkgs} $(get_depend_pkgnames "${installed_pkg}")"
fi
upgrade_pkgs="${upgrade_pkgs} ${installed_pkg}"
Expand Down Expand Up @@ -522,9 +524,22 @@ get_pkgname_from_origin() {
}

get_depend_pkgnames() {
local deps
deps=$(${PKG_QUERY} '%dn-%dv' $1 | sort -u)
[ ${opt_depends} -eq 2 ] && deps="${deps} $(get_strict_depend_pkgnames "$1" "${deps}")"
local deps X pkgfile
deps=
if istrue ${opt_use_packages}; then
for X in $1; do
pkgfile=${PKGREPOSITORY}/$X${PKG_BINARY_SUFX}
if [ -e ${pkgfile} ]; then
deps="${deps} $(${PKG_QUERY} -F ${pkgfile} '%dn-%dv')"
else
install_pkgs="${install_pkgs} $X"
fi
done
else
deps=$(${PKG_QUERY} '%dn-%dv' $1 | sort -u)
[ ${opt_depends} -ge 2 ] &&
deps="${deps} $(get_strict_depend_pkgnames "$1" "${deps}")"
fi
echo ${deps} | tr ' ' '\n' | sort -u
return 0
}
Expand Down Expand Up @@ -580,9 +595,6 @@ pkg_sort() {

pkgs=$@

# check installed package
${PKG_INFO} -e ${pkgs} 2>&1 > /dev/null || return 1

# check dependencies
echo -n 'Checking dependencies'
dep_list= ; cnt=0
Expand Down Expand Up @@ -1072,11 +1084,17 @@ set_pkginfo_install() {
;;
*)
pkg_name=$1
pkg_origin=$(get_origin_from_pkgname ${pkg_name}) || return 1
pkg_flavor=
pkg_portdir=$(get_portdir_from_origin ${pkg_origin}) || return 1
pkg_binary=${PKGREPOSITORY}/${pkg_name}${PKG_BINARY_SUFX}
[ -e ${pkg_binary} ] || pkg_binary=
if istrue ${opt_use_packages} && [ -e ${pkg_binary} ]; then
pkg_origin=$(get_binary_origin ${pkg_binary})
pkg_flavor=$(get_binary_flavor ${pkg_binary})
pkg_portdir=$(get_portdir_from_origin ${pkg_origin})
else
[ -e ${pkg_binary} ] || pkg_binary=
pkg_origin=$(${PKG_RQUERY} '%o' ${pkg_name%-*})
pkg_portdir=$(get_portdir_from_origin ${pkg_origin})
pkg_flavor=
fi
;;
esac
}
Expand Down Expand Up @@ -1532,6 +1550,14 @@ main() {

istrue ${opt_omit_check} || pkg_sort ${upgrade_pkgs}

# check installed package
for X in ${upgrade_pkgs}; do
get_installed_pkgname $X 2>&1 > /dev/null || {
install_pkgs="${install_pkgs} $X";
upgrade_pkgs=$(echo ${upgrade_pkgs} | sed "s|$X||g");
}
done

# config
(istrue ${opt_config} || istrue ${opt_force_config}) && {
set -- ${install_pkgs}
Expand All @@ -1545,6 +1571,7 @@ main() {
}
ARGV=${ARG}
done
tput cd
set -- ${upgrade_pkgs}
cnt=0
ARGV=
Expand Down

0 comments on commit 23847ab

Please sign in to comment.