100 lines
2.1 KiB
Plaintext
100 lines
2.1 KiB
Plaintext
|
#!/bin/bash
|
||
|
################################################################################
|
||
|
#
|
||
|
################################################################################
|
||
|
unalias -a
|
||
|
set +xv
|
||
|
|
||
|
VERBOSE=0
|
||
|
|
||
|
ARCHP=xxARCHPxx
|
||
|
ARCHM=xxARCHMxx
|
||
|
LOCALVERSION=xxLOCALVERSIONxx
|
||
|
LOCVER=xxLOCVERxx
|
||
|
KERNELRELEASE=xxKERNELRELEASExx
|
||
|
FIMAGE=xxFIMAGExx
|
||
|
FCONFIG=xxFCONFIGxx
|
||
|
FSYSTEMMAP=xxFSYSTEMMAPxx
|
||
|
FVMLINUX=xxFVMLINUXxx
|
||
|
|
||
|
x=${KERNELRELEASE#*elbrus.}
|
||
|
x=${LOCVER}
|
||
|
#x=`echo $x | sed -e 's/\./-/g'`
|
||
|
LABEL=k${x}
|
||
|
|
||
|
[[ -z $ROOT ]] && ROOT=/
|
||
|
ROOTDIR=$ROOT
|
||
|
|
||
|
OSLBASE=base
|
||
|
OSLUP=$LABEL
|
||
|
OSLFLASH=oslflash
|
||
|
|
||
|
BOOTCONF=/boot/boot.conf
|
||
|
|
||
|
tmpf=/tmp/__prerm_linux_$$_
|
||
|
################################################################################
|
||
|
cleanup()
|
||
|
{
|
||
|
rm -f ${tmpf}*
|
||
|
}
|
||
|
DoEcho()
|
||
|
{
|
||
|
echo "=== linux prerm: $LOCVER: $*"
|
||
|
}
|
||
|
DoEchoV()
|
||
|
{
|
||
|
[[ $VERBOSE == 0 ]] && return 0
|
||
|
DoEcho "$*"
|
||
|
}
|
||
|
################################################################################
|
||
|
# check boot.conf: label=base - image=/FIMAGE
|
||
|
################################################################################
|
||
|
CheckLabel_base()
|
||
|
{
|
||
|
O_IFS="$IFS"
|
||
|
export IFS=
|
||
|
isbase=0
|
||
|
while read -r line; do
|
||
|
line1=$(echo $line | sed -e 's/[\t ]*//g')
|
||
|
if [[ $line1 == "label=${OSLBASE}" || $line1 == "label=${OSLBASE}#"* ]]; then
|
||
|
isbase=1
|
||
|
continue
|
||
|
fi
|
||
|
if [[ $isbase == 1 ]]; then
|
||
|
if [[ $line1 == "image="* ]]; then
|
||
|
fimage=${line1#image=/}
|
||
|
fimage=${fimage%%\#*}
|
||
|
if [[ $fimage == $FIMAGE ]]; then
|
||
|
return 1
|
||
|
else
|
||
|
return 0
|
||
|
fi
|
||
|
fi
|
||
|
fi
|
||
|
done <${BOOTCONF}
|
||
|
IFS="$O_IFS"
|
||
|
}
|
||
|
################################################################################
|
||
|
trap "cleanup" 1 2 3 6 15 EXIT
|
||
|
|
||
|
DoEchoV "KERNELRELEASE=$KERNELRELEASE"
|
||
|
DoEchoV "FIMAGE=$FIMAGE"
|
||
|
DoEchoV "LABEL=$LABEL"
|
||
|
|
||
|
krelease=`uname -r`
|
||
|
if [[ "$krelease" == "$KERNELRELEASE" ]]; then
|
||
|
DoEcho "WARNING: kernel release: uname -r: $krelease"
|
||
|
DoEcho "WARNING: cannot remove package"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [[ -f $BOOTCONF ]]; then
|
||
|
CheckLabel_base
|
||
|
if [[ $? == 1 ]]; then
|
||
|
DoEcho "WARNING: label=${OSLBASE}: image=/$FIMAGE"
|
||
|
DoEcho "WARNING: cannot remove package"
|
||
|
exit 1
|
||
|
fi
|
||
|
fi
|
||
|
exit 0
|