3 # Copyright © 1995-1998 Ian Jackson <ijackson@chiark.greenend.org.uk>
4 # Copyright © 1998 Heiko Schlittermann <hs@schlittermann.de>
5 # Copyright © 1998-1999 Martin Schulze <joey@infodrom.north.de>
7 # This is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <https://www.gnu.org/licenses/>.
25 test -d "$vardir/methods/$method" || mkdir
"$vardir/methods/$method"
26 cd "$vardir/methods/$method"
27 tp
="$(mktemp --tmpdir $method.XXXXXXXXXX)"
29 iarch
=$
(dpkg
--print-architecture)
35 if [ -n "$umount" ]; then
36 umount "$umount" >/dev/null 2>&1
41 if ls -d "$tp.?" >/dev
/null
2>&1; then
45 #debug() { echo "DEBUG: $@"; }
50 debug
$1 $2; test -e "$1/.disk/info" ||
test -e "$1$2/.disk/info"
57 if [ -f $1/.disk
/info
]; then
58 echo -n $
(head -1 "$1/.disk/info")
59 elif [ -f $1$2/.disk
/info
]; then
60 echo -n $
(head -1 "$1$2/.disk/info")
62 echo -n 'Non-Debian disc'
70 if [ -z "$response" ]; then
87 mountpoint
="$vardir/methods/mnt"
88 if [ -z "$defaultdevice" ]; then
89 defaultdevice
="$newdefaultdevice"
90 elif [ "$defaultdevice" != "$newdefaultdevice" ]; then
91 echo "Last time you specified installation from $defaultdevice."
94 while [ -z "$blockdevice" ]; do
95 echo -n "$promptstring [$defaultdevice]: "
97 if [ -z "$response" ]; then
98 response
="$defaultdevice"
100 if [ ! -b "$response" ]; then
101 echo "$response is not a block device - will try as loopback."
104 tryblockdevice
="$response"
107 if mount
-rt "$fstype" -o nosuid
,nodev
$loop "$tryblockdevice" "$mountpoint"
110 blockdevice
="$tryblockdevice"
113 echo "Unable to mount $tryblockdevice on $mountpoint, type $fstype."
119 echo "$2" |
sed -e "s/'/'\\\\''/; s/^/$1='/; s/$/'/" >&3
123 intrkey
="$(stty -a | sed -n 's/.*intr = \([^;]*\);.*/\1/p')"
125 If you make a mistake, use the interrupt key ($intrkey) to abort.
128 # State variables, “best first”
129 # {main,ctb,nf,lcl}_{packages,binary}
130 # Empty before we've found them or if they're not available,
131 # set to the relevant bit under mountpoint otherwise.
133 # A directory containing a Debian FTP site mirror tree.
135 # The mountpoint for the filesystem containing the stuff
136 # empty or unset if we don't know yet, or if we haven't mounted anything;
137 # may also be empty if ‘directory’ was set.
139 # The actual block device to mount.
141 # The filesystem type to use.
143 # The default block device to mount.
146 if [ -f shvar.
$option ]; then
148 defaultdevice
="$p_blockdev"
149 usedevel
="$p_usedevel"
153 sed -n 's/ ([^)]*)$//; s/^[^ ]* on //; s/ type iso9660$//p' <$tp.m
>$tp.l
154 ncdroms
=$
(wc -l <$tp.l
)
155 if [ $ncdroms -gt 1 ]; then
157 while [ -z "$response" ]; do
158 echo 'Several media discs (ISO9660 filesystems) are mounted:'
159 grep -E 'type iso9660 \([^)]*\)$' <$tp.m |
nl
160 echo -n "Is it any of these ? Type a number, or 'n' for none. "
162 response
="$(echo "$response" | sed -e 's/[ ]*$//')"
163 if expr "$response" : '[0-9][0-9]*$' >/dev
/null
&& \
164 [ $response -ge 1 -a $response -le $ncdroms ]; then
165 mountpoint
="$(sed -n $response'p' <$tp.l)"
167 elif expr "$response" : '[Nn]' >/dev
/null
; then
173 elif [ $ncdroms = 1 ]; then
174 mountpoint
="$(cat $tp.l)"
175 perl
-ne 'print if s/ type iso9660 \([^)]*\)$// && s/ on .*$//;' \
177 blockdevice
="$(cat $tp.d)"
179 "Found a media disc: $blockdevice, mounted on $mountpoint. Is it the right one?"
180 if [ $yesno = no
]; then
181 echo 'Unmounting it ...'
184 echo -n 'Please insert the right disc, and hit return: '
186 if mount
-rt iso9660
-o nosuid
,nodev \
187 "$blockdevice" "$mountpoint"; then
194 if [ -z "$mountpoint" ]; then
195 if [ -b /dev
/cdrom
]; then
196 echo 'Found that /dev/cdrom exists and is a block device.'
197 newdefaultdevice
=/dev
/cdrom
199 getblockdev
'Insert the media and enter the block device name'
202 if [ -n "$mountpoint" ]; then
203 # We must have $mountpoint
205 'All directory names should be entered relative to the root of the media disc.
209 # now try to get the users idea where the debian
210 # hierarchy start below the mointpoint
212 debug
"mountpoint: $mountpoint"
214 if ismulti
"${mountpoint}" "${hierbase}"; then
219 "Need to know where on the media disc the top level of the Debian
220 distribution is - this will usually contain the 'dists' directory.
222 If the media disc is badly organized and doesn't have a straightforward copy of
223 the distribution you may answer 'none' and the needed parts will be prompted
227 if [ -n "$p_hierbase" ]; then
228 if [ -d "$mountpoint/$p_hierbase/dists/$dist/main/binary-$iarch" \
229 -o -n "$multi" ]; then
230 echo "Last time you said '$p_hierbase', and that looks plausible."
231 defhierbase
="$p_hierbase"
234 Last time you said '$p_hierbase', but that doesn't look plausible,
235 since '$p_hierbase/dists/$dist/main/binary-$iarch' doesn't seem to exist.
236 And it does not appear that you are using a multiple media set."
240 # at this point defhierbase is set if it looks plausible
241 # if ‘none’ was entered, we assume a media with a debian/ directory
243 if [ none
= "$defhierbase" -a -d "$mountpoint/debian/dists/$dist/main/binary-$iarch" ]
245 echo "'/debian' exists and looks plausible, so that's the default."
249 echo -n "Distribution top level ? [$defhierbase] "
251 if [ -z "$response" ]; then
252 response
="$defhierbase"
254 if [ none
= "$response" ]; then
257 elif ismulti
"$mountpoint" "$response" && [ -z "$multi" ]; then
261 if ! [ -d "$mountpoint/$response/dists/$dist/main/binary-$iarch" \
262 -o -n "$multi" ]; then
264 "Neither $response/dists/$dist/main/binary-$iarch does not exist,
265 nor are you using a multiple media set"
269 hierbase
="$(echo "$response" | sed -e 's:/$::; s:^/*:/:; s:/\+:/:g;')"
270 debug
"hierbase: [$hierbase]"
272 if [ -n "$multi" ]; then
273 disklabel
=$
(getdisklabel
"$mountpoint" "/$response")
274 echo "Ok, this is disc"
276 #echo "Updating multiple media contents file cache ..."
277 #multi_contentsfile="${mountpoint}/${response}/.disk/contents.gz"
278 #zcat "$multi_contentsfile" > disk-contents.$option
285 if [ -n "$hierbase" ]; then
286 if [ -d "$mountpoint/$hierbase/dists/unstable/binary-$iarch" ]; then
289 Both a stable released distribution and a work-in-progress
290 development tree are available for installation. Would you like to
291 use the unreleased development tree (this is only recommended for
292 experts who like to live dangerously and want to help with testing) ?'
293 yesno
"$p_usedevel" 'Use unreleased development distribution ?'
295 if [ "$usedevel" = yes ]; then
296 distribution
=development
310 hierbase
="/$hierbase"
315 # args: area-in-messages directory
316 debug
"check_binary($@)"
318 if [ ! -d "${mountpoint}$2" -a -z "$multi" ]; then
319 echo "'$2' does not exist."
323 # In this special case it is ok for a sub-distribution to not contain any
324 # .deb files. Each media should contain all Packages.cd files but does not
325 # need to contain the .deb files.
327 # if ! { find -L "$mountpoint$2" -name '*.deb' -print \
328 # | head -1 | grep . ; } >/dev/null 2>&1 && [ -z "$multi" ];
330 # echo "'$2' does not contain any *.deb packages."
335 echo -n "Using '$this_binary' as $1 binary directory"
337 if [ -n "$multi" ]; then
338 this_disk
=$
(getdisklabel
${mountpoint} "/$hierbase")
347 # args: area-in-messages area-in-vars subdirectory-in-hier
348 # last-time-binary last-time-packages
349 debug
"find_area($@)"
353 if [ -n "$hierbase" ]; then
354 check_binary
$1 $
(echo "$hierbase/dists/$3/$1/binary-$iarch" |
sed 's:/\+:/:g')
355 debug
"THIS_BINARY $this_binary"
357 if [ $2 = nf
-a -z "$this_binary" ]; then
359 Note: most media distributions of Debian do not include programs available
360 in the 'non-free' directory of the distribution site.
361 This is because these programs are under licenses that do not allow source
362 modification or prevent distribution for profit on a media, or other
363 restrictions that make them not free software.
364 If you wish to install these programs you will have to get them from an
367 while [ -z "$this_binary" ]; do
370 Which directory contains the *.deb packages from the $1 distribution
371 area (this directory is named '$3/binary' on the distribution site) ?
372 Say 'none' if this area is not available."
373 if [ $2 != main
-a -z "$defaultbinary" ]; then
377 "Enter _$1_ binary directory. [$4]
380 if [ -z "$response" -a -n "$defaultbinary" ]; then
381 response
="$defaultbinary"
383 if [ none
= "$response" ]; then
391 check_binary
$1 "$(echo "$response" | sed -e 's:/$::; s:^/*:/:')"
393 if [ -n "$this_binary" ]; then
394 if [ "$multi" = "yes" ]; then
395 for f
in Packages.
cd.gz packages.
cd.gz Packages.
cd packages.
cd; do
396 if [ -f "$mountpoint/$this_binary/$f" ]; then
397 this_packages
="$this_binary/$f"
398 echo "Using '$this_packages' for $1."
402 elif [ -f "${mountpoint}${hierbase}/.disk/packages/$1/Packages.gz" ]; then
403 this_packages
=$
(echo "${hierbase}/.disk/packages/$1/Packages.gz"|
sed 's:/\+:/:g')
404 echo "Using '${this_packages}' for $1."
406 while [ -z "$this_packages" ]; do
408 Cannot find the $1 'Packages.cd' file. The information in the
409 'Packages.cd' file is important for package selection during new
410 installations, and is very useful for upgrades.
412 If you overlooked it when downloading you should do get it now and
413 return to this installation procedure when you have done so: you will
414 find one Packages.cd file and one Packages.cd.gz file -- either will do --
415 in the 'binary' subdirectory of each area on the FTP sites and
416 media discs. Alternatively (and this will be rather slow) the packages in
417 the distribution area can be scanned - say 'scan' if you want to do so.
419 You need a separate Packages.cd file from each of the distribution areas
422 Where is the _$1_ 'Packages.cd' file (if none is available, say 'none')
426 if [ -z "$response" -a -n "$5" ]; then
440 this_packages
="$response"
443 this_packages
="/$response"
448 eval $2'_binary="$this_binary"'
449 eval $2'_packages="$this_packages"'
450 eval $2'_disk="$this_disk"'
453 find_area main main
"$distribution" "$p_main_binary" "$p_main_packages"
454 find_area contrib ctb
"$distribution" "$p_ctb_binary" "$p_ctb_packages"
455 find_area non-free-firmware nff
"$distribution" "$p_nff_binary" "$p_nff_packages"
456 find_area non-free nf
"$distribution" "$p_nf_binary" "$p_nf_packages"
457 find_area
local lcl
local "$p_lcl_binary" "$p_lcl_packages"
460 Hit RETURN to continue. '
463 exec 3>shvar.
$option.new
465 outputparam p_blockdev
"$blockdevice"
466 outputparam p_fstype
"$fstype"
467 outputparam p_mountpoint
"$mountpoint"
468 outputparam p_hierbase
"$hierbase"
469 outputparam p_usedevel
"$usedevel"
470 outputparam p_main_packages
"$main_packages"
471 outputparam p_main_binary
"$main_binary"
472 outputparam p_main_disk
"$main_disk"
473 outputparam p_ctb_packages
"$ctb_packages"
474 outputparam p_ctb_binary
"$ctb_binary"
475 outputparam p_ctb_disk
"$ctb_disk"
476 outputparam p_nff_packages
"$nff_packages"
477 outputparam p_nff_binary
"$nff_binary"
478 outputparam p_nff_disk
"$nff_disk"
479 outputparam p_nf_packages
"$nf_packages"
480 outputparam p_nf_binary
"$nf_binary"
481 outputparam p_nf_disk
"$nf_disk"
482 outputparam p_lcl_packages
"$lcl_packages"
483 outputparam p_lcl_binary
"$lcl_binary"
484 outputparam p_multi
"$multi"
485 outputparam p_multi_contentsfile
"$multi_contentsfile"
487 mv shvar.
$option.new shvar.
$option