File: 60local

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 (73 lines) | stat: -rwxr-xr-x 1,753 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
70
71
72
73
#!/bin/sh
set -e

. /usr/share/debconf/confmodule

file="$1"

i=-2
while i="$(($i + 1))" || true; do
	repo_name="local$i"
	if [ $i -lt 0 ]; then repo_name="_DEVEL_"; fi
	db_get "apt-setup/$repo_name/repository" && [ "$RET" ] || {
		if [ $i -lt 0 ]; then continue; fi
		break
	}
	repository="${RET#deb }"
	comment=
	if db_get "apt-setup/$repo_name/comment"; then
		comment="$RET"
	fi
	key=
	if db_get "apt-setup/$repo_name/key"; then
		key="$RET"
	fi
	options=
	if db_get "apt-setup/$repo_name/options"; then
		options="$RET"
	fi
	echo >> $file
	if [ -n "$comment" ]; then
		echo "## $comment" >> $file
		name=$(echo "$comment" | sed -E 's/[^0-9A-Za-z]+/_/g')
	else
		name="apt-setup_$repo_name"
	fi
	key_path=
	if [ -n "$key" ]; then
		# fetch the key
		while :; do
			if fetch-url "$key" "$ROOT/tmp/key$i.pub"; then
				# select extension for key file
				if grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----' "$ROOT/tmp/key$i.pub"
				then
					ext="asc"
				else
					ext="gpg"
				fi
				key_path="/etc/apt/keyrings/$name.$ext"
				# move it into place
				mv "$ROOT/tmp/key$i.pub" "$ROOT$key_path"
				options="signed-by=$key_path${options:+ $options}"
				break
			else
				db_subst apt-setup/local/key-error MIRROR "${repository%% *}"
				db_subst apt-setup/local/key-error URL "$key"
				db_set apt-setup/local/key-error Retry
				db_input critical apt-setup/local/key-error || true
				db_go || exit 10
				db_get apt-setup/local/key-error
				if [ "$RET" = Ignore ]; then
					break
				fi
			fi
		done
	fi
	echo "deb${options:+ [$options]} $repository" >> $file
	# if true, add a line for deb-src
	if db_get "apt-setup/$repo_name/source" && [ "$RET" = true ]; then
		echo "deb-src${options:+ [$options]} $repository" >> $file
	fi
done

exit 0