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