summaryrefslogtreecommitdiffstats
path: root/testing/source/pkgtools/scripts/makebootdisk
diff options
context:
space:
mode:
author Patrick J Volkerding <volkerdi@slackware.com>2018-06-19 22:35:25 +0000
committer Eric Hameleers <alien@slackware.com>2018-06-20 09:00:31 +0200
commit7e5ee73de954e6c084195b0a1fa6ef01a78d092f (patch)
tree7219c86cd7bc94b145e6e31779a1654ba5998e4c /testing/source/pkgtools/scripts/makebootdisk
parenta27618d0d02506153de111da1055a5af43245d13 (diff)
downloadcurrent-7e5ee73de954e6c084195b0a1fa6ef01a78d092f.tar.gz
current-7e5ee73de954e6c084195b0a1fa6ef01a78d092f.tar.xz
Tue Jun 19 22:35:25 UTC 201820180619223525
a/acl-2.2.53-x86_64-1.txz: Upgraded. a/attr-2.4.48-x86_64-1.txz: Upgraded. n/gnupg-1.4.23-x86_64-1.txz: Upgraded. Sanitize the diagnostic output of the original file name in verbose mode. By using a made up file name in the message it was possible to fake status messages. Using this technique it was for example possible to fake the verification status of a signed mail. For more information, see: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-12020 (* Security fix *) x/libXaw3d-1.6.3-x86_64-1.txz: Upgraded. x/libinput-1.11.1-x86_64-1.txz: Upgraded. x/xf86-input-mouse-1.9.3-x86_64-1.txz: Upgraded. testing/packages/pkgtools-15.0-noarch-20.txz: Rebuilt. This update is a bit scarier than usual, so we're going to test it here first and then move it into the main tree in a couple of days if there are no serious bug reports. It's well-tested here, and works with the slackpkg that's in -current now, but I don't know about slackpkg+ so that's another reason to let it cool down here first. The purpose of this update is to migrate the package database and directories from /var/log to /var/lib/pkgtools. /var/log was never a good place for this data, as it is considered by many to be a directory that could be wiped to free up some space. Originally the package database was in /var/adm, but the FSSTND (later FHS) group decided that directory should be a symlink to /var/log, and I went along with that since it was years ago and I was a n00b and didn't know any better. /var/lib/pkgtools will be a better and safer location. The removed_packages and removed_scripts directories are really just logs that aren't actually used for anything - those will remain under /var/log, but moved into /var/log/pkgtools. Everything under /var/log will be considered potentially non-permanent by the pkgtools - if any directories or symlinks disappear from there, the pkgtools will automatically recreate them as needed. In fact, the migration process will create symlinks from all the old directory locations to the new ones, so anything that expects the old locations (including slackpkg, for now) should continue to work. Once this moves into the main tree, the plan is to fix other packages to use the new installer script directory (/var/lib/pkgtools/setup) and change the installer and slackpkg to use the new native locations for everything. When slackpkg is changed over to use the new native locations, I'll also make sure to float that in testing/ for a few days before moving it to the main tree to avoid more unintentional disruption to slackpkg+ users. Be aware that the package database migration is a one-way operation, but even so if you later downgrade to an older version of the pkgtools it will still work through the compatibility symlinks.
Diffstat (limited to 'testing/source/pkgtools/scripts/makebootdisk')
-rw-r--r--testing/source/pkgtools/scripts/makebootdisk443
1 files changed, 443 insertions, 0 deletions
diff --git a/testing/source/pkgtools/scripts/makebootdisk b/testing/source/pkgtools/scripts/makebootdisk
new file mode 100644
index 000000000..793796181
--- /dev/null
+++ b/testing/source/pkgtools/scripts/makebootdisk
@@ -0,0 +1,443 @@
+#!/bin/sh
+# Copyright 1995, 1998, 2002, 2005 Patrick Volkerding, Moorhead, Minnesota USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+if [ ! "$UID" = "0" ]; then
+ echo "You need to be root to run this script."
+ exit 1
+fi
+
+# Was a kernel specified on the command line?
+if [ -r "$1" ]; then
+ KERNEL=$1
+ KMSG="Using kernel $KERNEL"
+else
+ KMSG="No kernel selected yet"
+fi
+
+# Make sure there's a proper temp directory:
+TMP=/var/lib/pkgtools/setup/tmp
+# If the $TMP directory doesn't exist, create it:
+if [ ! -d $TMP ]; then
+ mkdir -p $TMP
+ chmod 700 $TMP # no need to leave it open
+fi
+
+ROOT_DEVICE="`mount | grep ' on / ' | cut -f 1 -d ' '`"
+
+if mount | grep ' on / ' | grep umsdos 1> /dev/null 2> /dev/null ; then
+ MOUNT="read-write"
+else
+ MOUNT="read-only"
+fi
+
+make_root_device() {
+# Make a device:
+makedev() {
+ if [ ! -b $1 ]; then
+ mknod $1 b $2 $3
+ chown root.disk $1
+ chmod 640 $1
+ fi
+}
+
+# Make ide device
+# make ide major minor hd1 hd2 (2 base devs for major)
+make_ide() {
+ # Handle base devices:
+ if [ "$2" = "0" ]; then
+ makedev $TMP/lilo/dev/$3 $1 $2
+ return 0
+ elif [ "$2" = "64" ]; then
+ makedev $TMP/lilo/dev/$4 $1 $2
+ return 0
+ fi
+ # Must be a partition:
+ if [ "`expr $2 / 64`" = "0" ]; then
+ DEV=$3
+ NUM=$2
+ else
+ DEV=$4
+ NUM=`expr $2 - 64`
+ fi
+ makedev $TMP/lilo/dev/$DEV$NUM $1 $2
+}
+
+# Make SCSI device
+make_scsi() {
+ # find drive # 0 - 15
+ DRV=`expr $1 / 16`
+ NUM=`expr $1 % 16`
+ if [ "$NUM" = "0" ]; then
+ NUM=""
+ fi
+ if [ "$DRV" = "0" ]; then
+ makedev $TMP/lilo/dev/sda$NUM 8 $1
+ elif [ "$DRV" = "1" ]; then
+ makedev $TMP/lilo/dev/sdb$NUM 8 $1
+ elif [ "$DRV" = "2" ]; then
+ makedev $TMP/lilo/dev/sdc$NUM 8 $1
+ elif [ "$DRV" = "3" ]; then
+ makedev $TMP/lilo/dev/sdd$NUM 8 $1
+ elif [ "$DRV" = "4" ]; then
+ makedev $TMP/lilo/dev/sde$NUM 8 $1
+ elif [ "$DRV" = "5" ]; then
+ makedev $TMP/lilo/dev/sdf$NUM 8 $1
+ elif [ "$DRV" = "6" ]; then
+ makedev $TMP/lilo/dev/sdg$NUM 8 $1
+ elif [ "$DRV" = "7" ]; then
+ makedev $TMP/lilo/dev/sdh$NUM 8 $1
+ elif [ "$DRV" = "8" ]; then
+ makedev $TMP/lilo/dev/sdi$NUM 8 $1
+ elif [ "$DRV" = "9" ]; then
+ makedev $TMP/lilo/dev/sdj$NUM 8 $1
+ elif [ "$DRV" = "10" ]; then
+ makedev $TMP/lilo/dev/sdk$NUM 8 $1
+ elif [ "$DRV" = "11" ]; then
+ makedev $TMP/lilo/dev/sdl$NUM 8 $1
+ elif [ "$DRV" = "12" ]; then
+ makedev $TMP/lilo/dev/sdm$NUM 8 $1
+ elif [ "$DRV" = "13" ]; then
+ makedev $TMP/lilo/dev/sdn$NUM 8 $1
+ elif [ "$DRV" = "14" ]; then
+ makedev $TMP/lilo/dev/sdo$NUM 8 $1
+ elif [ "$DRV" = "15" ]; then
+ makedev $TMP/lilo/dev/sdp$NUM 8 $1
+ fi
+}
+
+if cat /proc/partitions | grep / 1> /dev/null 2> /dev/null ; then # new
+ cat /proc/partitions | grep / | while read line ; do
+ SMASHED_LINE=$line
+ MAJOR=`echo $SMASHED_LINE | cut -f 1 -d ' '`
+ MINOR=`echo $SMASHED_LINE | cut -f 2 -d ' '`
+ if [ "$MAJOR" = "3" ]; then
+ make_ide $MAJOR $MINOR hda hdb
+ elif [ "$MAJOR" = "8" ]; then
+ make_scsi $MINOR
+ elif [ "$MAJOR" = "22" ]; then
+ make_ide $MAJOR $MINOR hdc hdd
+ elif [ "$MAJOR" = "33" ]; then
+ make_ide $MAJOR $MINOR hde hdf
+ elif [ "$MAJOR" = "34" ]; then
+ make_ide $MAJOR $MINOR hdg hdh
+ elif [ "$MAJOR" = "56" ]; then
+ make_ide $MAJOR $MINOR hdi hdj
+ fi
+ done
+else # old format
+ cat /proc/partitions | grep d | while read line ; do
+ SMASHED_LINE=$line
+ MAJOR=`echo $SMASHED_LINE | cut -f 1 -d ' '`
+ MINOR=`echo $SMASHED_LINE | cut -f 2 -d ' '`
+ DEVNAME=`echo $SMASHED_LINE | cut -f 4 -d ' '`
+ makedev $TMP/lilo/dev/$DEVNAME $MAJOR $MINOR
+ done
+fi
+}
+
+choose_kernel() {
+while [ 0 ]; do # input loop
+cat << EOF > $TMP/tmpmsg
+
+Some possible paths to kernels are these:
+
+/boot/vmlinuz
+/usr/src/linux/arch/i386/boot/bzImage
+/usr/src/linux/arch/i386/boot/zImage
+/vmlinuz
+
+Put the path to the kernel you want to use in the box below.
+
+EOF
+
+ dialog --title "CHOOSE KERNEL" --inputbox "`cat $TMP/tmpmsg`" \
+ 16 72 "/boot/vmlinuz" 2> $TMP/return
+ if [ ! $? = 0 ]; then
+ exit
+ fi
+
+ KERNEL="`cat $TMP/return`"
+
+ if [ ! -r "$KERNEL" ]; then
+ dialog --title "NOT FOUND!" --msgbox "$KERNEL" 5 60
+ continue
+ fi
+ KMSG="Using kernel $KERNEL"
+break
+done
+}
+
+format_disk() {
+ # If anyone still uses 1.2 MB, you'll have to uncomment this.
+ # It's no longer a default option.
+ #FDEV=/dev/fd0h1200
+ #FDEV=/dev/fd0u1400
+ FDEV=/dev/fd0u1680
+ if [ "$FDEV" = "/dev/fd0u1680" ]; then
+ dialog --title "Formatting /dev/fd0u1680" --infobox \
+ "Formatting /dev/fd0, 1.68 megabytes." 3 42
+ elif [ "$FDEV" = "/dev/fd0u1400" ]; then
+ dialog --title "Formatting /dev/fd0u1440" --infobox \
+ "Formatting /dev/fd0, 1.44 megabytes." 3 42
+ elif [ "$FDEV" = "/dev/fd0h1200" ]; then
+ dialog --title "Formatting /dev/fd0h1200" --infobox \
+ "Formatting /dev/fd0, 1.2 megabytes." 3 42
+ fi
+ fdformat $FDEV 1> /dev/null 2> /dev/null
+ if [ ! $? = 0 ]; then
+ dialog --title "ERROR: FLOPPY FORMAT FAILED" --msgbox "The attempt to format the floppy \
+disk in /dev/fd0 has failed, probably due to bad media. Please try again with a \
+different disk. If that doesn't work, perhaps the drive needs cleaning." 0 0
+ return 1
+ fi
+}
+
+DEFAULT_ITEM="syslinux"
+
+while [ 0 ]; do # menu loop
+ dialog --title "MAKE BOOT FLOPPY FROM KERNEL" \
+--default-item $DEFAULT_ITEM \
+--backtitle "$KMSG" --menu "This menu allows you to make a SYSLINUX bootdisk \
+from a compiled kernel. The SYSLINUX bootloader has the advantage of \
+using a FAT filesystem making it easy to replace the kernel later. \
+Which option would you like?" 12 67 2 \
+"syslinux" "Make a SYSLINUX bootdisk" \
+"exit" "Exit this program" 2> $TMP/return
+ if [ ! $? = 0 ]; then
+ break;
+ fi
+ REPLY=`cat $TMP/return`
+ rm -f $TMP/return
+ if [ "$REPLY" = "simple" ]; then # make simple bootdisk
+ if [ "$KERNEL" = "" ]; then
+ choose_kernel
+ fi
+ kernel_size=`du -Lk $KERNEL | cut -f1`
+ if [ "$kernel_size" -gt "1023" ]; then
+cat << EOF > $TMP/tmpmsg
+
+The kernel $KERNEL is $kernel_size K (which is
+more than 1023 Kb in size), so it probably won't
+boot standalone on the floppy. Use the 'syslinux'
+method instead.
+
+EOF
+ dialog --title "KERNEL TOO BIG!" --msgbox "`cat $TMP/tmpmsg`" 10 60
+ continue
+ fi
+ dialog --title "BOOT DISK CREATION" --backtitle "$KMSG" --yesno \
+"\n\
+Now put a formatted floppy in your boot drive. \n\
+This will be made into your Linux boot disk. Use this to\n\
+boot Linux until LILO has been configured to boot from\n\
+the hard drive.\n\n\
+Any data on the target disk will be destroyed.\n\n\
+YES creates the disk, NO aborts.\n" 14 62
+ if [ $? = 0 ]; then
+ format_disk
+ dialog --title "CREATING DISK" --infobox "Creating boot disk from $KERNEL..." 5 72
+ dd if=$KERNEL of=/dev/fd0 2> /dev/null
+ rdev /dev/fd0 $ROOT_DEVICE
+ rdev -v /dev/fd0 -1
+ if [ "$MOUNT" = "read-only" ]; then
+ rdev -R /dev/fd0 1
+ else
+ rdev -R /dev/fd0 0
+ fi
+ fi
+ elif [ "$REPLY" = "syslinux" ]; then # make syslinux bootdisk
+ DEFAULT_ITEM="exit"
+ if [ "$KERNEL" = "" ]; then
+ choose_kernel
+ fi
+ dialog --title "CREATING SYSLINUX BOOTDISK IN /dev/fd0" --backtitle "$KMSG" --yesno "Now put a \
+floppy in your boot drive. This will be made into a SYSLINUX \
+bootdisk that you can use to start your Linux system. Any data on the \
+target disk will be destroyed. YES creates the disk, NO aborts." 8 62
+ if [ $? = 0 ]; then # make the disk
+ format_disk
+ if [ ! $? = 0 ]; then
+ continue
+ fi
+ dialog --title "CREATING BOOT FLOPPY" --infobox "Creating SYSLINUX bootdisk for \
+$ROOT_DEVICE in /dev/fd0." 3 64
+ mkdosfs -F 12 /dev/fd0u1680 1680 1> /dev/null 2> /dev/null
+ if [ ! -d $TMP/bootdisk ]; then
+ mkdir $TMP/bootdisk
+ fi
+ mount -t vfat /dev/fd0 $TMP/bootdisk 1> /dev/null 2> /dev/null
+ cp $KERNEL $TMP/bootdisk/vmlinuz
+ ## This avoids a syslinux-1.72 bug, and doesn't seem to hurt anything:
+ #dd if=/dev/zero bs=1k count=1 >> $TMP/bootdisk/vmlinuz 2> /dev/null
+ if [ ! "$?" = "0" ]; then
+ dialog --title "ERROR COPYING KERNEL TO FLOPPY" \
+ --msgbox "Sorry, but there was an error copying the kernel to the \
+floppy disk. Possibly the kernel is too large to fit the disk. \
+This program will now exit." 0 0
+ umount /dev/fd0
+ rm -rf $TMP/bootdisk
+ exit 1
+ fi
+ cat << EOF > $TMP/bootdisk/message.txt
+
+Welcome to the 09Slackware07 Linux custom bootdisk!
+
+By default, this disk boots a root Linux partition on $ROOT_DEVICE when you
+hit ENTER. If you'd like to boot some other partition, use a command like
+this on the prompt below:
+
+ mount root=/dev/sda1 ro
+
+Where "/dev/sda1" is the partition you want to boot, and "ro" specifies that
+the partition should be initially mounted as read-only. If you wish to mount
+the partition read-write, use "rw" instead. To set the video console mode,
+use the vga= parameter (press F1 to see a table). You may also add any other
+kernel parameters you might need depending on your hardware, and which
+drivers are included in your kernel.
+
+EOF
+ cat << EOF > $TMP/bootdisk/syslinux.cfg
+default vmlinuz ramdisk_size=7000 root=$ROOT_DEVICE vga=normal ro
+prompt 1
+timeout 6000
+display message.txt
+F1 f1.txt
+F2 message.txt
+#F3 f3.txt
+#F4 f4.txt
+#F5 f5.txt
+#F6 f6.txt
+#F7 f7.txt
+label mount
+ kernel vmlinuz
+ append ramdisk_size=7000 root=$ROOT_DEVICE vga=normal ro
+label ramdisk
+ kernel vmlinuz
+ append vmlinuz ramdisk_size=7000 root=/dev/fd0u1440 vga=normal rw
+EOF
+ cat << EOF > $TMP/bootdisk/f1.txt
+ STANDARD MODES:
+ To make the kernel prompt for standard video modes use: vga=ask
+
+ FRAMEBUFFER MODES:
+ To get the kernel to start in VESA framebuffer mode, you need to pass it
+ a vga= init string on the "boot:" prompt. Here's a table:
+
+ Colors 640x480 800x600 1024x768 1280x1024 1600x1200
+ --------+---------------------------------------------
+ 256 | 769 771 773 775 796
+ 32,768 | 784 787 790 793 797
+ 65,536 | 785 788 791 794 798
+ 16.8M | 786 789 792 795 799
+
+ ...such as this for 1024x768x64k:
+ vga=791
+
+ F2 returns to the previous page.
+
+EOF
+ umount /dev/fd0
+ syslinux-nomtools -s /dev/fd0
+ rm -r $TMP/bootdisk
+ fi
+ elif [ "$REPLY" = "lilo" ]; then # make lilo bootdisk
+ DEFAULT_ITEM="exit"
+ if [ ! -x "`type -path lilo`" ]; then
+cat << EOF > $TMP/tmpmsg
+
+You don't have 'lilo' installed on the system.
+I guess you didn't install the lilo package.
+
+EOF
+ dialog --title "LILO NOT FOUND" --msgbox "`cat $TMP/tmpmsg`" 8 60
+ continue
+ fi
+ if [ "$KERNEL" = "" ]; then
+ choose_kernel
+ fi
+ dialog --title "CREATING LILO BOOTDISK IN /dev/fd0" --backtitle "$KMSG" --yesno "Now put a \
+floppy in your boot drive. This will be made into a LILO \
+bootdisk that you can use to start your Linux system. Any data on the \
+target disk will be destroyed. YES creates the disk, NO aborts." 8 62
+ if [ $? = 0 ]; then # make the disk
+ format_disk
+ DEV=/dev/fd0u1680
+ mknod_fd="-m 0640 $TMP/lilo$DEV b 2 44"
+ dialog --infobox "Creating LILO bootdisk from $KERNEL for $ROOT_DEVICE..." 4 60
+ mke2fs -q -m 0 -i 4096 $DEV 1> /dev/null 2> /dev/null || exit 1
+ if [ ! -d $TMP/lilo ]; then
+ mkdir -p $TMP/lilo
+ fi
+ mount -t ext2 $DEV $TMP/lilo 1> /dev/null || exit 1
+ rmdir $TMP/lilo/lost+found
+ cp $KERNEL $TMP/lilo/vmlinuz || exit 1
+ mkdir $TMP/lilo/dev
+ make_root_device
+ mknod -m 0640 $TMP/lilo/dev/fd0 b 2 0
+ mknod -m 0640 $TMP/lilo/dev/fd1 b 2 1
+ mknod $mknod_fd
+ mknod -m 0666 $TMP/lilo/dev/null c 1 3
+ mkdir $TMP/lilo/etc
+ cat << EOF > $TMP/lilo/etc/lilo.conf
+boot = $DEV
+message=/boot/message
+backup=/dev/null
+prompt
+image = /vmlinuz
+ label = mount
+ ramdisk = 0
+ root = $ROOT_DEVICE
+ vga = normal
+ $MOUNT
+EOF
+ mkdir $TMP/lilo/boot
+ cp -a /boot/chain.b $TMP/lilo/boot
+ if [ -f /boot/boot-text.b ]; then
+ cp -a /boot/boot-text.b $TMP/lilo/boot/boot.b
+ else
+ cp -a /boot/boot.b $TMP/lilo/boot
+ fi
+ cat << EOF > $TMP/lilo/boot/message
+
+Welcome to the Slackware Linux custom LILO bootdisk!
+
+By default, this disk boots a root Linux partition on $ROOT_DEVICE when
+you hit ENTER. If you'd like to boot some other partition, use a command
+like this on the LILO prompt below:
+
+ mount root=/dev/sda1 ro
+
+Where "/dev/sda1" is the partition you want to boot, and "ro" specifies that
+the partition should be initially mounted as read-only. If you which to mount
+the partition read-write, use "rw" instead. You may also add any other kernel
+parameters you might need depending on your hardware, and which drivers are
+included in your kernel.
+
+EOF
+ lilo -r $TMP/lilo > /dev/null
+ umount $TMP/lilo
+ rm -rf $TMP/lilo
+ fi
+ elif [ "$REPLY" = "exit" ]; then
+ break;
+ fi
+done