Skip to content

Commit da46e1a

Browse files
committed
Use deb822 sources format everywhere
1 parent fd60196 commit da46e1a

File tree

4 files changed

+71
-40
lines changed

4 files changed

+71
-40
lines changed

chroot-script

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,34 @@ markauto() {
9292
}
9393
# }}}
9494

95+
# write a deb822 sources stanza to a file {{{
96+
writesource() {
97+
local file types uris suites components signed_by
98+
99+
file="${1:-}"
100+
types="${2:-}"
101+
uris="${3:-}"
102+
suites="${4:-}"
103+
components="${5:-}"
104+
signed_by="${6:-}"
105+
106+
mkdir -p "$(dirname "${file}")"
107+
108+
if [ -f "$file" ]; then
109+
## stanzas need a space between them and the previous stanza
110+
echo '' >> "$file"
111+
fi
112+
113+
echo "Types: $types" >> "$file"
114+
echo "URIs: $uris" >> "$file"
115+
echo "Suites: $suites" >> "$file"
116+
echo "Components: $components" >> "$file"
117+
if [ -n "$signed_by" ]; then
118+
echo "Signed-By: $signed_by" >> "$file"
119+
fi
120+
}
121+
# }}}
122+
95123
# define chroot mirror {{{
96124
chrootmirror() {
97125
if [ "$KEEP_SRC_LIST" = "yes" ] ; then
@@ -105,8 +133,16 @@ chrootmirror() {
105133
echo "Using repository components $COMPONENTS"
106134

107135
if [ -n "$MIRROR" ] ; then
108-
echo "Adjusting sources.list for mirror (${MIRROR})."
109-
echo "deb $MIRROR $RELEASE $COMPONENTS" > /etc/apt/sources.list
136+
echo "Deleting obsolete sources.list"
137+
rm -f /etc/apt/sources.list
138+
139+
if grep -q 'file:' <<< "$MIRROR" ; then
140+
echo "Adjusting sources.list.d/local.sources for mirror (${MIRROR})."
141+
writesource '/etc/apt/sources.list.d/local.sources' 'deb' "$MIRROR" "$RELEASE" "$COMPONENTS" '/usr/share/keyrings/debian-archive-keyring.gpg'
142+
else
143+
echo "Adjusting sources.list.d/debian.sources for mirror (${MIRROR})."
144+
writesource '/etc/apt/sources.list.d/debian.sources' 'deb' "$MIRROR" "$RELEASE" "$COMPONENTS" '/usr/share/keyrings/debian-archive-keyring.gpg'
145+
fi
110146
fi
111147

112148
# add security.debian.org:
@@ -115,8 +151,8 @@ chrootmirror() {
115151
*)
116152
# bullseye and newer releases use a different repository layout, see
117153
# https://lists.debian.org/debian-devel-announce/2019/07/msg00004.html
118-
echo "Adding security.debian.org/debian-security to sources.list."
119-
echo "deb http://security.debian.org/debian-security ${RELEASE}-security $COMPONENTS" >> /etc/apt/sources.list
154+
echo "Adding security.debian.org/debian-security to sources.list.d/debian.sources."
155+
writesource '/etc/apt/sources.list.d/debian.sources' 'deb' 'http://security.debian.org/debian-security' "${RELEASE}-security" "$COMPONENTS" '/usr/share/keyrings/debian-archive-keyring.gpg'
120156
;;
121157
esac
122158
}
@@ -130,11 +166,10 @@ remove_chrootmirror() {
130166
fi
131167

132168
if [ -n "$MIRROR" ] && echo "$MIRROR" | grep -q 'file:' ; then
133-
echo "Removing local mirror (${MIRROR}) from sources.list."
134-
TMP_MIRROR="${MIRROR//\//\\\/}"
135-
sed -i "/deb $TMP_MIRROR $RELEASE $COMPONENTS/ D" /etc/apt/sources.list
136-
echo "Adding fallback mirror entry (${FALLBACK_MIRROR}) to sources.list instead."
137-
echo "deb $FALLBACK_MIRROR $RELEASE $COMPONENTS" >> /etc/apt/sources.list
169+
echo "Removing local.sources."
170+
rm /etc/apt/sources.list.d/local.sources
171+
echo "Adding fallback mirror entry (${FALLBACK_MIRROR}) to sources.list.d/debian.sources instead."
172+
writesource '/etc/apt/sources.list.d/debian.sources' 'deb' "$FALLBACK_MIRROR" "$RELEASE" "$COMPONENTS" '/usr/share/keyrings/debian-archive-keyring.gpg'
138173
fi
139174
}
140175
# }}}
@@ -146,19 +181,15 @@ grmlrepos() {
146181
fi
147182

148183
# user might have provided their own apt sources configuration
149-
if [ -r /etc/apt/sources.list.d/grml.list ] ; then
150-
echo "File /etc/apt/sources.list.d/grml.list exists already, not modifying."
184+
if [ -r /etc/apt/sources.list.d/grml.sources ] ; then
185+
echo "File /etc/apt/sources.list.d/grml.sources exists already, not modifying."
151186
else
152-
echo "Setting up /etc/apt/sources.list.d/grml.list."
153-
cat > /etc/apt/sources.list.d/grml.list << EOF
154-
# grml: stable repository:
155-
deb [signed-by=/usr/share/keyrings/grml-archive-keyring.gpg] http://deb.grml.org/ grml-stable main
156-
deb-src [signed-by=/usr/share/keyrings/grml-archive-keyring.gpg] http://deb.grml.org/ grml-stable main
157-
158-
# grml: testing/development repository:
159-
deb [signed-by=/usr/share/keyrings/grml-archive-keyring.gpg] http://deb.grml.org/ grml-testing main
160-
deb-src [signed-by=/usr/share/keyrings/grml-archive-keyring.gpg] http://deb.grml.org/ grml-testing main
161-
EOF
187+
echo "Setting up /etc/apt/sources.list.d/grml.sources."
188+
echo '# grml: stable repository:' >> /etc/apt/sources.list.d/grml.sources
189+
writesource '/etc/apt/sources.list.d/grml.sources' 'deb deb-src' 'https://deb.grml.org' 'grml-stable' 'main' '/usr/share/keyrings/grml-archive-keyring.gpg'
190+
echo '' >> /etc/apt/sources.list.d/grml.sources
191+
echo '# grml: testing/development repository:' >> /etc/apt/sources.list.d/grml.sources
192+
writesource '/etc/apt/sources.list.d/grml.sources' 'deb deb-src' 'https://deb.grml.org' 'grml-testing' 'main' '/usr/share/keyrings/grml-archive-keyring.gpg'
162193
fi
163194

164195
# make sure we install packages from Grml's pool only if not available from Debian
@@ -188,11 +219,8 @@ EOF
188219
# feature to provide Debian backports repos {{{
189220
backportrepos() {
190221
if [ -n "$BACKPORTREPOS" ] ; then
191-
cat >> /etc/apt/sources.list.d/backports.list << EOF
192-
# debian backports: ${RELEASE}-backports repository:
193-
deb ${MIRROR} ${RELEASE}-backports main
194-
deb-src ${MIRROR} ${RELEASE}-backports main
195-
EOF
222+
echo "# debian backports: ${RELEASE}-backports repository:" >> /etc/apt/sources.list.d/backports.sources
223+
writesource '/etc/apt/sources.list.d/backports.sources' 'deb deb-src' "$MIRROR" "${RELEASE}-backports" 'main' '/usr/share/keyrings/debian-archive-keyring.gpg'
196224
fi
197225
}
198226
# }}}

config

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,19 @@
4141
# BOOT_APPEND='pci=nomsi'
4242

4343
# Set mirror where packages will be downloaded from.
44-
# Default: use /etc/debootstrap/etc/apt/sources.list if it exists, else
45-
# 'http://deb.debian.org/debian'
44+
# Default: use /etc/debootstrap/etc/apt/sources.list.d/debian.sources if it
45+
# exists, else use /etc/debootstrap/etc/apt/sources.list if it exists, else
46+
# use 'http://deb.debian.org/debian'
4647
# Usage example:
4748
# MIRROR='ftp://ftp.de.debian.org/debian'
4849

49-
# If /etc/apt/sources.list should NOT be build on the fly, this
50-
# options allows providing a separate apt sources.list file via
51-
# /etc/debootstrap/etc/apt/sources.list
50+
# If /etc/apt/sources.list.d/debian.sources should NOT be built on the fly,
51+
# this option allows providing a separate apt sources.list file via
52+
# /etc/debootstrap/etc/apt/sources.list, or providing a deb822-format sources
53+
# file via /etc/debootstrap/etc/apt/sources.list.d/debian.sources.
5254
# KEEP_SRC_LIST='yes'
5355

54-
# To enable the Grml repository via /etc/apt/sources.list.d/grml.list
56+
# To enable the Grml repository via /etc/apt/sources.list.d/grml.sources
5557
# set this variable to 'yes'.
5658
# Default: 'no'
5759
# GRMLREPOS='yes'
@@ -62,7 +64,7 @@
6264
# GRMLPACKAGES='grml-etc-core'
6365

6466
# To enable Debian's backports repository via
65-
# /etc/apt/sources.list.d/backports.list set this variable to 'yes'.
67+
# /etc/apt/sources.list.d/backports.sources set this variable to 'yes'.
6668
# Default: 'no'
6769
# BACKPORTREPOS='yes'
6870

@@ -71,7 +73,7 @@
7173
# Default: 'trixie'
7274
# RELEASE='trixie'
7375

74-
# Define components that should be used within sources.list.
76+
# Define components that should be used within sources.list.d/debian.sources.
7577
# Default: 'main'
7678
# COMPONENTS='main contrib non-free'
7779

grml-debootstrap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Configuration options:
139139
--debconf <file> Pre-seed packages using specified pre-seed db file.
140140
--grmlrepos Enable Grml's Debian repository (deb.grml.org).
141141
--backportrepos Enable Debian's backports repository (backports.debian.org).
142-
--keep_src_list Do not overwrite user provided apt sources.list.
142+
--keep_src_list Do not override user provided apt sources.
143143
--contrib Enable 'contrib' in COMPONENTS (defaults to 'main' only).
144144
--non-free Enable non-free / non-free-firmware in COMPONENTS (defaults to 'main' only).
145145
--hostname <name> Hostname of Debian system.
@@ -461,7 +461,7 @@ while :; do
461461
shift; _opt_chroot_scripts="$1"
462462
_opt_chroot_scripts_set=T
463463
;;
464-
--keep_src_list) # Do not overwrite user provided apt sources.list
464+
--keep_src_list) # Do not override user provided apt sources
465465
_opt_keep_src_list=T
466466
;;
467467
--hostname) # Hostname of Debian system

