3 # The ‘multicd’ package was initially written by Heiko Schlittermann
4 # <heiko@lotte.sax.de> based on builtin access methods written by Ian
5 # Jackson <ijackson@chiark.greenend.org.uk>. The final packaging as well as
6 # cleanups were made by Martin Schulze <joey@infodrom.north.de> who also
7 # put this package together for the slink release (Debian GNU/Linux
10 # Copyright © 1995-1998 Ian Jackson <ijackson@chiark.greenend.org.uk>
11 # Copyright © 1998 Heiko Schlittermann <hs@schlittermann.de>
13 # This is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <https://www.gnu.org/licenses/>.
31 test -d "$vardir/methods/$method" || mkdir "$vardir/methods/$method"
32 cd "$vardir/methods/$method"
35 iarch=`dpkg --print-architecture`
43 umount "$umount" >/dev/null 2>&1
48 if ls -d "$tp.?" >/dev/null 2>&1
53 #debug() { echo "DEBUG: $@"; }
55 ismulti() { debug $1 $2; test -e "$1/.disk/info" || test -e "$1$2/.disk/info"; }
61 if [ -f $1/.disk/info ]
63 echo -n `head -1 "$1/.disk/info"`
65 if [ -f $1$2/.disk/info ]
67 echo -n `head -1 "$1$2/.disk/info"`
69 echo -n 'Non-Debian disc'
84 [Nn]*) yesno=no ; return ;;
85 [Yy]*) yesno=yes ; return ;;
91 mountpoint="$vardir/methods/mnt"
92 if [ -z "$defaultdevice" ]
94 defaultdevice="$newdefaultdevice"
95 elif [ "$defaultdevice" != "$newdefaultdevice" ]
98 "Last time you specified installation from $defaultdevice."
101 while [ -z "$blockdevice" ]
103 echo -n "$promptstring [$defaultdevice]: "
105 if [ -z "$response" ]
107 response="$defaultdevice"
109 if [ ! -b "$response" ]
111 echo "$response is not a block device - will try as loopback.";
114 tryblockdevice="$response"
115 if [ $option = multi_cd ]
118 elif [ $option = harddisk2 ]
120 blockbase="`echo \"$tryblockdevice\" | sed -e 's/[0-9]\{1,\}$//'`"
122 printf 'p\nq\n' | fdisk "$blockbase" 2>/dev/null >$tp.f
124 proposeddevice="$tryblockdevice" perl -ne '
125 next unless /^ *Device +Boot +Begin +Start +End +Blocks +Id +System *$/i .. !/\S/;
126 next unless s:^/\S+::p && ${^MATCH} eq $ENV{proposeddevice};
127 next unless s/^ +(\* +)?\d+ +\d+ +\d+ +\d+\+? +//;
128 next unless m/^([0-9a-f]{1,2}) /i;
129 %types= ( "1","msdos", "4","msdos", "6","msdos", "7","hpfs", "80","minix",
130 "81","minix", "83","ext2" );
131 print $types{$1}; exit(0); ' <$tp.f >$tp.m
132 defaultfstype="`cat $tp.m`"
133 if [ -n "$defaultfstype" ]
136 The partition table for $blockbase claims that $tryblockdevice
137 contains filesystem type $defaultfstype.
139 if ! grep " $defaultfstype$" /proc/filesystems >/dev/null
142 "Your kernel does not appear to support that filesystem type."
146 echo -n "Supported filesystems: "
147 sed -e 's/^.* / /' /proc/filesystems | tr '\n' ' '
149 Enter filesystem type (for $tryblockdevice) [$defaultfstype]: "
153 fstype="$defaultfstype"
157 if mount -rt "$fstype" -o nosuid,nodev$loop "$tryblockdevice" "$mountpoint"
160 blockdevice="$tryblockdevice"
164 "Unable to mount $tryblockdevice on $mountpoint, type $fstype."
170 echo "$2" | sed -e "s/'/'\\\\''/; s/^/$1='/; s/$/'/" >&3
174 intrkey="`stty -a | sed -n 's/.*intr = \([^;]*\);.*/\1/p'`"
176 If you make a mistake, use the interrupt key ($intrkey) to abort.
179 # State variables, “best first”
180 # {main,ctb,nf,nonus,nonusctb,nonusnf,lcl}_{packages,binary}
181 # Empty before we've found them or if they're not available,
182 # set to the relevant bit under mountpoint otherwise.
184 # A directory containing a Debian FTP site mirror tree.
186 # The mountpoint for the filesystem containing the stuff
187 # empty or unset if we don't know yet, or if we haven't mounted anything;
188 # may also be empty if ‘directory’ was set.
190 # The actual block device to mount.
192 # The filesystem type to use.
194 # The default block device to mount.
197 if [ -f shvar.$option ]
200 defaultdevice="$p_blockdev"
201 defaultnfsserver="$p_nfsserver"
202 defaultnfsrempath="$p_nfsrempath"
203 usedevel="$p_usedevel"
206 if [ $option = multi_cd ]
209 sed -n 's/ ([^)]*)$//; s/^[^ ]* on //; s/ type iso9660$//p' <$tp.m >$tp.l
210 ncdroms=`wc -l <$tp.l`
211 if [ $ncdroms -gt 1 ]
214 while [ -z "$response" ]
217 'Several CD-ROMs (or other ISO9660 filesystems) are mounted:'
218 egrep 'type iso9660 \([^)]*\)$' <$tp.m | nl
220 "Is it any of these ? Type a number, or 'n' for none. "
222 response="`echo \"$response\" | sed -e 's/[ ]*$//'`"
223 if expr "$response" : '[0-9][0-9]*$' >/dev/null && \
224 [ $response -ge 1 -a $response -le $ncdroms ]
226 mountpoint="`sed -n $response'p' <$tp.l`"
228 elif expr "$response" : '[Nn]' >/dev/null
235 elif [ $ncdroms = 1 ]
237 mountpoint="`cat $tp.l`"
238 perl -ne 'print if s/ type iso9660 \([^)]*\)$// && s/ on .*$//;' \
240 blockdevice="`cat $tp.d`"
242 "I see a CD-ROM: $blockdevice, mounted on $mountpoint. Is it the right one ?"
245 echo 'Unmounting it ...'
250 'Please insert the right disc, and hit return: '
252 if mount -rt iso9660 -o nosuid,nodev \
253 "$blockdevice" "$mountpoint"
261 if [ -z "$mountpoint" ]
266 'I see that /dev/cdrom exists and is a block device.'
267 newdefaultdevice=/dev/cdrom
269 getblockdev 'Insert the CD-ROM and enter the block device name'
273 if [ $option = multi_nfs ]
275 mountpoint="$vardir/methods/mnt"
276 while [ -z "$nfsserver" ]
279 "What is the name of the NFS server ? [$defaultnfsserver] "
281 if [ -z "$response" -a -n "$defaultnfsserver" ]
283 response="$defaultnfsserver"
285 if [ -z "$response" ]; then continue; fi
286 if [ -x "`which rpcinfo`" ]
288 if rpcinfo -u "$response" mountd >/dev/null
290 nfsserver="$response"
292 echo "$response appears not to be an NFS server."
294 elif [ -x "`which ping`" ]
296 if ping -q -c 1 "$response" | grep -q ', 1 packets received'
298 nfsserver="$response"
300 echo "$response appears to be down or nonexistent."
304 "(I can't check that now because there is no rpcinfo or ping.)"
305 nfsserver="$response"
308 while [ -z "$nfsrempath" ]
311 What is the pathname on the NFS server of the filesystem with
312 the Debian files ? [$defaultnfsrempath] "
314 if [ -z "$response" -a -n "$defaultnfsrempath" ]
316 response="$defaultnfsrempath"
318 response="`echo \"$response\" | sed -e 's:/$::; s:^/*:/:'`"
321 if mount -rt nfs -o nosuid,nodev "$nfsserver:$response" "$mountpoint"
324 nfsrempath="$response"
328 "Unable to mount NFS filesystem $nfsserver:$response."
331 nfs="$nfsserver:$nfsrempath"
334 if [ $option = harddisk2 ]
337 printf 'p\nq\n' | fdisk /dev/hda 2>/dev/null >$tp.f
340 printf 'p\nq\n' | fdisk /dev/sda 2>/dev/null >$tp.f
344 next unless /^ *Device +Boot +Begin +Start +End +Blocks +Id +System *$/i .. !/\S/;
345 next unless / [146] +DOS \d+-bit \S+$/;
346 next unless m:^/\S+:p;
347 print ${^MATCH}; ' <$tp.f >$tp.d
348 newdefaultdevice="`cat $tp.d`"
350 I need to know which disk partition contains the distribution files;
351 disk partitions are specified by the block device name in Linux."
352 if [ -n "$newdefaultdevice" ]
355 "By the way, $newdefaultdevice looks like a DOS partition."
357 getblockdev "Enter the partition's block device name"
360 if [ -n "$mountpoint" ]
362 # We must have $mountpoint
363 if [ $option = multi_cd ]
366 'All directory names should be entered relative to the root of the CD-ROM.
368 elif [ $option = multi_nfs ]
371 "All directory names should be entered relative to the root of the NFS
372 filesystem, ie relative to $nfsrempath on the server.
376 "All directory names should be entered relative to the root of the
377 $fstype filesystem on $blockdevice.
382 # now try to get the users idea where the debian
383 # hierarchy start below the mointpoint
385 debug "mountpoint: $mountpoint"
388 if ismulti "${mountpoint}" "${hierbase}"; then
392 if [ $option = multi_cd ]
395 "I would like to know where on the CD-ROM the top level of the Debian
396 distribution is - this will usually contain the 'dists' directory.
398 If the CD-ROM is badly organized and doesn't have a straightforward copy of
399 the distribution you may answer 'none' and we'll go through the parts
400 I need individually."
403 "In order to make it easy for me to find the relevant files I'd ideally
404 like to install from a straightforward copy of the Debian distribution.
405 To use this I'll need to know where the top level of that copy of the
406 distribution is - this directory usually contains the Packages-Master file.
408 If you do not have a straightforward copy of the distribution available
409 just answer 'none' and we'll go through the parts I need individually."
413 if [ -n "$p_hierbase" ]; then
414 if [ -d "$mountpoint/$p_hierbase/dists/$dist/main/binary-$iarch" \
415 -o -n "$multi" ]; then
416 echo "Last time you said '$p_hierbase', and that looks plausible."
417 defhierbase="$p_hierbase"
420 Last time you said '$p_hierbase', but that doesn't look plausible,
421 since '$p_hierbase/dists/$dist/main/binary-$iarch' doesn't seem to exist.
422 And I can't get the impression that you're using a multi-CD set."
426 # at this point defhierbase is set if it looks plausible
427 # if ‘none’ was entered, we assume a CD with a debian/ directory
429 if [ none = "$defhierbase" -a -d "$mountpoint/debian/dists/$dist/main/binary-$iarch" ]
431 echo "'/debian' exists and looks plausible, so that's the default."
435 echo -n "Distribution top level ? [$defhierbase] "
437 if [ -z "$response" ]; then response="$defhierbase"; fi
438 if [ none = "$response" ]; then
441 elif ismulti "$mountpoint" "$response" && [ -z "$multi" ]; then
445 if ! [ -d "$mountpoint/$response/dists/$dist/main/binary-$iarch" \
446 -o -n "$multi" ]; then
448 "Neither $response/dists/$dist/main/binary-$iarch does not exist,
449 nor are you using a multi-CD set"
453 hierbase="`echo \"$response\" | sed -e 's:/$::; s:^/*:/:; s:/\+:/:g;'`"
454 debug "hierbase: [$hierbase]"
456 if [ -n "$multi" ]; then
457 disklabel=`getdisklabel "$mountpoint" "/$response"`
458 echo "Ok, this is disc"
460 #echo "Updating multi CD contents file cache ..."
461 #multi_contentsfile="${mountpoint}/${response}/.disk/contents.gz"
462 #zcat "$multi_contentsfile" > disk-contents.$option
469 if [ -n "$hierbase" ]
471 if [ -d "$mountpoint/$hierbase/dists/unstable/binary-$iarch" ]
475 Both a stable released distribution and a work-in-progress
476 development tree are available for installation. Would you like to
477 use the unreleased development tree (this is only recommended for
478 experts who like to live dangerously and want to help with testing) ?'
479 yesno "$p_usedevel" 'Use unreleased development distribution ?'
481 if [ "$usedevel" = yes ]
483 distribution=development
494 * ) hierbase="/$hierbase" ;;
498 # args: area-in-messages directory
499 debug "check_binary($@)"
501 if [ ! -d "${mountpoint}$2" -a -z "$multi" ]
503 echo "'$2' does not exist."
507 # In this special case it is ok for a sub-distribution to not contain any
508 # .deb files. Each CD should contain all Packages.cd files but doesn't
509 # need to contain the .deb files.
511 # if ! { find -L "$mountpoint$2" -name '*.deb' -print \
512 # | head -1 | grep . ; } >/dev/null 2>&1 && [ -z "$multi" ];
514 # echo "'$2' does not contain any *.deb packages."
519 echo -n "Using '$this_binary' as $1 binary directory"
521 if [ -n "$multi" ]; then
522 this_disk=`getdisklabel ${mountpoint} "/$hierbase"`
531 # args: area-in-messages area-in-vars subdirectory-in-hier
532 # last-time-binary last-time-packages
533 debug "find_area($@)"
537 if [ -n "$hierbase" ]
539 check_binary $1 `echo "$hierbase/dists/$3/$1/binary-$iarch" | sed 's:/\+:/:g'`
540 debug "THIS_BINARY $this_binary"
542 if [ $option = multi_cd -a $2 = nf -a -z "$this_binary" ]
545 Note: most CD-ROM distributions of Debian do not include programs
546 available in the 'non-free' directory of the distribution site.
547 This is because these programs have copyrights that prevent
548 distribution for profit on a CD-ROM - ie they are not free software.
549 If you wish to install these programs you'll have to get them from an
552 while [ -z "$this_binary" ]
556 Which directory contains the *.deb packages from the $1 distribution
557 area (this directory is named '$3/binary' on the distribution site) ?
558 Say 'none' if this area is not available."
559 if [ $2 != main -a -z "$defaultbinary" ]
564 "Enter _$1_ binary directory. [$4]
567 if [ -z "$response" -a -n "$defaultbinary" ]
569 response="$defaultbinary"
571 if [ none = "$response" ]
576 '' | none) continue ;;
578 check_binary $1 "`echo \"$response\" | sed -e 's:/$::; s:^/*:/:'`"
580 if [ -n "$this_binary" ]
582 if [ "$multi" = "yes" ]; then
583 for f in Packages.cd.gz packages.cd.gz Packages.cd packages.cd
585 if [ -f "$mountpoint/$this_binary/$f" ]
587 this_packages="$this_binary/$f"
588 echo "Using '$this_packages' for $1."
593 if [ -f "${mountpoint}${hierbase}/.disk/packages/$1/Packages.gz" ]; then
594 this_packages=`echo "${hierbase}/.disk/packages/$1/Packages.gz"|sed 's:/\+:/:g'`
595 echo "Using '${this_packages}' for $1."
598 while [ -z "$this_packages" ]
601 I can't find the $1 'Packages.cd' file. The information in the
602 'Packages.cd' file is important for package selection during new
603 installations, and is very useful for upgrades.
605 If you overlooked it when downloading you should do get it now and
606 return to this installation procedure when you have done so: you will
607 find one Packages.cd file and one Packages.cd.gz file -- either will do --
608 in the 'binary' subdirectory of each area on the FTP sites and
609 CD-ROMs. Alternatively (and this will be rather slow) I can scan the
610 packages in the distribution area - say 'scan' if you want me to do so.
612 You need a separate Packages.cd file from each of the distribution areas
615 Where is the _$1_ 'Packages.cd' file (if none is available, say 'none')
619 if [ -z "$response" -a -n "$5" ]
626 scan) this_packages=scan ;;
627 /*) this_packages="$response" ;;
628 *) this_packages="/$response" ;;
632 eval $2'_binary="$this_binary"'
633 eval $2'_packages="$this_packages"'
634 eval $2'_disk="$this_disk"'
637 find_area main main "$distribution" "$p_main_binary" "$p_main_packages"
638 find_area contrib ctb "$distribution" "$p_ctb_binary" "$p_ctb_packages"
639 find_area non-free nf "$distribution" "$p_nf_binary" "$p_nf_packages"
640 find_area non-US/main nonus "$distribution" "$p_nonus_binary" "$p_nonus_packages"
641 find_area non-US/contrib nonusctb "$distribution" "$p_nonusctb_binary" "$p_nonusctb_packages"
642 find_area non-US/non-free nonusnf "$distribution" "$p_nonusnf_binary" "$p_nonusnf_packages"
643 find_area local lcl local "$p_lcl_binary" "$p_lcl_packages"
646 Hit RETURN to continue. '
649 exec 3>shvar.$option.new
651 outputparam p_blockdev "$blockdevice"
652 outputparam p_fstype "$fstype"
653 outputparam p_mountpoint "$mountpoint"
654 outputparam p_nfsserver "$nfsserver"
655 outputparam p_nfsrempath "$nfsrempath"
656 outputparam p_nfs "$nfs"
657 outputparam p_hierbase "$hierbase"
658 outputparam p_usedevel "$usedevel"
659 outputparam p_main_packages "$main_packages"
660 outputparam p_main_binary "$main_binary"
661 outputparam p_main_disk "$main_disk"
662 outputparam p_ctb_packages "$ctb_packages"
663 outputparam p_ctb_binary "$ctb_binary"
664 outputparam p_ctb_disk "$ctb_disk"
665 outputparam p_nf_packages "$nf_packages"
666 outputparam p_nf_binary "$nf_binary"
667 outputparam p_nf_disk "$nf_disk"
668 outputparam p_nonus_binary "$nonus_binary"
669 outputparam p_nonus_packages "$nonus_packages"
670 outputparam p_nonus_disk "$nonus_disk"
671 outputparam p_nonusctb_binary "$nonusctb_binary"
672 outputparam p_nonusctb_packages "$nonusctb_packages"
673 outputparam p_nonusctb_disk "$nonusctb_disk"
674 outputparam p_nonusnf_binary "$nonusnf_binary"
675 outputparam p_nonusnf_packages "$nonusnf_packages"
676 outputparam p_nonusnf_disk "$nonusnf_disk"
677 outputparam p_lcl_packages "$lcl_packages"
678 outputparam p_lcl_binary "$lcl_binary"
679 outputparam p_multi "$multi"
680 outputparam p_multi_contentsfile "$multi_contentsfile"
682 mv shvar.$option.new shvar.$option