summaryrefslogtreecommitdiffstats
path: root/source/installer/sources/initrd/usr/lib/setup/SeTkernel
blob: 9def33c8c476388a72515f8ffb9a832ec7d8f564 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/sh
TMP=/var/log/setup/tmp
T_PX="`cat $TMP/SeTT_PX`"

# First, determine our slackware kernel name:
for ELEMENT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
  if $(cat /proc/cmdline | cut -f $ELEMENT -d ' ' | grep -q SLACK_KERNEL) ; then
    SLACK_KERNEL=$(cat /proc/cmdline | cut -f $ELEMENT -d ' ' | cut -f 2 -d =)
  fi
done
unset ELEMENT

# Next, find the kernel's release version:
VERSION=$(uname -r | tr - _)

# If someone tries to install kernels from a CD that doesn't contain any,
# we'll give them one chance to find a disc that does.
swapdisks() {
  if [ -r ${T_PX}/var/log/setup/tmp/SeTCDdev ]; then
    CDDEVICE=$(cat ${T_PX}/var/log/setup/tmp/SeTCDdev)
  elif [ -r /tmp/SeTCDdev ]; then
    CDDEVICE=$(cat /tmp/SeTCDdev)
  else
    return 1
  fi
  umount $CDDEVICE 1> /dev/null 2> /dev/null
  eject -s $CDDEVICE
  dialog --title "REINSERT KERNEL DISC" --msgbox \
"Please reinsert the Slackware disc containing the collection \
of Linux kernels. Usually this is disc number one (the disc \
that you boot from). Once you've inserted the disc, hit ENTER \
to continue." \
8 61
  mount $CDDEVICE /var/log/mount 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    sleep 1
    mount $CDDEVICE /var/log/mount 1> /dev/null 2> /dev/null
      if [ ! $? = 0 ]; then
      sleep 11
      mount $CDDEVICE /var/log/mount 1> /dev/null 2> /dev/null
    fi
  fi
}

# Determine if we need the .x64 suffix for x86_64 config files:
if [ "$(uname -m)" = "x86_64" ]; then
  CONFIGSUFFIX=".x64"
else
  unset CONFIGSUFFIX
fi

( cd boot
  if [ "$SLACK_KERNEL" = "generic.s" ]; then
    if [ -r vmlinuz-generic-$VERSION ]; then
      ln -sf vmlinuz-generic-$VERSION vmlinuz
      ln -sf config-generic-${VERSION}${CONFIGSUFFIX} config
      ln -sf System.map-huge-$VERSION System.map
    fi
  elif [ "$SLACK_KERNEL" = "huge.s" ]; then
    if [ -r vmlinuz-huge-$VERSION ]; then
      ln -sf vmlinuz-huge-$VERSION vmlinuz
      ln -sf config-huge-${VERSION}${CONFIGSUFFIX} config
      ln -sf System.map-huge-$VERSION System.map
    fi
  elif [ "$SLACK_KERNEL" = "hugesmp.s" ]; then
    if [ -r vmlinuz-huge-smp-$VERSION ]; then
      ln -sf vmlinuz-huge-smp-$VERSION vmlinuz
      ln -sf config-huge-smp-$VERSION config
      ln -sf System.map-huge-smp-$VERSION System.map
    fi
  elif [ "$SLACK_KERNEL" = "gensmp.s" ]; then
    if [ -r vmlinuz-generic-smp-$VERSION ]; then
      ln -sf vmlinuz-generic-smp-$VERSION vmlinuz
      ln -sf config-generic-smp-$VERSION config
      ln -sf System.map-generic-smp-$VERSION System.map
    fi
  elif [ "$SLACK_KERNEL" = "speakup.s" ]; then
    # This assumes symlinks /nfs and /cdrom both pointing to /var/log/mount:
    if $(mount | grep -q "type nfs") ; then
      PLINK=nfs
    else
      PLINK=cdrom
    fi
    if [ $PLINK = cdrom -a ! -d /$PLINK/kernels ]; then
      swapdisks
    fi
    if [ ! -d /$PLINK/kernels ]; then
      dialog --title "ERROR ATTEMPTING TO INSTALL KERNEL" --msgbox "Sorry, but the directory /$PLINK/kernels \
was not found. You may need to install the requested kernel $SLACK_KERNEL manually \
and then install LILO \
before your system will be able to boot correctly." \
0 0
    else
      rm -f $T_PX/boot/vmlinuz $T_PX/boot/config $T_PX/boot/System.map
      cp -a /$PLINK/kernels/$SLACK_KERNEL/bzImage $T_PX/boot/vmlinuz-$SLACK_KERNEL-$VERSION
      cp -a /$PLINK/kernels/$SLACK_KERNEL/config $T_PX/boot/config-$SLACK_KERNEL-${VERSION}${CONFIGSUFFIX}
      cp -a /$PLINK/kernels/$SLACK_KERNEL/System.map.gz $T_PX/boot
      ( cd $T_PX/boot
        gzip -d System.map.gz
        mv System.map System.map-$SLACK_KERNEL-$VERSION
        ln -sf vmlinuz-$SLACK_KERNEL-$VERSION vmlinuz
        ln -sf config-$SLACK_KERNEL-${VERSION}${CONFIGSUFFIX} config
        ln -sf System.map-$SLACK_KERNEL-$VERSION System.map
      )
    fi
  fi
)

# and after all that hard work