Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 599396
Collapse All | Expand All

(-)dhcpcd-9999.ebuild (-9 / +65 lines)
Lines 79-99 Link Here
79
79
80
pkg_postinst()
80
pkg_postinst()
81
{
81
{
82
	# Upgrade the duid file to the new format if needed
82
	local dbdir="${ROOT}"/var/lib/dhcpcd old_files=
83
	local old_duid="${ROOT}"/var/lib/dhcpcd/dhcpcd.duid
83
84
	local new_duid="${ROOT}"/etc/dhcpcd.duid
84
	local old_old_duid="${ROOT}"/var/lib/dhcpcd/dhcpcd.duid
85
	if [ -e "${old_duid}" ] && ! grep -q '..:..:..:..:..:..' "${old_duid}"; then
85
	local old_duid="${ROOT}"/etc/dhcpcd.duid
86
		sed -i -e 's/\(..\)/\1:/g; s/:$//g' "${old_duid}"
86
	local new_duid="${dbdir}"/duid
87
	if [ -e "${old_old_duid}" ]; then
88
		# Upgrade the duid file to the new format if needed
89
		if ! grep -q '..:..:..:..:..:..' "${old_old_duid}"; then
90
			sed -i -e 's/\(..\)/\1:/g; s/:$//g' "${old_old_duid}"
91
		fi
92
93
		# Move the duid to /etc, a more sensible location
94
		if [ ! -e "${old_duid}" ]; then
95
			cp -p "${old_old_duid}" "${new_duid}"
96
		fi
97
		old_files="${old_files} ${old_old_duid}"
98
	fi
99
100
	# dhcpcd-7 moves the files out of /etc
101
	if [ -e "${old_duid}" ]; then
102
		if [ ! -e "${new_duid}" ]; then
103
			cp -p "${old_duid}" "${new_duid}"
104
		fi
105
		old_files="${old_files} ${old_duid}"
106
	fi
107
	local old_secret="${ROOT}"/etc/dhcpcd.secret
108
	local new_secret="${dbdir}"/secret
109
	if [ -e "${old_secret}" ]; then
110
		if [ ! -e "${new_secret}" ]; then
111
			cp -p "${old_secret}" "${new_secret}"
112
		fi
113
		old_files="${old_files} ${old_secret}"
87
	fi
114
	fi
88
115
89
	# Move the duid to /etc, a more sensible location
116
	# dhcpcd-7 renames some files in /var/lib/dhcpcd
90
	if [ -e "${old_duid}" -a ! -e "${new_duid}" ]; then
117
	local old_rdm="${dbdir}"/dhcpcd-rdm.monotonic
91
		cp -p "${old_duid}" "${new_duid}"
118
	local new_rdm="${dbdir}"/rdm_monotonic
119
	if [ -e "${old_rdm}" ]; then
120
		if [ ! -e "${new_rdm}" ]; then
121
			cp -p "${old_rdm}" "${new_rdm}"
122
		fi
123
		old_files="${old_files} ${old_rdm}"
124
	fi
125
	local lease=
126
	for lease in "${dbdir}"/dhcpcd-*.lease*; do
127
		[ -f "$lease" ] || continue
128
		old_files="${old_files} ${lease}"
129
		local new_lease=$(basename "$lease" | sed -e "s/dhcpcd-//")
130
		[ -e "${dbdir}/${new_lease}" ] && continue
131
		cp "${lease}" "${dbdir}/${new_lease}"
132
	done
133
134
	# Warn about removing stale files
135
	if [ -n "${old_files}" ]; then
136
		elog
137
		elog "dhcpcd-7 has copied dhcpcd.duid and dhcpcd.secret from"
138
		elog "${ROOT}/etc to ${dbdir}"
139
		elog "and copied leases in ${dbdir} to new files with the dhcpcd-"
140
		elog "prefix dropped."
141
		elog
142
		elog "You should remove these files if you don't plan on reverting"
143
		elog "to an older version:"
144
		local old_file=
145
		for old_file in ${old_files}; do
146
			elog "	${old_file}"
147
		done
92
	fi
148
	fi
93
149
94
	if [ -z "$REPLACING_VERSIONS" ]; then
150
	if [ -z "$REPLACING_VERSIONS" ]; then
95
		elog
151
		elog
96
	 elog "dhcpcd has zeroconf support active by default."
152
	 	elog "dhcpcd has zeroconf support active by default."
97
		elog "This means it will always obtain an IP address even if no"
153
		elog "This means it will always obtain an IP address even if no"
98
		elog "DHCP server can be contacted, which will break any existing"
154
		elog "DHCP server can be contacted, which will break any existing"
99
		elog "failover support you may have configured in your net configuration."
155
		elog "failover support you may have configured in your net configuration."

Return to bug 599396