Skip to content

Commit b87ff29

Browse files
committed
chroot-script: ignore shellcheck SC2329
shellcheck apparently cannot figure out that these functions are used via `stage`.
1 parent 34c3fa9 commit b87ff29

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

chroot-script

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# shellcheck disable=SC2317 # shellcheck has trouble understanding the code flow in this file
1212

1313
# error_handler {{{
14+
# shellcheck disable=SC2329
1415
error_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
7072
askpass() {
7173
# read -s emulation for dash. result is in $resp.
7274
set -o noglob
@@ -78,6 +80,7 @@ askpass() {
7880
# }}}
7981

8082
# mark existing packages as automatically installed {{{
83+
# shellcheck disable=SC2329
8184
markauto() {
8285
# Mark most leaf packages as automatically installed.
8386
# Later in the systems life, apt autoremove will remove them if possible.
@@ -86,6 +89,7 @@ markauto() {
8689
# }}}
8790

8891
# define chroot mirror {{{
92+
# shellcheck disable=SC2329
8993
chrootmirror() {
9094
if [ "$KEEP_SRC_LIST" = "yes" ] ; then
9195
echo "KEEP_SRC_LIST has been enabled, skipping chrootmirror stage."
@@ -115,6 +119,7 @@ chrootmirror() {
115119
# }}}
116120

117121
# remove local chroot mirror {{{
122+
# shellcheck disable=SC2329
118123
remove_chrootmirror() {
119124
if [ "$KEEP_SRC_LIST" = "yes" ] ; then
120125
echo "KEEP_SRC_LIST has been enabled, skipping remove_chrootmirror stage."
@@ -132,6 +137,7 @@ remove_chrootmirror() {
132137
# }}}
133138

134139
# set up grml repository {{{
140+
# shellcheck disable=SC2329
135141
grmlrepos() {
136142
if [ -z "$GRMLREPOS" ] ; then
137143
return 0
@@ -178,6 +184,7 @@ EOF
178184
# }}}
179185

180186
# feature to provide Debian backports repos {{{
187+
# shellcheck disable=SC2329
181188
backportrepos() {
182189
if [ -n "$BACKPORTREPOS" ] ; then
183190
cat >> /etc/apt/sources.list.d/backports.list << EOF
@@ -190,6 +197,7 @@ EOF
190197
# }}}
191198

192199
# set up kernel-img.conf {{{
200+
# shellcheck disable=SC2329
193201
kernelimg_conf() {
194202
if ! [ -r /etc/kernel-img.conf ] ; then
195203
echo "Setting up /etc/kernel-img.conf"
@@ -204,6 +212,7 @@ EOF
204212
# }}}
205213

206214
# make sure services do not start up {{{
215+
# shellcheck disable=SC2329
207216
install_policy_rcd() {
208217
if ! [ -r /usr/sbin/policy-rc.d ] ; then
209218
export POLICYRCD=1
@@ -218,6 +227,7 @@ EOF
218227
# }}}
219228

220229
# make sure we have an up2date system {{{
230+
# shellcheck disable=SC2329
221231
upgrade_system() {
222232
if [ "$UPGRADE_SYSTEM" = "yes" ] ; then
223233
echo "Running update + upgrade"
@@ -229,7 +239,9 @@ upgrade_system() {
229239
}
230240

231241
# }}}
242+
232243
# remove now useless apt cache {{{
244+
# shellcheck disable=SC2329
233245
remove_apt_cache() {
234246
if [ "$RM_APTCACHE" = 'yes' ] ; then
235247
echo "Cleaning apt cache."
@@ -242,6 +254,7 @@ remove_apt_cache() {
242254
# }}}
243255

244256
# install additional packages {{{
257+
# shellcheck disable=SC2329
245258
packages() {
246259
# Pre-seed the debconf database with answers. Each question will be marked
247260
# as seen to prevent debconf from asking the question interactively.
@@ -267,6 +280,7 @@ packages() {
267280
# }}}
268281

269282
# install extra packages {{{
283+
# shellcheck disable=SC2329
270284
extrapackages() {
271285
if [ "$EXTRAPACKAGES" = 'yes' ] ; then
272286
PACKAGELIST=$(find /etc/debootstrap/extrapackages -type f -name '*.deb')
@@ -281,14 +295,15 @@ extrapackages() {
281295
# }}}
282296

283297
# check if the specified Debian package exists
298+
# shellcheck disable=SC2329
284299
package_exists() {
285300
output=$(apt-cache show "$1" 2>/dev/null)
286301
[ -n "$output" ]
287302
return $?
288303
}
289304

290-
291305
# determine the kernel version postfix
306+
# shellcheck disable=SC2329
292307
get_kernel_version() {
293308
# do not override $KERNEL if set via config file
294309
if [ -n "$KERNEL" ] ; then
@@ -310,6 +325,7 @@ get_kernel_version() {
310325
}
311326

312327
# install kernel packages {{{
328+
# shellcheck disable=SC2329
313329
kernel() {
314330
if [ -n "$NOKERNEL" ] ; then
315331
echo "Skipping installation of kernel packages as requested via --nokernel"
@@ -333,6 +349,7 @@ kernel() {
333349
# }}}
334350

335351
# reconfigure packages {{{
352+
# shellcheck disable=SC2329
336353
reconfigure() {
337354
if [ -n "$RECONFIGURE" ] ; then
338355
for package in $RECONFIGURE ; do
@@ -346,6 +363,7 @@ reconfigure() {
346363
# }}}
347364

348365
# set password of user root {{{
366+
# shellcheck disable=SC2329
349367
passwords()
350368
{
351369
if [ -n "$NOPASSWORD" ] ; then
@@ -393,6 +411,7 @@ passwords()
393411
# }}}
394412

395413
# set up /etc/hosts {{{
414+
# shellcheck disable=SC2329
396415
hosts() {
397416
if ! [ -f /etc/hosts ] ; then
398417
cat > /etc/hosts << EOF
@@ -406,6 +425,7 @@ EOF
406425
# }}}
407426

408427
# set default locales {{{
428+
# shellcheck disable=SC2329
409429
default_locales() {
410430
if [ -n "$DEFAULT_LOCALES" ] ; then
411431
if ! [ -x /usr/sbin/update-locale ] ; then
@@ -420,6 +440,7 @@ default_locales() {
420440
# }}}
421441

422442
# adjust timezone {{{
443+
# shellcheck disable=SC2329
423444
timezone() {
424445
if [ -n "$TIMEZONE" ] ; then
425446
echo "Adjusting /etc/localtime"
@@ -436,6 +457,7 @@ timezone() {
436457
# }}}
437458

438459
# helper function for fstab() {{{
460+
# shellcheck disable=SC2329
439461
createfstab(){
440462
echo "Setting up /etc/fstab"
441463
cat > /etc/fstab <<EOF
@@ -487,6 +509,7 @@ EOF
487509
# }}}
488510

489511
# generate /etc/fstab {{{
512+
# shellcheck disable=SC2329
490513
fstab() {
491514
# set up /etc/fstab if file is UNCONFIGURED (debootstrap, mmdebstrap)
492515
if grep -q UNCONFIGURED /etc/fstab ; then
@@ -496,6 +519,7 @@ fstab() {
496519
# }}}
497520

498521
# ensure we have according filesystem tools available {{{
522+
# shellcheck disable=SC2329
499523
install_fs_tools() {
500524
local pkg=""
501525

@@ -518,6 +542,7 @@ install_fs_tools() {
518542
# }}}
519543

520544
# set up hostname {{{
545+
# shellcheck disable=SC2329
521546
hostname() {
522547
if [ -n "$HOSTNAME" ] ; then
523548
echo "Setting hostname to ${HOSTNAME}."
@@ -552,6 +577,7 @@ hostname() {
552577
# }}}
553578

554579
# generate initrd/initramfs {{{
580+
# shellcheck disable=SC2329
555581
initrd() {
556582
# assume the first available kernel as our main kernel
557583
# shellcheck disable=SC2012
@@ -577,6 +603,7 @@ initrd() {
577603
}
578604
# }}}
579605

606+
# shellcheck disable=SC2329
580607
efi_setup() {
581608
if [ -z "$EFI" ] ; then
582609
return 0
@@ -606,6 +633,7 @@ efi_setup() {
606633

607634
# helper function to get relevant /dev/disk/by-id/* entries,
608635
# based on GRUB's postinst script
636+
# shellcheck disable=SC2329
609637
available_ids() {
610638
local path ids
611639

@@ -621,6 +649,7 @@ available_ids() {
621649

622650
# helper function to report corresponding /dev/disk/by-id/ for a given device name,
623651
# based on GRUB's postinst script
652+
# shellcheck disable=SC2329
624653
device_to_id() {
625654
local id
626655

@@ -641,6 +670,7 @@ device_to_id() {
641670
return 1
642671
}
643672

673+
# shellcheck disable=SC2329
644674
is_grub_bios_compatible() {
645675
# Check if the disk uses an MSDOS partition table, these are always compatible
646676
if [[ "$(blkid "$GRUB")" =~ 'PTTYPE="dos"' ]]; then
@@ -664,6 +694,7 @@ is_grub_bios_compatible() {
664694
return 1
665695
}
666696

697+
# shellcheck disable=SC2329
667698
run_grub_install() {
668699
grub_install_cmd=( 'grub-install' "$@" )
669700
if ! "${grub_install_cmd[@]}" ; then
@@ -672,6 +703,7 @@ run_grub_install() {
672703
fi
673704
}
674705

706+
# shellcheck disable=SC2329
675707
grub_install() {
676708
if [ -z "$GRUB" ] ; then
677709
echo "Notice: \$GRUB not defined, will not install grub inside chroot at this stage."
@@ -780,6 +812,7 @@ grub_install() {
780812
# }}}
781813

782814
# execute all scripts present in /etc/debootstrap/chroot-scripts/ {{{
815+
# shellcheck disable=SC2329
783816
custom_scripts() {
784817
[ -d /etc/debootstrap/chroot-scripts/ ] || return 0
785818

@@ -791,6 +824,7 @@ custom_scripts() {
791824
# }}}
792825

793826
# make sure we don't have any running processes left {{{
827+
# shellcheck disable=SC2329
794828
services() {
795829
for service in ssh mdadm mdadm-raid ; do
796830
if [ -x /etc/init.d/"$service" ] ; then
@@ -801,6 +835,7 @@ services() {
801835
# }}}
802836

803837
# unmount /proc and make sure nothing is left {{{
838+
# shellcheck disable=SC2329
804839
finalize() {
805840
# make sure we don't leave any sensible data
806841
rm -f /etc/debootstrap/variables
@@ -815,6 +850,7 @@ finalize() {
815850
# }}}
816851

817852
# signal handler {{{
853+
# shellcheck disable=SC2329
818854
signal_handler() {
819855
finalize
820856
[ -n "$1" ] && EXIT="$1" || EXIT="1"

0 commit comments

Comments
 (0)