@@ -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 {{{
96124chrootmirror () {
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
188219# feature to provide Debian backports repos {{{
189220backportrepos () {
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# }}}
0 commit comments