This file is indexed.

/usr/share/bootcd/bootcd-check.lib is in bootcd 4.04.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# bootcd-check.lib
# vim: set filetype=sh :

warn_user()
{
  A=""
  while [ "$A" != "y" -a "$A" != "n" ]
  do
    [ "$CLEAN_VAR" = "yes" ] &&
    echo "  /var/cache/apt will be cleaned (apt-get clean) !" | tee -a $ERRLOG
  
    echo ""
    if [ ! "$SCRIPT" ]; then
      echo -n "Ok to continue? (y/n) " | tee -a $ERRLOG
      read A; echo "$A" >> $ERRLOG
      # Next line handles EOF from a pipe as "n"
      [ $? -ne 0 ] && A="n"
    else
      A="y"
    fi
  done
  if [ "$A" = "n" ]; then
    exit 1
  fi
  echo ""
}

check_config()
{
  echo "--- CONFVARS from Config ---" >>$ERRLOG
  for i in $CONFVARS; do
    eval "echo $i \$$i"
  done | sort >>$ERRLOG

  PROBLEM="The image destination $VAR/cdimage.iso exists.
Delete $VAR/cdimage.iso and try again!"
  if [ -e $VAR/cdimage.iso ] ; then
    err "$PROBLEM"
  fi

  SRCDISK=$(realpath $SRCDISK)
  [ $? -ne 0 ] && err "Wrong Definition of SRCDISK: See $ERRLOG"
  SRCDI=$SRCDISK; [ "$SRCDI" = "/" ] && SRCDI=""
  CONFVARS="$CONFVARS SRCDI"

  nn=""
  for j in $NOT_TO_CD; do
    aa=$(realpath -s $j) 
    if [ $? -ne 0 ];then  
      warn "Wrong Definition of NOT_TO_CD (\"$j\"): See $ERRLOG"
    else
      [ "$nn" ] && nn="$nn $aa" || nn=$aa
    fi
  done
  NOT_TO_CD=$nn

  KERNEL=$(realpath $KERNEL)
  [ $? -ne 0 ] && err "Wrong Definition of KERNEL: See $ERRLOG"
  [ ! -f "$KERNEL" ] && err "No Kernel <$KERNEL>"

  KCONF=$(echo $KERNEL | sed "s/vmlinu./config/")
  [ "$KCONF" = "$KERNEL" -o ! -f "$KCONF" ] && KCONF=""

  REL_KERNEL=$(echo "$KERNEL" | sed "s|^$SRCDI||")
  CONFVARS="$CONFVARS REL_KERNEL"
  
  if [ "$INITRD" != "" ]; then
    INITRD=$(realpath $INITRD)
    if [ $? -ne 0 -o ! -f "$INITRD" ]; then
      warn "No file \"$INITRD\" INITRD will be set to \"\""
      INITRD=""
    fi
  fi

  REL_INITRD=$(echo "$INITRD" | sed "s|^$SRCDI||")
  CONFVARS="$CONFVARS REL_INITRD"

  [ "$DISPLAY" ] && [ ! -f $DISPLAY ] && warn "DISPLAY ($DISPLAY) not found."

  if [ "$BOOTCDMODPROBE" != "standard" -a "$BOOTCDMODPROBE" != "bootcd" -a "$BOOTCDMODPROBE" != "auto" ]
  then
    warn 'BOOTCDMODPROBE is not defined as "standard", "bootcd" or "auto".' \
         'It will be treated as "auto".'
    BOOTCDMODPROBE="auto"
  fi

  if [ "$BOOTCDMODPROBE" = "auto" ]; then
    if [ -f /sbin/discover -o -f /bin/discover -o -f /usr/bin/discover ]; then
      BOOTCDMODPROBE="bootcd"
    else
      BOOTCDMODPROBE="standard"
    fi
  elif [ "$BOOTCDMODPROBE" = "bootcd" ]; then
    if [ ! -f /sbin/discover -a ! -f /bin/discover -a ! -f /usr/bin/discover ]; then
      warn "BOOTCDMODPROBE=bootcd is defined, but discover is not installed."
    fi
  fi

  CDDEV1=$(echo $CDDEV | awk '{print $1}')
  CDDEVR=$(echo $CDDEV | awk '{$1=""; print}')
  CONFVARS="$CONFVARS CDDEV1 CDDEVR"

  if [ "$DO_CHECK" != "no" -a "$DO_CHECK" != "yes" ]; then
    DO_CHECK=yes
    warn 'DO_CHECK is not defined as "yes" or "no".' \
         'It will be treated as "yes".'
  fi

  [ "$DO_CHECK" = "yes" ] &&
    echo "--- Checking for possible Problems ---" | tee -a $ERRLOG

  if [ "$TYP" != "CD" -a "$TYP" != "DVD" ]; then
    err "TYP must be defined as \"CD\" or \"DVD\" (not \"$TYP\")."
  fi

  CHANGES=$VAR/changes
  CONFVARS="$CONFVARS CHANGES"

  VERSION=$(COLUMNS=200 dpkg -l bootcd | tail -1 | awk '{print $3}')
  CONFVARS="$CONFVARS VERSION"

  echo "--- CONFVARS checked by check_config ---" >>$ERRLOG
  for i in $CONFVARS; do
    eval "echo $i \$$i"
  done | sort >>$ERRLOG
}

