Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 03 Feb 2014 20:55:23 +0900
From:      "KAMADA Ken'ichi" <kamada@nanohz.org>
To:        kdeguchi@sz.tokoha-u.ac.jp, FreeBSD-gnats-submit@freebsd.org
Cc:        kamada@nanohz.org
Subject:   ports/186406: ports-mgmt/pkg_replace: preserve automatic flag
Message-ID:  <20140203205523XW%kamada@nanohz.org>
Resent-Message-ID: <201402031200.s13C0673037647@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         186406
>Category:       ports
>Synopsis:       ports-mgmt/pkg_replace: preserve automatic flag
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Feb 03 12:00:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     KAMADA Ken'ichi
>Release:        FreeBSD 10.0-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD shiki.nanohz.org 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16 22:34:59 UTC 2014 root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64

>Description:
Hello Deguchi-san,

This is a patch to make pkg_replace preserve the automatic flag.
Could you merge this into your patch set?
Attached patch is against pkg_replace-0.8.0_7.

>How-To-Repeat:

>Fix:
--- /usr/local/sbin/pkg_replace	2014-02-03 08:15:28.000000000 +0900
+++ pkg_replace	2014-02-03 19:57:49.000000000 +0900
@@ -1290,7 +1290,8 @@
 }
 
 do_replace() {
-	local pkg_log pkg_tmpdir old_package old_required_by preserved_files
+	local pkg_log pkg_tmpdir old_package old_required_by preserved_files \
+		automatic_flag
 
 	if is_yes ${use_pkgng}; then
 		local old_origin new_origin
@@ -1365,6 +1366,7 @@
 		backup_package "${cur_pkg_name}" "${old_package}" &&
 		if is_yes ${use_pkgng}; then
 			old_origin=`${PKG_INFO} -qo ${cur_pkg_name}` || return 1
+			automatic_flag=$(${PKG_QUERY} %a "${cur_pkg_name}")
 		else
 			backup_file "${cur_pkg_pkgdir}/+REQUIRED_BY" "${old_required_by}"
 		fi &&
@@ -1381,6 +1383,7 @@
 			cur_pkg_pkgdir=${PKG_DBDIR}/${pkg_name}
 			if is_yes ${use_pkgng}; then
 				new_origin=`${PKG_INFO} -qo ${pkg_name}`
+				${PKG_SET} -y -A "${automatic_flag}" "${pkg_name}"
 			fi
 		else
 			log="install error"
@@ -1389,6 +1392,9 @@
 				"please reinstall '${old_package}' manually."
 				return 1
 			}
+			if is_yes ${use_pkgng}; then
+				${PKG_SET} -y -A "${automatic_flag}" "${old_package}"
+			fi
 		fi
 	else
 		log="deinstall error"
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140203205523XW%kamada>