~xnox/debian-cd/cleanup

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
#!/bin/sh

# This script tries to get good estimations into the .calc files at
# boot/$CODENAME/boot-$FULLARCH.calc, so you can use it whenever you want to
# update these .calc files with more recent estimations.

# It uses info taken from the temporary dir of a previous build for $FULLARCH,
# $CODENAME. This doesn't need to be a full build, you can get the needed
# stuff by running a build.sh with something like:
# IMAGETARGET="ok bootable upgrade bin-infos bin-list"

# Temporary directory of the previous build.
BDIR="$TDIR/$CODENAME-$FULLARCH"

#Get info from older build if it exists
if [ -d "$BDIR" ];
then
  echo Estimated sizes:
  rm -f "boot/$CODENAME/boot-$FULLARCH.calc"
  for i in `du -sm "$BDIR"/CD[0123456789]* |
              sed -n 's/^\([0-9]\+\).*CD\([0-9]\+\)/\2=\1/p'`
  do
    #space used by boot images in megs (this has an error of up to a mega)
    if [ -d "$BDIR/boot${i%=*}" ]
    then
      imgdu=`du -sm "$BDIR/boot${i%=*}" |
               sed -n 's/^\([0-9]\+\).*/\1/p'`
    else
      imgdu=1
    fi
    #add it all up and write it to the .calc file
    echo BOOT_SIZE_${i%=*}=${i#*=}+$imgdu
    echo BOOT_SIZE_${i%=*}=$((${i#*=}+$imgdu)) >> "boot/$CODENAME/boot-$FULLARCH.calc"
    case "$FULLARCH" in
      m68k)	echo SIZE_MULT_${i%=*}=97 >> "boot/$CODENAME/boot-$FULLARCH.calc";;
    esac
  done
fi

#Use different corrections depending on the size of the ISO
if [ -n "$SIZELIMIT1" ] && [ "$SIZELIMIT1" -gt 1000000000 ] || 
   [ -n "$SIZELIMIT" ] && [ "$SIZELIMIT" -gt 1000000000 ] ||
   [ -n "$DEFBINSIZE" ] && [ "$DEFBINSIZE" -gt 1000 ]
then
  case "$FULLARCH" in
    powerpc)     echo SIZE_MULT_1=92 >> "boot/$CODENAME/boot-$FULLARCH.calc";;
  esac
else
  case "$FULLARCH" in
    powerpc)     echo SIZE_MULT_1=96 >> "boot/$CODENAME/boot-$FULLARCH.calc";;
  esac
fi