home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / slakware / makeflop < prev    next >
Encoding:
Text File  |  1996-07-11  |  14.1 KB  |  514 lines

  1. #!/bin/sh
  2. # Copyright (C) 1993 David Niemi
  3. # The author places no restrictions on the use of this script.
  4.  
  5. #
  6. # Partial port to HP/UX by Michel Eyckmans (MCE) <eyckmans@imec.be>.
  7. # Only DOS formatting capability is missing.
  8. #
  9.  
  10. # this script requires mtools (except on HP/UX). If you don't have
  11. # it, get it from prep.ai.mit.edu: /pub/gnu or other GNU repositories.
  12.  
  13. # modified by Patrick Volkerding (volkerdi@mhd1.moorhead.msus.edu)
  14. # and IBM RS6000 compatibility by Torben N. Rasmussen (tnr@csd.cri.dk)
  15.  
  16. # Extensive cleanup/functionality additions by John Plocher (plocher@sun.com)
  17. # Provides interactive prompts to make disk mastering easier
  18. # Run this script in the directory containing the directories "a" "ap" ...
  19.  
  20. # Edit this as needed
  21.  
  22. MTOOLS=/usr
  23.  
  24. # Global defaults
  25.  
  26. export PATH LD_LIBRARY_PATH
  27. LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/ucblib:$MTOOLS/lib
  28. PATH=$PATH:$MTOOLS/bin
  29.  
  30. format=$MTOOLS/bin/mformat
  31. copy=$MTOOLS/bin/mcopy
  32. erase=$MTOOLS/bin/mdel
  33. eject=eject
  34.  
  35. dollar='$'
  36.  
  37. set -e  # Exit on error
  38.  
  39. # Number of disks in each set
  40.  
  41. a=8
  42. ap=5
  43. d=13
  44. e=8
  45. f=2
  46. k=6
  47. n=6
  48. t=9
  49. tcl=2
  50. x=16
  51. xap=4
  52. xd=3
  53. xv=3
  54. y=1
  55.  
  56. # Descriptions of the packages
  57.  
  58. at="Base Linux"
  59. apt="Text based applications"
  60. dt="Program Development/GCC c|c++|obj-C kernel source and more"
  61. et="Emacs"
  62. ft="FAQs"
  63. kt="Kernel source and includes"
  64. nt="Networking/UUCP/Mail/News"
  65. tt="TeX"
  66. tclt="Tcl Script Language/Tk Toolkit"
  67. xt="XFree86 X Window System"
  68. xapt="X Applications"
  69. xdt="X11 Server Development"
  70. xvt="XView (OpenLook Window Manager)"
  71. yt="Games"
  72.  
  73. PACKAGES="a ap d e f k n t tcl x xap xd xv y"
  74.  
  75. ##########################################################################
  76. # These routines are only used on an hp/ux host
  77. #
  78. hpuxdosformat () {
  79.   echo "*** Warning *** No format on HP/UX, trying without !"
  80.   ## The mediainit utility can do a low level format, but there
  81.   ## seems to be no way to create an MS-DOS filesystem.
  82.   return 0
  83. }
  84.  
  85. hpuxdoserase() {
  86.   # HACK: We can ignore our $* here, since we just want to remove
  87.   #       everything anyway. HP/UX dos commands don't know about
  88.   #       filename completion, so we have to do it the hard way.
  89.   files=`dosls $FD`
  90.   if [ "$files" != '' ]
  91.   then
  92.       dosrm -r $files     
  93.   fi
  94. }
  95.  
  96. hpuxdoswrite() {
  97.   for file in $*
  98.   do
  99.       if [ "$file" != "$FD" ]
  100.       then
  101.       echo Copying $file ...
  102.           doscp -f $file $FD`basename $file`
  103.       fi
  104.   done
  105.   return 0
  106. }
  107.  
  108. hpuxeject(){
  109.   echo "Please eject floppy disk now"
  110. }
  111.  
  112. #       (End of HP/UX specific routines)
  113. ##########################################################################
  114.  
  115. ##########################################################################
  116. # These routines are only used on an aix host
  117. #
  118. aixdosformat () {
  119.   Echo "Formatting..."
  120.   dosformat > /dev/null << EOI
  121.  
  122. n
  123. EOI
  124.   echo "done"
  125.   return 0
  126. }
  127.  
  128. aixdoswrite() {
  129.   for file in $*; do
  130.     if [ "$file" != "$FD" ]; then
  131.       echo Copying $file ...
  132.       doswrite $file `basename $file` > /dev/null
  133.     fi
  134.   done
  135.   return 0
  136. }
  137.  
  138. aixeject(){
  139.   echo "Please eject floppy disk now"
  140. }
  141. #       (End of AIX specific routines)
  142. ##########################################################################
  143.  
  144. # Linux specific formatting routines:
  145.  
  146. Linuxaformat() {
  147.     fdformat /dev/fd0H1440
  148.         if [ $? = 0 ]; then
  149.          mformat a:
  150.         else
  151.          return 1;
  152.         fi
  153.         return $?
  154. }
  155.  
  156. Linuxbformat() {
  157.     fdformat /dev/fd1H1440
  158.         if [ $? = 0 ]; then
  159.          mformat b:
  160.         else
  161.          return 1;
  162.         fi
  163.         return $?
  164. }
  165.  
  166. ##########################################################################
  167. #                       Common routines
  168. ##########################################################################
  169.  
  170. Echo() {
  171.         if [ "`echo -n `" != "'-n'" ]
  172.     then
  173.             echo -n $*' '
  174.     else
  175.             echo $*' '"\c"
  176.     fi
  177. }
  178.  
  179. ##########################################################################
  180.  
  181. Prompt() { # => diskno alldone duplicate eraseit
  182.         my_IMAGE="$1"
  183.         my_default="$2"
  184.         my_disk="$3"
  185.         my_diskno="$4"
  186.         my_maxdisk="$5"
  187.         my_series="$6"
  188.         my_descrip="$7"
  189.  
  190.         valid_answer="no"
  191.         my_need_help="yes"
  192.         imagename=$my_diskno
  193.  
  194.         while [ "$valid_answer" = "no" ]; do
  195.                 if [ "$my_need_help" = "yes" ]; then
  196.                     my_need_help="no"
  197.                     echo "__"
  198.                   if [ -z "$my_IMAGE" ]; then
  199.                     echo "[$my_disk] disk $my_diskno of $my_maxdisk (${my_descrip})"
  200.                   else
  201.                     echo "[$my_disk] ${my_descrip}"
  202.                   fi
  203.                     echo "  Please insert a blank floppy and press"
  204.                     echo "    [q]  to Quit this program"
  205.                     echo "    [h]  to show this Help message"
  206.                     echo "    [f]  to Format floppy and duplicate disk image"
  207.                     echo "    [d]  to Duplicate disk image"
  208.                   if [ -z "$my_IMAGE" ]; then
  209.                     echo "    [l]  to List the contents of disk \"$my_series$my_diskno\""
  210.                     echo "    [sd] to Skip this Disk \"$my_series$my_diskno\""
  211.                     echo "    [ss] to Skip the entire \"$my_series\" Series"
  212.                   else
  213.                     echo "    [l]  to List the possible disk images"
  214.                     echo "    [c]  to Choose a disk image"
  215.                     echo "    [s]  to Skip this disk image"
  216.                     echo "    Current image: $my_diskno"
  217.                   fi
  218.                 fi
  219.  
  220.                 Echo "__Choice: [$my_default]: "
  221.                 answer="invalid"
  222.                 read answer junk
  223.                 if [ -z "$answer" ]; then
  224.                         answer="$my_default"
  225.                 fi
  226.  
  227.                 case $answer in
  228.                 q*) echo "Quitting"; exit 0 ;;
  229.                 h*) my_need_help=yes;;
  230.                 c*)
  231.                     if [ -n "$my_IMAGE" ]; then
  232.                         Echo "$disk image: [$my_diskno]: "
  233.                         read imagename junk
  234.                         if [ -z "$imagename" ]; then
  235.                             imagename="$default_image"
  236.                         fi
  237.                         if [ ! -r "$imagename" ]; then
  238.                            echo "ERROR: \"$imagename\" is not readable."
  239.                         else
  240.                            my_diskno=$imagename
  241.                         fi
  242.                     fi;
  243.                     ;;
  244.                 l*)
  245.                     if [ -z "$my_IMAGE" ]; then
  246.                         ls -Fl $my_series$my_diskno/.??* $my_series$my_diskno/* | cut -c30-41,54-
  247.                     else
  248.                         ls -Fl $my_IMAGE | cut -c30-41,54-
  249.                     fi
  250.                     duplicate=no
  251.                     alldone=no
  252.                     eraseit=no
  253.                     ;;
  254.                 sd)
  255.                     if [ -z "$my_IMAGE" ]; then
  256.                         alldone=yes
  257.                         valid_answer=yes
  258.                     else
  259.                         echo "ERROR: Invalid entry.  Try again"
  260.                     fi
  261.                     ;;
  262.                 ss)
  263.                     if [ -z "$my_IMAGE" ]; then
  264.                         diskno=$my_maxdisk;
  265.                         alldone=yes
  266.                         valid_answer=yes
  267.                     else
  268.                         echo "ERROR: Invalid entry.  Try again"
  269.                     fi
  270.                     ;;
  271.                 s*)
  272.                     if [ -z "$my_IMAGE" ]; then
  273.                         Echo "Skip what? [d]=disk [s]=series: [d]: "
  274.                         answer="invalid"
  275.                         read answer junk
  276.                         if [ -z "$answer" ]; then
  277.                                 answer="d"
  278.                         fi
  279.                         case $answer in
  280.                                 d) alldone=yes;
  281.                                    valid_answer=yes;;
  282.                                 s) diskno=$maxdisk;
  283.                                    alldone=yes;
  284.                                    valid_answer=yes;;
  285.                                 *) echo "invalid entry - try again";;
  286.                         esac
  287.                     else
  288.                         alldone=yes
  289.                         valid_answer=yes
  290.                     fi
  291.                     ;;
  292.                 d*) duplicate=yes
  293.                     eraseit=yes
  294.                     default="d"
  295.                     valid_answer=yes
  296.                     ;;
  297.                 f*) default="f"
  298.                     if $format; then
  299.                           duplicate=yes
  300.                           eraseit=no
  301.                           valid_answer=yes
  302.                           break
  303.                     else
  304.                           echo "Error: format failed!"
  305.                           $eject
  306.                     fi
  307.                    ;;
  308.                 *)
  309.                    echo "ERROR: Invalid entry.  Try again"
  310.                    ;;
  311.                 esac
  312.         done;
  313. }
  314.  
  315. ##########################################################################
  316.  
  317. CopyImage()
  318. {
  319.     alldone=no
  320.  
  321.     echo
  322.     echo "=== $descrip ==="
  323.  
  324.     while [ "$alldone" = "no" ]; do
  325.             Prompt "$images" "f" "$disk" "$default_image" "" "" "${descrip}"
  326.             if [ "$alldone" != "no" ]; then break; fi
  327.  
  328.             if [ "$duplicate" = "yes" ]; then
  329.                 if [ -r $imagename -o -r $imagename.gz ]; then
  330.                     if [ "`basename $imagename .gz`" != "$imagename" ]; then # compressed
  331.                         gzip -cd $imagename | dd of=$device obs=18k 
  332.                         $eject
  333.                         alldone=yes
  334.                     else # uncompressed
  335.                         dd of=$device obs=18k if=$imagename 
  336.                         $eject
  337.                         alldone=yes
  338.                     fi
  339.                     break;
  340.                 else
  341.                     echo
  342.                     echo "ERROR: \"$imagename\" does not exist."
  343.                 fi
  344.             fi
  345.  
  346.     done
  347. }
  348.  
  349. ##########################################################################
  350.  
  351. CopyDisk()
  352. {
  353.     while [ "$alldone" = "no" ]; do
  354.         Prompt "" "$default" "$disk" "$diskno" "$maxdisk" "$series" "${descrip}"
  355.         if [ "$alldone" != "no" ]; then break; fi
  356.         if [ "$duplicate" = "yes" ]; then
  357.             if [ ! -d "$disk" ]; then
  358.                     echo "ERROR: Disk Image Directory \"$disk\" does not exist!"
  359.             else
  360.                     set +e
  361.                     if [ "X$eraseit" = "Xyes" ]; then
  362.                             if $erase $FD/\* 2>&1 > /dev/null; then
  363.                                 :       # All OK
  364.                             else
  365.                                 :
  366.                                 # echo "ERROR: $erase $FD/\* failed!"
  367.                                 # set -e
  368.                                 # continue
  369.                             fi
  370.                     fi
  371.                     if $copy $disk/* $FD; then
  372.                             alldone=yes
  373.                             $eject
  374.                     else
  375.                             echo "ERROR: $copy $disk/\* $FD failed!"
  376.                             $eject
  377.                             set -e
  378.                             continue
  379.                     fi
  380.                     set -e
  381.             fi
  382.         fi
  383.     done
  384. }
  385.  
  386. ########################################################################
  387.  
  388.  
  389.  
  390.  
  391. echo "########################################################################"
  392. echo "            Linux Slackware 3.0.0 disk mastering utility"
  393. echo "########################################################################"
  394. echo
  395. echo "This program should be run in the directory containing the"
  396. echo "Linux Slackware directories: $PACKAGES"
  397. echo
  398. echo "Which of the following is your target device:"
  399. echo
  400. echo "    1 - Sun floppy drive"
  401. echo "    2 - Volmgr sun floppy drive (UNTESTED)"
  402. echo "    3 - A: 3.5\" linux drive (/dev/fd0H1440)"
  403. echo "    4 - B: 3.5\" linux drive (/dev/fd1H1440)"
  404. echo "    5 - AIX RS6000 floppy drive"
  405. echo "    6 - HP/UX floppy drive"
  406. echo "    7 - Quit"
  407. echo
  408. if [ "`echo -n `" != "'-n'" ]
  409. then
  410.     echo -n "Enter your choice: [Q]: "
  411. else
  412.     echo "Enter your choice: [Q]: \c"
  413. fi
  414.  
  415. #read device junk
  416. read device;
  417. if [ -z "$device" ]; then
  418.         device="Q"
  419. fi
  420.  
  421. case "$device" in
  422.         1*|[sS]* )
  423.           FD="a:"
  424.           format="fdformat -d -f"
  425.           device=/dev/diskette
  426.           eject="eject floppy"
  427.         ;;
  428.         2*|[vV]* )
  429.           FD="a:"
  430.           format="fdformat -d -f"
  431.           device=/vol/dev/fd0
  432.           eject="eject floppy"
  433.         ;;
  434.         3*|[aA]:* )
  435.           FD="a:"
  436.           format=Linuxaformat
  437.           device=/dev/fd0H1440
  438.           eject=:
  439.         ;;
  440.         4*|[bB]:* )
  441.           FD="b:"
  442.           format=Linuxbformat
  443.           device=/dev/fd1H1440
  444.           eject=:
  445.         ;;
  446.         5*|[Aa][Ii][Xx]* )
  447.           FD="a:"
  448.           device=/dev/rfd0
  449.           format=aixdosformat
  450.           copy=aixdoswrite
  451.           eject=aixeject
  452.         ;;
  453.         6*|[Hh][Pp]* )
  454.           device=/dev/rfloppy/c201d0s0
  455.           FD=$device:
  456.           format=hpuxdosformat
  457.           copy=hpuxdoswrite
  458.       erase=hpuxdoserase
  459.           eject=hpuxeject           
  460.         ;;
  461.         [7qQ]* )
  462.           echo "Quitting"
  463.           exit 0
  464.           ;;
  465.         * )
  466.           echo "ERROR: invalid entry"
  467.           echo "Quitting"
  468.           exit 0;
  469.         ;;
  470. esac
  471.  
  472. echo "Using $FD ($device) to create floppies."
  473. echo
  474.  
  475. descrip="Slackware bootkernel disk"
  476. images="../bootdsks.*/*.gz"
  477. default_image=../bootdsks.144/modern.gz
  478. disk="Boot"
  479.  
  480. CopyImage
  481.  
  482. descrip="Slackware root/install disk"
  483. images="../rootdsks.*/*.gz"
  484. disk="Filesystem"
  485. default_image=../rootdsks.144/color144.gz
  486.  
  487. CopyImage
  488.  
  489. default="f"
  490.  
  491. for series in $PACKAGES; do
  492.         diskno=1
  493.         maxdisk=`eval echo "$dollar$series"`
  494.         descrip=`eval echo "$dollar${series}t"`
  495.  
  496.         echo
  497.         echo "=== ${descrip} ==="
  498.         echo "Making $maxdisk floppies for series \"$series\" (${descrip})"
  499.         while [ "$diskno" -le $maxdisk ]; do
  500.                 disk=$series$diskno
  501.                 alldone=no
  502.                 duplicate=no
  503.                 if [ ! -d "$disk" ]; then
  504.                         echo "ERROR: Disk Image Directory \"$disk\" does not exist!"
  505.                         alldone="yes"
  506.                 fi
  507.                 CopyDisk
  508.         diskno=`expr $diskno + 1`
  509.         done
  510. done
  511.  
  512.