grml-debootstrap.8.adoc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Options and environment variables
4040
*--backportrepos*::
4141

4242
Enable Debian's Backports repository via the
43-
/etc/apt/sources.list.d/backports.list configuration file. This provides the
44-
option to install Debian packages from Debian's backports repository.
43+
/etc/apt/sources.list.d/backports.sources configuration file. This provides
44+
the option to install Debian packages from Debian's backports repository.
4545

4646
*--bootappend* _appendline-for-the-kernel_::
4747

@@ -113,7 +113,7 @@ Options and environment variables
113113
*--grmlrepos*::
114114

115115
Enable Grml.org's Debian repository (http://deb.grml.org/) via the
116-
/etc/apt/sources.list.d/grml.list configuration file. This provides the
116+
/etc/apt/sources.list.d/grml.sources configuration file. This provides the
117117
option to install Debian packages from Grml's repository.
118118

119119
*--grub* _device_::
@@ -135,7 +135,8 @@ Options and environment variables
135135

136136
*--keep_src_list*::
137137

138-
Do not overwrite user provided /etc/apt/sources.list.
138+
Do not override user provided /etc/apt/sources.list.d/debian.sources or
139+
delete /etc/apt/sources.list.
139140

140141
*-m*, *--mirror* _URL_::
141142

0 commit comments

Comments
 (0)