Mercurial > hg > zsh-env
comparison removeKernel @ 175:8af0a6219353
Remove the support for genkernel 3, add support for distinguishing between gentoo/vanilla sources
author | Dirk Olmes <dirk.olmes@codedo.de> |
---|---|
date | Wed, 15 Apr 2020 09:02:04 +0200 |
parents | 5da4de3d7ee1 |
children | 249b37a8c917 |
comparison
equal
deleted
inserted
replaced
174:5da4de3d7ee1 | 175:8af0a6219353 |
---|---|
15 MICRO=$3 | 15 MICRO=$3 |
16 if [ $# -gt 3 ]; then | 16 if [ $# -gt 3 ]; then |
17 REVISION=$4 | 17 REVISION=$4 |
18 fi | 18 fi |
19 | 19 |
20 FULL_VERSION="${MAJOR}.${MINOR}.${MICRO}" | |
21 if [[ "${REVISION}" != "" ]]; then | |
22 FULL_VERSION=$"{FULL_VERSION}-${REVISION}" | |
23 fi | |
24 | |
20 ARCH=`uname -m` | 25 ARCH=`uname -m` |
21 if [ "$ARCH" = "i686" ]; then | 26 if [ "$ARCH" = "i686" ]; then |
22 ARCH="x86" | 27 ARCH="x86" |
28 fi | |
29 | |
30 KERNEL_FLAVOR="" | |
31 KERNEL_EBUILD="vanilla-sources" | |
32 if [[ "$(grep gentoo-sources /var/lib/portage/world)" != "" ]]; then | |
33 KERNEL_FLAVOR="-gentoo" | |
34 KERNEL_EBUILD="gentoo-sources" | |
23 fi | 35 fi |
24 | 36 |
25 LOGFILE=/tmp/removeKernel-$$.log | 37 LOGFILE=/tmp/removeKernel-$$.log |
26 | 38 |
27 # unmerge the kernel | 39 # unmerge the kernel |
28 cd /usr/src | 40 cd /usr/src |
29 KERNEL_DIR="linux-${MAJOR}.${MINOR}.${MICRO}-gentoo" | 41 KERNEL_DIR="linux-${FULL_VERSION}${KERNEL_FLAVOR}" |
30 if [ "$REVISION" != "" ]; then | |
31 KERNEL_DIR="${KERNEL_DIR}-${REVISION}" | |
32 fi | |
33 if [ -d $KERNEL_DIR ]; then | 42 if [ -d $KERNEL_DIR ]; then |
34 KERNEL_NAME=gentoo-sources-${MAJOR}.${MINOR}.${MICRO} | 43 KERNEL_NAME="${KERNEL_EBUILD}-${FULL_VERSION}" |
35 if [ "${REVISION}" != "" ]; then | |
36 KERNEL_NAME="${KERNEL_NAME}-${REVISION}" | |
37 fi | |
38 | 44 |
39 echo "unmerge kernel $KERNEL_NAME" >> $LOGFILE 2>&1 | 45 echo "unmerge kernel $KERNEL_NAME" >> $LOGFILE 2>&1 |
40 emerge --unmerge $KERNEL_NAME >> $LOGFILE 2>&1 | 46 emerge --unmerge $KERNEL_NAME >> $LOGFILE 2>&1 |
41 | 47 |
42 echo "remove $KERNEL_DIR" >> $LOGFILE 2>&1 | 48 echo "remove $KERNEL_DIR" >> $LOGFILE 2>&1 |
43 rm -r $KERNEL_DIR >> $LOGFILE 2>&1 | 49 rm -r $KERNEL_DIR >> $LOGFILE 2>&1 |
44 fi | 50 fi |
45 | 51 |
46 # remove modules | 52 # remove modules |
47 cd /lib/modules | 53 cd /lib/modules |
48 LIB_DIR=${MAJOR}.${MINOR}.${MICRO}-gentoo | 54 LIB_DIR="${FULL_VERSION}${KERNEL_FLAVOR}-${ARCH}" |
49 if [[ "$REVISION" != "" ]]; then | 55 if [[ -d ${LIB_DIR} ]]; then |
50 LIB_DIR="${LIB_DIR}-${REVISION}" | 56 echo "remove modules from $(pwd)/${LIB_DIR}" >> $LOGFILE 2>&1 |
51 fi | 57 rm -r ${LIB_DIR} >> $LOGFILE 2>&1 |
52 if [[ ! -d $LIB_DIR ]]; then | |
53 LIB_DIR="${LIB_DIR}-${ARCH}" | |
54 fi | |
55 if [[ -d $LIB_DIR ]]; then | |
56 echo "remove modules from `pwd`/${LIB_DIR}" >> $LOGFILE 2>&1 | |
57 rm -r $LIB_DIR >> $LOGFILE 2>&1 | |
58 fi | 58 fi |
59 | 59 |
60 # remove the kernel and stuff, check if /boot is mounted first | 60 # remove the kernel and stuff, check if /boot is mounted first |
61 MOUNTED=`mount | grep /boot` | 61 MOUNTED=`mount | grep /boot` |
62 if [ "$MOUNTED" = "" ]; then | 62 if [ "$MOUNTED" = "" ]; then |
63 echo "mount /boot" >> $LOGFILE 2>&1 | 63 echo "mount /boot" >> $LOGFILE 2>&1 |
64 mount /boot >> $LOGFILE 2>&1 | 64 mount /boot >> $LOGFILE 2>&1 |
65 fi | 65 fi |
66 | 66 |
67 cd /boot | 67 cd /boot |
68 SUFFIX_V3="genkernel-${ARCH}-${MAJOR}.${MINOR}.${MICRO}" | |
69 if [[ "${REVISION}" != "" ]]; then | |
70 SUFFIX_V3="${SUFFIX_V3}-${REVISION}" | |
71 fi | |
72 SUFFIX_V3="${SUFFIX_V3}-gentoo" | |
73 | 68 |
74 SUFFIX_V4="${MAJOR}.${MINOR}.${MICRO}" | 69 SYSTEM_MAP="System.map-${FULL_VERSION}${KERNEL_FLAVOR}-${ARCH}" |
75 if [ "${REVISION}" != "" ]; then | |
76 SUFFIX_V4="${SUFFIX_V4}-${REVISION}" | |
77 fi | |
78 SUFFIX_V4="${SUFFIX_V4}-gentoo-${ARCH}" | |
79 | |
80 SYSTEM_MAP="System.map-${SUFFIX_V3}" | |
81 if [[ -f $SYSTEM_MAP ]]; then | |
82 rm ${SYSTEM_MAP} >> $LOGFILE 2>&1 | |
83 fi | |
84 SYSTEM_MAP="System.map-${SUFFIX_V4}" | |
85 if [[ -f ${SYSTEM_MAP} ]]; then | 70 if [[ -f ${SYSTEM_MAP} ]]; then |
86 rm ${SYSTEM_MAP} >> $LOGFILE 2>&1 | 71 rm ${SYSTEM_MAP} >> $LOGFILE 2>&1 |
87 fi | 72 fi |
88 if [[ -f ${SYSTEM_MAP}.old ]]; then | 73 if [[ -f ${SYSTEM_MAP}.old ]]; then |
89 rm ${SYSTEM_MAP}.old >> $LOGFILE 2>&1 | 74 rm ${SYSTEM_MAP}.old >> $LOGFILE 2>&1 |
90 fi | 75 fi |
91 | 76 |
92 INITRAMFS="initramfs-${SUFFIX_V3}" | 77 INITRAMFS="initramfs-${FULL_VERSION}${KERNEL_FLAVOR}-${ARCH}.img" |
93 if [[ -f ${INITRAMFS} ]]; then | |
94 rm ${INITRAMFS} >> $LOGFILE 2>&1 | |
95 fi | |
96 INITRAMFS="initramfs-${SUFFIX_V4}" | |
97 if [[ -f ${INITRAMFS} ]]; then | 78 if [[ -f ${INITRAMFS} ]]; then |
98 rm ${INITRAMFS} >> $LOGFILE 2>&1 | 79 rm ${INITRAMFS} >> $LOGFILE 2>&1 |
99 fi | 80 fi |
100 if [[ -f ${INITRAMFS}.old ]]; then | 81 if [[ -f ${INITRAMFS}.old ]]; then |
101 rm ${INITRAMFS}.old >> $LOGFILE 2>&1 | 82 rm ${INITRAMFS}.old >> $LOGFILE 2>&1 |
102 fi | 83 fi |
103 | 84 |
104 KERNEL="kernel-${SUFFIX_V3}" | 85 KERNEL="vmlinuz-${FULL_VERSION}${KERNEL_FLAVOR}-${ARCH}" |
105 if [[ -f $KERNEL ]]; then | |
106 rm $KERNEL >> $LOGFILE 2>&1 | |
107 fi | |
108 KERNEL="vmlinuz-${SUFFIX_V4}" | |
109 if [[ -f $KERNEL ]]; then | 86 if [[ -f $KERNEL ]]; then |
110 rm $KERNEL >> $LOGFILE 2>&1 | 87 rm $KERNEL >> $LOGFILE 2>&1 |
111 fi | 88 fi |
112 if [[ -f $KERNEL.old ]]; then | 89 if [[ -f $KERNEL.old ]]; then |
113 rm $KERNEL.old >> $LOGFILE 2>&1 | 90 rm $KERNEL.old >> $LOGFILE 2>&1 |
114 fi | 91 fi |
115 | 92 |
116 cd /var/tmp/genkernel | 93 cd /var/tmp/genkernel |
117 INITRAMFS="initramfs-${ARCH}-${SUFFIX_V4}" | 94 INITRAMFS="initramfs-${ARCH}-${FULL_VERSION}${KERNEL_FLAVOR}-${ARCH}" |
118 if [[ -f ${INITRAMFS} ]]; then | 95 if [[ -f ${INITRAMFS} ]]; then |
119 rm ${INITRAMFS} >> $LOGFILE 2>&1 | 96 rm ${INITRAMFS} >> $LOGFILE 2>&1 |
120 fi | 97 fi |
121 | 98 |
122 # if we got until here, just remove the logfile again | 99 # if we got until here, just remove the logfile again |