~ubuntu-branches/ubuntu/hardy/silo/hardy-updates

« back to all changes in this revision

Viewing changes to debian/postinst

  • Committer: Bazaar Package Importer
  • Author(s): Fabio M. Di Nitto
  • Date: 2007-10-25 09:28:08 UTC
  • mfrom: (15.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071025092808-1yhj12t7s4zqsfu5
Tags: 1.4.13a+git20070930-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Build with -fno-stack-protector.
  - Change silo.postinst to automatically update the boot block without
    invoking siloconfig and keep asking questions on upgrades.
  - Convert silo.conf to use /dev/disk/by-uuid.
  - Ubuntu maintainer foobar.
  - Fix debian/rules call to dh_installdocs.
  - Drop the requirement of gcc-4.1 and start using default gcc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
set -e
 
4
 
 
5
convert_to_uuid() {
 
6
  line=$1
 
7
  byuuid=""
 
8
  root=$(echo "$line" | sed 's/.*root=//;s/ .*//')
 
9
  case "$root" in
 
10
    UUID=*|LABEL=*|/dev/disk/*|/dev/mapper/*|/dev/evms/*|/dev/md[0-9]*)
 
11
    ;;
 
12
    /dev/*)
 
13
      if [ -L "$root" ] && readlink "$root" | grep -q "^/dev/mapper/"
 
14
      then
 
15
        :
 
16
      elif [ -b "$root" ]; then
 
17
        uuid=$(/sbin/vol_id -u "$root" || true)
 
18
        if [ -n "$uuid" ]; then
 
19
          byuuid=$(echo "$line" | sed "s#\(.*root=\)[^ ]*#\1/dev/disk/by-uuid/$uuid#")
 
20
        fi
 
21
      fi
 
22
    ;;
 
23
  esac
 
24
  if [ -n "$byuuid" ]; then
 
25
    echo \# "$line"
 
26
    echo "$byuuid"
 
27
  else
 
28
    echo "$line"
 
29
  fi
 
30
}
 
31
 
 
32
convert_silo_conf() {
 
33
  if [ -f silo.conf.uuid ]; then
 
34
        return
 
35
  fi
 
36
  OLDIFS=${IFS}
 
37
  export IFS="Å"
 
38
  cat /boot/silo.conf | { while read line; do
 
39
        case "$line" in
 
40
                *root=*)
 
41
                        convert_to_uuid "$line" >> /boot/silo.conf.uuid
 
42
                ;;
 
43
                *)
 
44
                        echo $line >> /boot/silo.conf.uuid
 
45
                ;;
 
46
        esac
 
47
  done; }
 
48
  export IFS="${OLDIFS}"
 
49
  cp /boot/silo.conf /boot/silo.conf.pre-uuid
 
50
  cp /boot/silo.conf.uuid /boot/silo.conf
 
51
  rm /boot/silo.conf.uuid
 
52
}
 
53
 
 
54
# if we are upgrading there is no real need to invoke siloconfig
 
55
# and we just update.
 
56
if [ -n "$2" ] && [ -f /boot/silo.conf ]; then
 
57
  /sbin/silo -f
 
58
  if dpkg --compare-versions "$2" lt "1.4.13-1ubuntu5"; then
 
59
    convert_silo_conf
 
60
    /sbin/silo -f
 
61
  fi
 
62
else
 
63
  /usr/sbin/siloconfig
 
64
fi
 
65
 
 
66
#DEBHELPER#