File: 10apt-cdrom-setup

package info (click to toggle)
apt-setup 1%3A0.198
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,272 kB
  • sloc: sh: 1,247; makefile: 25
file content (69 lines) | stat: -rwxr-xr-x 2,381 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /bin/sh
set -e

. /usr/share/debconf/confmodule

# Can be preseeded to true to force cdrom entries to be disabled
db_get apt-setup/disable-cdrom-entries
disable_cdrom_entries="$RET"

# Disable cdrom sources in sources.list after installation
# if installation media is not a real CD (e.g. USB flash drive, SD/MMC card, ISO file)
# or ftp or http(s) sources are present and
#  cdrom type is "small" (netinst, live, single-desktop CD)
reason="preseed"
if [ "$disable_cdrom_entries" != "true" ] && \
   [ -e /cdrom/.disk/base_installable ] && \
   [ -e /cdrom/.disk/cd_type ]; then
	install_device="$(grep -F ' /cdrom ' /proc/mounts | cut -d' ' -f1)"
	if ! list-devices cd | grep -Fxq "$install_device"; then
		# installation device is not a real CD
		disable_cdrom_entries="true"
		reason="not_a_cd"
	elif grep -Eq "^deb (http|ftp)" /target/etc/apt/sources.list; then
		case "$(cat /cdrom/.disk/cd_type)" in
		    not_complete|live|full_cd/single)
			disable_cdrom_entries="true"
			reason="small_media"
		esac
	fi
fi

# Comment out the cdrom entries and update APT's cache
if [ "$disable_cdrom_entries" = "true" ]; then
	logger -t finish-install "Disabling CDROM entries in sources.list ($reason)"
	sed -i "/^deb cdrom:/s/^/#/" /target/etc/apt/sources.list
	case "$reason" in
	    small_media)
		cat >> /target/etc/apt/sources.list <<EOF

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.
EOF
		;;
	    not_a_cd)
		cat >> /target/etc/apt/sources.list <<EOF

# This system was installed using removable media other than
# CD/DVD/BD (e.g. USB stick, SD card, ISO image file).
# The matching "deb cdrom" entries were disabled at the end
# of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.
EOF
		;;
	    preseed)
		cat >> /target/etc/apt/sources.list <<EOF

# This system was installed using removable media.
# The matching "deb cdrom" entries were disabled at the end
# of the installation process by preseed.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.
EOF
	esac
	log-output -t finish-install chroot /target apt-get update
fi