get_sizes()
{
  [ "$DO_CHECK" = "no" ] && return

  S_NOT_TO_CD=0 
  [ "$NOT_TO_CD" ] && S_NOT_TO_CD=$(du_dir $NOT_TO_CD $ERRLOG $SRCDI/tmp)
  echo "S_NOT_TO_CD=<$S_NOT_TO_CD>" >> $ERRLOG

  S_CD_ALL=$(du_dir $SRCDISK $NOT_TO_CD $ERRLOG $SRCDI/tmp)
  echo "S_CD_ALL=<$S_CD_ALL>" >> $ERRLOG

  S_NEED_CD=$(expr $S_CD_ALL - $S_NOT_TO_CD)
  S_VAR=$(df_file $VAR)
  echo "S_VAR=<$S_VAR>" >> $ERRLOG

  S_NEED_COMPRESS=$(expr $S_NEED_CD \* 2)
  echo "S_NEED_COMPRESS=<$S_NEED_COMPRESS>" >> $ERRLOG

  if [ "$TYP" = "DVD" ]; then
    S_CD="4700000"
  else
    S_CD=$(expr 1024 \* 650)
  fi
  echo "S_CD=<$S_CD>" >> $ERRLOG
}

check_file_rc()
{

  PROBLEM="
you have installed the debian package file-rc on the system you want to
copy on cd. The file-rc package provides an alternative mechanism to boot the 
system, to shut it down and to change runlevels. The /etc/rc?.d/* links 
will be converted into one single configuration file /etc/runlevel.conf...
     
Therefore scripts in /etc/rcS.d added by bootcdwrite are not executed during
booting from CD.

To slolve the problem, please deinstall file-rc on the system you want to 
copy on cd."
  F="$SRCDI/var/lib/dpkg/info/file-rc.list"
  [ -f $F ] && warn "Found $F. This means $PROBLEM"
}

check_compress()
{
  PROBLEM="
to create a compressed filesystem we need the command mkzftree.
this command is included in the debian package mkisofs since
Version 4:2.0-2 or in package genisoimage."
  if [ ! -f /usr/bin/mkzftree ]; then
    warn "command mkzftree not found.$PROBLEM"
  fi


  PROBLEM="
To enable compression there must be much space (S_VAR)
available in $VAR to hold extra space for compression.
We need double as much space (S_NEED_COMPRESS) as will be copied to CD.
but the space available is not enough"
  if [ "$DO_CHECK" = "yes" ]; then
    if [ "$S_VAR" = "" ]; then
      warn "Couldn't guess size of \"$VAR\" with df so assume enought space is available! (Press \"i\")"
    elif [ $S_NEED_COMPRESS -gt $S_VAR ]; then
      warn "S_NEED_COMPRESS > S_VAR ($S_NEED_COMPRESS ) $S_VAR) $PROBLEM"
    fi
  fi

  PROBLEM="
To enable compression some options have to be compiled in the
kernel. Only with the necessary options the kernel is able to boot from the
compressed CD/DVD."
  if [ "$KCONF" ]; then
    for i in \
      "CONFIG_ZISOFS=$([ "$INITRD" ] && echo "[m|y]" || echo y)" \
      "CONFIG_ZISOFS_FS=$([ "$INITRD" ] && echo "[m|y]" || echo y)"
    do
      # Only if Option is available (with or without #) do anything
      grep -q "$i" $KCONF
      if [ $? = 0 ]; then
        # Now that we know the Option is available, check if configured
        grep -q "^$i" $KCONF
        if [ $? != 0 ]; then
          warn "$i seems not to be configured in $KERNEL$PROBLEM"
        fi
      fi
    done
  fi
}

check_cdfiles()
{
  [ "$DO_CHECK" = "no" ] && return

  PROBLEM="
This file or directory will be created in the next step by bootcdwrite. 
Please remove the actual file. You are probably trying to use bootcdwrite
on a system created with bootcd2disk."
  for i in cdboot.img cdboot.catalog usr/bin/bootcd2disk \
    usr/bin/bootcdflopcp usr/bin/bootcdflopcp \
    etc/bootcd/bootcd2disk.conf rr_moved ram1.cpio.gz ram2.cpio.gz \
    isolinux
  do
    [ -e $SRCDI/$i ] && warn "found $SRCDI/$i$PROBLEM"
  done
}

# check_kernel - Try to make some kernel checks
check_kernel()
{
  [ "$DO_CHECK" = "no" ] && return

  PROBLEM="
If you install a kernel from a .deb package the kernel will be named
/boot/vmlinuz<version> and there will be a kernel config file named
/boot/config<version>. Bootcdwrite could not find the config file and 
therefore no further kernel checks could be done. This is not critical 
but you could build your kernel with make-kpkg to solve the problem.
Please read the FAQ to check if you have build erverything necessary in
your kernel."

  if [ ! "$KCONF" ]; then
    warn "Could not calculate Kernelconfig to make further checks.$PROBLEM"
    return
  fi

  PROBLEM="
To run bootcd some features have to be compiled in the kernel.
Please read the FAQ and check if all necessary features are enabled."
  for i in \
    "CONFIG_AUFS_FS=[m|y]" \
    "CONFIG_BLK_DEV_RAM=[m|y]" \
    "CONFIG_BLK_DEV_LOOP=[m|y]" \
    "CONFIG_TMPFS=[m|y]"
  do
    grep -q "^$i" $KCONF
    [ $? != 0 ] && warn "$i seems not to be configured in $KERNEL$PROBLEM"
  done

  if [ "$BOOTFLOPPY" = "yes" ]; then
    PROBLEM="
You have configured BOOTFLOPPY=yes.
To boot from floppy with syslinux you need some additional features
compiled in the kernel. Please read the FAQ and check if all necessary
features are enabled."

    for i in \
      "CONFIG_FAT_FS=y" \
      "CONFIG_MSDOS_FS=y" \
      "CONFIG_VFAT_FS=y"
    do
      grep -q "^$i" $KCONF
      [ $? != 0 ] && warn "$i seems not to be configured in $KERNEL$PROBLEM"
    done
  fi

#  PROBLEM="
#The KERNEL has to be in SRCDISK subdir. Please edit bootcdwrite.conf."
#  [ "$(echo "$KERNEL" | grep "^$SRCDI/")" ] || 
#    warn "$KERNEL is not in $SRCDI/ subdir.$PROBLEM"
#
#  A=$(chnglist -no_mnt -rel "$SRCDISK" "$KERNEL")
#  B="$SRCDI/vmlinuz"
#  PROBLEM="
#There should be a symbolic link 
#$B -> /$A.  
#Bootcd2disk can later use this link to automatically install 
#the kernel to the new disk. Please create the link with
#\"ln -sf /$A $B\"."
#  [ "$(/bin/ls -l $B 2>&1 | grep -e "-> /\?$A$")" ] || warn "$PROBLEM"

  if [ "$INITRD" = "" ]; then
    PROBLEM="
To run bootcd (without INITRD) some features have to be compiled in the 
kernel. Please read the FAQ and check if all necessary features are enabled."
    for i in \
      "CONFIG_ISO9660_FS=y" \
      "CONFIG_EXT2_FS=y" \
      "CONFIG_BLK_DEV_LOOP=[m|y]"
    do
      grep -q "^$i" $KCONF
      [ $? != 0 ] && warn "$i seems not to be configured in $KERNEL$PROBLEM"
    done
  else
    PROBLEM="
You have configured INITRD=\"$INITRD\".
The kernel has to be configured for this to work."

    for i in \
      "CONFIG_ISO9660_FS=[m|y]" \
      "CONFIG_EXT2_FS=[m|y]" \
      "CONFIG_BLK_DEV_INITRD=y"
    do
      grep -q "^$i" $KCONF
      [ $? != 0 ] && warn "$i seems not to be configured in $KERNEL$PROBLEM"
    done
  fi

}

check_initrd()
{
  [ "$DO_CHECK" = "no" ] && return

  [ ! "$INITRD" ] && return

  PROBLEM="
The initrd file is no compressed ROM File System and it is 
no compressed cpio archive.
It can not be checked by bootcdwrite"
  if [ "$(file $INITRD | grep "Compressed ROM File System")" ]; then

    PROBLEM="
You have to make sure, that the module \"isofs.o\" is loaded from
the initrd system. Please read the FAQ or install bootcd-mkinitramfs."
    run mkdir -p $VAR/mnt
    run mount -o loop $INITRD $VAR/mnt -t cramfs
    if ! grep -q "modprobe.*\<isofs\>" $VAR/mnt/loadmodules; then
      warn "$PROBLEM"
    fi
    run umount $VAR/mnt
    losetup -d /dev/loop0 2>/dev/null

  elif [ "$(zcat $INITRD | file - | grep "cpio archive")" ]; then

    PROBLEM="
You are using a compressed cpio file for initrd. You have to 
make sure, that all modules needed to boot from cd are in this
file. At least the isofs-module is missing.

If this initrd was built by yaird, you also have to make sure that the
init script within the initrd will try to boot from cd.

Another option is to use initrd_tools instead of yaird. Then the 
neccessary modifications can be automatically done with intalling 
bootcd-mkinitramfs.
"
    if [ ! "$(zcat $INITRD | cpio -it | grep "/modules/.*isofs.k*o")" -a \
         ! "$(grep -q "^CONFIG_ISO9660_FS=y" $KCONF)" ]; then
      warn "$PROBLEM"
    fi

    PROBLEM="
The initrd $INITRD does not contain modifications
from bootcd-mkinitramfs.
Please run \"update-initramfs -u -k $(echo "$INITRD" | sed "s/^[^-]*-//")\" again.
"
    if [ ! "$(zcat $INITRD | cpio -it | grep "runbootcdproberoot")" ]; then
      warn "$PROBLEM"
    fi

  else
    warn "$PROBLEM"
  fi

#  PROBLEM="
#The INITRD has to be in SRCDISK subdir. Please edit bootcdwrite.conf."
#  [ "$(echo "$INITRD" | grep "^$SRCDI/")" ] || 
#    warn "$INITRD is not in $SRCDI/ subdir.$PROBLEM"
#
#  A=$(chnglist -no_mnt -rel "$SRCDISK" "$INITRD")
#  B="$SRCDI/initrd.img"
#  PROBLEM="
#There should be a symbolic link
#$B -> /$A.  
#Bootcd2disk can later use this link to automatically install the initrd 
#image to the new disk. Please create the link with
#\"ln -sf /$A $B\"."
#    [ "$(/bin/ls -l $B 2>&1 | grep -e "-> /\?$A$")" ] || warn "$PROBLEM"
}

check_sizes()
{
  [ "$DO_CHECK" = "no" ] && return

  echo "--- Sizes in KByte (du -klsc ) ---" | tee -a $ERRLOG

  echo -n "NOT_TO_CD =  . . . . . . . . . . . . . . . . . . " | tee -a $ERRLOG
  echo ". . . . . . . . . $S_NOT_TO_CD" | tee -a $ERRLOG
  echo -n "CD_ALL (SRCDISK v NOT_TO_CD) = . . . . . . . . . " | tee -a $ERRLOG
  echo ". . . . . . . . . $S_CD_ALL" | tee -a $ERRLOG
  echo -n "Needed = CD_ALL - NOT_TO_CD  . . . . . . . . . . " | tee -a $ERRLOG
  echo ". . . . . . . . . $S_NEED_CD" | tee -a $ERRLOG

  if [ "$TYP" = "DVD" ]; then
    echo -n "DVD+ (4.7 billion bytes) = . . . . . . . . . . . " | tee -a $ERRLOG
    echo ". . . . . . . . . $S_CD" | tee -a $ERRLOG
  else
    echo -n "CD (650 MB) =  . . . . . . . . . . . . . . . . " | tee -a $ERRLOG
    echo ". . . . . . . . . . $S_CD" | tee -a $ERRLOG
  fi

  S_CD=$(expr $S_CD \* 2)
  echo -n "because of compression perhaps double size = . " | tee -a $ERRLOG
  echo ". . . . . . . . . . $S_CD" | tee -a $ERRLOG

  PROBLEM="SRCDISK does not fit on $TYP (Needed > $TYP)"
  if [ "$TYP" = "CD" ]; then
    PROBLEM="$PROBLEM
You can specify TYP=DVD instead of TYP=CD in bootcdwrite.conf."
  fi
  PROBLEM="$PROBLEM
You can exclude files/dirs in NOT_TO_CD in bootcdwrite.conf.
You can try to ignore this problem, if you only want an iso image."

  if [ $S_NEED_CD -gt $S_CD ]; then 
    warn "$PROBLEM"
  else
    echo "OK - SRCDISK does fit on $TYP (Needed <= $TYP)" | tee -a $ERRLOG 
  fi

  echo -n "VAR =  . . . . . . . . . . . . . . . . . . . . . " | tee -a $ERRLOG
  echo ". . . . . . . . . $S_VAR" | tee -a $ERRLOG
  if [ "$S_VAR" = "" ]; then
    warn "Could not guess the size of \"$VAR\" with df so assume enought space is available!"
  elif [ $S_NEED_CD -gt $S_VAR ]; then
    warn "Not enough space in $VAR (Needed > VAR)"
  else
    echo "OK - enough space in $VAR (Needed <= VAR)"  | tee -a $ERRLOG 
  fi
}

check_locatedb()
{
  LOCATEDB=""
  for i in $SRCDISK/var/cache/locate/locatedb \
           $SRCDISK/var/lib/locate/locatedb \
	   $SRCDISK/var/lib/locate/slocatedb
  do
    if [ -f $i ]; then
      LOCATEDB="$i"
      break
    fi
  done
}

find_mkisofs()
{
  MKISOFS=""
  if [ -f /usr/bin/genisoimage ]; then
    MKISOFS="/usr/bin/genisoimage"
  elif [ -f /usr/bin/mkisofs ]; then
    MKISOFS="/usr/bin/mkisofs"
  else
    err "Can not find mkisofs or genisoimage"
  fi
}