mirror of
https://git.proxmox.com/git/mirror_spl-debian
synced 2025-10-04 21:47:07 +00:00
Handle the case /etc/hostid is being wrongly marked as conffile
There are packages distributed with /etc/hostid file installed as conffile, which is going to cause problem when the package is purged. Here we detect such case and migrate it to an ordinary file that preserves during purge. Also replace the endianness detection code to use od(1) from coreutils instead of requiring gcc
This commit is contained in:
parent
635ac71365
commit
c932eac93e
8
debian/spl.postinst
vendored
8
debian/spl.postinst
vendored
@ -21,6 +21,12 @@ set -e
|
||||
# If this file don't already exists on our system or has less than 4 bytes, then
|
||||
# we will stabilize our current hostid by writing its value to /etc/hostid
|
||||
|
||||
# Detect if /etc/hostid is a conffile of previous spl package, migrate if yes
|
||||
# hostid file should preserve even when package is purged
|
||||
if $(dpkg-query --showformat='${Conffiles}\n' --show spl >/dev/null 2>&1); then
|
||||
dpkg-maintscript-helper rm_conffile /etc/hostid -- "$@"
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/hostid ] || [ $(stat -c %s /etc/hostid) -lt 4 ] ; then
|
||||
|
||||
# Write our current hostid to /etc/hostid
|
||||
@ -31,7 +37,7 @@ if [ ! -f /etc/hostid ] || [ $(stat -c %s /etc/hostid) -lt 4 ] ; then
|
||||
DD=$(echo $HOSTID | cut -b 7,8)
|
||||
|
||||
# Big Endian
|
||||
if echo | gcc -E -dM - | grep -q "__BYTE_ORDER__.*__ORDER_BIG_ENDIAN__"; then
|
||||
if [ $(echo -n I | od -to2 | awk 'FNR==1{ print substr($2,6,1)}' 2>/dev/null) = 0 ]; then
|
||||
# Invoke the printf from coreutils. shell builtin lacks the byte format.
|
||||
/usr/bin/printf "\x$AA\x$BB\x$CC\x$DD" >/etc/hostid
|
||||
else
|
||||
|
10
debian/spl.postrm
vendored
Normal file
10
debian/spl.postrm
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Detect if /etc/hostid is a conffile of previous spl package, migrate if yes
|
||||
# hostid file should preserve even when package is purged
|
||||
if $(dpkg-query --showformat='${Conffiles}\n' --show spl >/dev/null 2>&1); then
|
||||
dpkg-maintscript-helper rm_conffile /etc/hostid -- "$@"
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
10
debian/spl.preinst
vendored
Normal file
10
debian/spl.preinst
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Detect if /etc/hostid is a conffile of previous spl package, migrate if yes
|
||||
# hostid file should preserve even when package is purged
|
||||
if $(dpkg-query --showformat='${Conffiles}\n' --show spl >/dev/null 2>&1); then
|
||||
dpkg-maintscript-helper rm_conffile /etc/hostid -- "$@"
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
Loading…
Reference in New Issue
Block a user