1111# shellcheck disable=SC2317 # shellcheck has trouble understanding the code flow in this file
1212
1313# error_handler {{{
14+ # shellcheck disable=SC2329
1415error_handler () {
1516 last_exit_code=" $? "
1617 last_bash_command=" $BASH_COMMAND "
@@ -67,6 +68,7 @@ stage() {
6768 return 0
6869}
6970
71+ # shellcheck disable=SC2329
7072askpass () {
7173 # read -s emulation for dash. result is in $resp.
7274 set -o noglob
@@ -78,21 +80,16 @@ askpass() {
7880# }}}
7981
8082# mark existing packages as automatically installed {{{
83+ # shellcheck disable=SC2329
8184markauto () {
82- case " $RELEASE " in
83- bullseye)
84- # apt-mark is unavailable or does not support all used patterns.
85- return
86- ;;
87- esac
88-
8985 # Mark most leaf packages as automatically installed.
9086 # Later in the systems life, apt autoremove will remove them if possible.
9187 apt-mark auto ' ~i !~M ?not(?priority(required)) ?not(?priority(important)) ?not(?priority(standard))'
9288}
9389# }}}
9490
9591# define chroot mirror {{{
92+ # shellcheck disable=SC2329
9693chrootmirror () {
9794 if [ " $KEEP_SRC_LIST " = " yes" ] ; then
9895 echo " KEEP_SRC_LIST has been enabled, skipping chrootmirror stage."
@@ -113,7 +110,6 @@ chrootmirror() {
113110 case " $RELEASE " in
114111 unstable|sid) ;; # no security pool available
115112 * )
116- # bullseye and newer releases use a different repository layout, see
117113 # https://lists.debian.org/debian-devel-announce/2019/07/msg00004.html
118114 echo " Adding security.debian.org/debian-security to sources.list."
119115 echo " deb http://security.debian.org/debian-security ${RELEASE} -security $COMPONENTS " >> /etc/apt/sources.list
@@ -123,6 +119,7 @@ chrootmirror() {
123119# }}}
124120
125121# remove local chroot mirror {{{
122+ # shellcheck disable=SC2329
126123remove_chrootmirror () {
127124 if [ " $KEEP_SRC_LIST " = " yes" ] ; then
128125 echo " KEEP_SRC_LIST has been enabled, skipping remove_chrootmirror stage."
@@ -140,6 +137,7 @@ remove_chrootmirror() {
140137# }}}
141138
142139# set up grml repository {{{
140+ # shellcheck disable=SC2329
143141grmlrepos () {
144142 if [ -z " $GRMLREPOS " ] ; then
145143 return 0
186184# }}}
187185
188186# feature to provide Debian backports repos {{{
187+ # shellcheck disable=SC2329
189188backportrepos () {
190189 if [ -n " $BACKPORTREPOS " ] ; then
191190 cat >> /etc/apt/sources.list.d/backports.list << EOF
198197# }}}
199198
200199# set up kernel-img.conf {{{
200+ # shellcheck disable=SC2329
201201kernelimg_conf () {
202202 if ! [ -r /etc/kernel-img.conf ] ; then
203203 echo " Setting up /etc/kernel-img.conf"
212212# }}}
213213
214214# make sure services do not start up {{{
215+ # shellcheck disable=SC2329
215216install_policy_rcd () {
216217 if ! [ -r /usr/sbin/policy-rc.d ] ; then
217218 export POLICYRCD=1
226227# }}}
227228
228229# make sure we have an up2date system {{{
230+ # shellcheck disable=SC2329
229231upgrade_system () {
230232 if [ " $UPGRADE_SYSTEM " = " yes" ] ; then
231233 echo " Running update + upgrade"
@@ -237,7 +239,9 @@ upgrade_system() {
237239}
238240
239241# }}}
242+
240243# remove now useless apt cache {{{
244+ # shellcheck disable=SC2329
241245remove_apt_cache () {
242246 if [ " $RM_APTCACHE " = ' yes' ] ; then
243247 echo " Cleaning apt cache."
@@ -250,6 +254,7 @@ remove_apt_cache() {
250254# }}}
251255
252256# install additional packages {{{
257+ # shellcheck disable=SC2329
253258packages () {
254259 # Pre-seed the debconf database with answers. Each question will be marked
255260 # as seen to prevent debconf from asking the question interactively.
@@ -275,6 +280,7 @@ packages() {
275280# }}}
276281
277282# install extra packages {{{
283+ # shellcheck disable=SC2329
278284extrapackages () {
279285 if [ " $EXTRAPACKAGES " = ' yes' ] ; then
280286 PACKAGELIST=$( find /etc/debootstrap/extrapackages -type f -name ' *.deb' )
@@ -289,14 +295,15 @@ extrapackages() {
289295# }}}
290296
291297# check if the specified Debian package exists
298+ # shellcheck disable=SC2329
292299package_exists () {
293300 output=$( apt-cache show " $1 " 2> /dev/null)
294301 [ -n " $output " ]
295302 return $?
296303}
297304
298-
299305# determine the kernel version postfix
306+ # shellcheck disable=SC2329
300307get_kernel_version () {
301308 # do not override $KERNEL if set via config file
302309 if [ -n " $KERNEL " ] ; then
@@ -318,6 +325,7 @@ get_kernel_version() {
318325}
319326
320327# install kernel packages {{{
328+ # shellcheck disable=SC2329
321329kernel () {
322330 if [ -n " $NOKERNEL " ] ; then
323331 echo " Skipping installation of kernel packages as requested via --nokernel"
@@ -341,6 +349,7 @@ kernel() {
341349# }}}
342350
343351# reconfigure packages {{{
352+ # shellcheck disable=SC2329
344353reconfigure () {
345354 if [ -n " $RECONFIGURE " ] ; then
346355 for package in $RECONFIGURE ; do
@@ -354,6 +363,7 @@ reconfigure() {
354363# }}}
355364
356365# set password of user root {{{
366+ # shellcheck disable=SC2329
357367passwords ()
358368{
359369 if [ -n " $NOPASSWORD " ] ; then
@@ -401,6 +411,7 @@ passwords()
401411# }}}
402412
403413# set up /etc/hosts {{{
414+ # shellcheck disable=SC2329
404415hosts () {
405416 if ! [ -f /etc/hosts ] ; then
406417 cat > /etc/hosts << EOF
414425# }}}
415426
416427# set default locales {{{
428+ # shellcheck disable=SC2329
417429default_locales () {
418430 if [ -n " $DEFAULT_LOCALES " ] ; then
419431 if ! [ -x /usr/sbin/update-locale ] ; then
@@ -428,6 +440,7 @@ default_locales() {
428440# }}}
429441
430442# adjust timezone {{{
443+ # shellcheck disable=SC2329
431444timezone () {
432445 if [ -n " $TIMEZONE " ] ; then
433446 echo " Adjusting /etc/localtime"
@@ -444,6 +457,7 @@ timezone() {
444457# }}}
445458
446459# helper function for fstab() {{{
460+ # shellcheck disable=SC2329
447461createfstab (){
448462 echo " Setting up /etc/fstab"
449463 cat > /etc/fstab << EOF
495509# }}}
496510
497511# generate /etc/fstab {{{
512+ # shellcheck disable=SC2329
498513fstab () {
499514 # set up /etc/fstab if file is UNCONFIGURED (debootstrap, mmdebstrap)
500515 if grep -q UNCONFIGURED /etc/fstab ; then
@@ -504,6 +519,7 @@ fstab() {
504519# }}}
505520
506521# ensure we have according filesystem tools available {{{
522+ # shellcheck disable=SC2329
507523install_fs_tools () {
508524 local pkg=" "
509525
@@ -526,6 +542,7 @@ install_fs_tools() {
526542# }}}
527543
528544# set up hostname {{{
545+ # shellcheck disable=SC2329
529546hostname () {
530547 if [ -n " $HOSTNAME " ] ; then
531548 echo " Setting hostname to ${HOSTNAME} ."
@@ -560,6 +577,7 @@ hostname() {
560577# }}}
561578
562579# generate initrd/initramfs {{{
580+ # shellcheck disable=SC2329
563581initrd () {
564582 # assume the first available kernel as our main kernel
565583 # shellcheck disable=SC2012
@@ -585,6 +603,7 @@ initrd() {
585603}
586604# }}}
587605
606+ # shellcheck disable=SC2329
588607efi_setup () {
589608 if [ -z " $EFI " ] ; then
590609 return 0
@@ -614,6 +633,7 @@ efi_setup() {
614633
615634# helper function to get relevant /dev/disk/by-id/* entries,
616635# based on GRUB's postinst script
636+ # shellcheck disable=SC2329
617637available_ids () {
618638 local path ids
619639
@@ -629,6 +649,7 @@ available_ids() {
629649
630650# helper function to report corresponding /dev/disk/by-id/ for a given device name,
631651# based on GRUB's postinst script
652+ # shellcheck disable=SC2329
632653device_to_id () {
633654 local id
634655
@@ -649,6 +670,7 @@ device_to_id() {
649670 return 1
650671}
651672
673+ # shellcheck disable=SC2329
652674is_grub_bios_compatible () {
653675 # Check if the disk uses an MSDOS partition table, these are always compatible
654676 if [[ " $( blkid " $GRUB " ) " =~ ' PTTYPE="dos"' ]]; then
@@ -672,6 +694,7 @@ is_grub_bios_compatible() {
672694 return 1
673695}
674696
697+ # shellcheck disable=SC2329
675698run_grub_install () {
676699 grub_install_cmd=( ' grub-install' " $@ " )
677700 if ! " ${grub_install_cmd[@]} " ; then
@@ -680,6 +703,7 @@ run_grub_install() {
680703 fi
681704}
682705
706+ # shellcheck disable=SC2329
683707grub_install () {
684708 if [ -z " $GRUB " ] ; then
685709 echo " Notice: \$ GRUB not defined, will not install grub inside chroot at this stage."
@@ -788,6 +812,7 @@ grub_install() {
788812# }}}
789813
790814# execute all scripts present in /etc/debootstrap/chroot-scripts/ {{{
815+ # shellcheck disable=SC2329
791816custom_scripts () {
792817 [ -d /etc/debootstrap/chroot-scripts/ ] || return 0
793818
@@ -799,6 +824,7 @@ custom_scripts() {
799824# }}}
800825
801826# make sure we don't have any running processes left {{{
827+ # shellcheck disable=SC2329
802828services () {
803829 for service in ssh mdadm mdadm-raid ; do
804830 if [ -x /etc/init.d/" $service " ] ; then
@@ -809,6 +835,7 @@ services() {
809835# }}}
810836
811837# unmount /proc and make sure nothing is left {{{
838+ # shellcheck disable=SC2329
812839finalize () {
813840 # make sure we don't leave any sensible data
814841 rm -f /etc/debootstrap/variables
@@ -823,6 +850,7 @@ finalize() {
823850# }}}
824851
825852# signal handler {{{
853+ # shellcheck disable=SC2329
826854signal_handler () {
827855 finalize
828856 [ -n " $1 " ] && EXIT=" $1 " || EXIT=" 1"
0 commit comments