c86ef88fab8c468870b38c98afb561f61bb62919
[live-boot-grml.git] / debian / patches / 42_restore_support_for_old_persistence.patch
1 From: Evgeni Golov <evgeni@debian.org>
2 Subject: restore support for old persistence media
3
4 --- a/scripts/boot/9990-aaa-fixme.sh
5 +++ b/scripts/boot/9990-aaa-fixme.sh
6 @@ -40,7 +40,10 @@
7         udevinfo='udevinfo'
8  fi
9  
10 +old_root_overlay_label="live-rw"
11 +old_home_overlay_label="home-rw"
12  custom_overlay_label="persistence"
13 +old_custom_overlay_label="custom-ov"
14  persistence_list="persistence.conf"
15  old_persistence_list="live-persistence.conf"
16  
17 --- a/scripts/boot/9990-misc-helpers.sh
18 +++ b/scripts/boot/9990-misc-helpers.sh
19 @@ -1582,6 +1582,32 @@
20         echo ${used_devices}
21  }
22  
23 +fix_backwards_compatibility ()
24 +{
25 +       local device dir opt backing include_list
26 +       device=${1}
27 +       dir=${2}
28 +       opt=${3}
29 +
30 +       if [ -n "${PERSISTENCE_READONLY}" ]
31 +       then
32 +               return
33 +       fi
34 +
35 +       backing="$(mount_persistence_media ${device})"
36 +       if [ -z "${backing}" ]
37 +       then
38 +               return
39 +       fi
40 +
41 +       include_list="${backing}/${persistence_list}"
42 +       if [ ! -r "${include_list}" ] && [ ! -r "${backing}/${old_persistence_list}" ]
43 +       then
44 +               echo "# persistence backwards compatibility:
45 +${dir} ${opt},source=." > "${include_list}"
46 +       fi
47 +}
48 +
49  is_mountpoint ()
50  {
51         directory="$1"
52 --- a/scripts/boot/9990-overlay.sh
53 +++ b/scripts/boot/9990-overlay.sh
54 @@ -210,7 +210,7 @@
55  
56                 if is_in_comma_sep_list overlay ${PERSISTENCE_METHOD}
57                 then
58 -                       overlays="${custom_overlay_label}"
59 +                       overlays="${old_root_overlay_label} ${old_home_overlay_label} ${custom_overlay_label} ${old_custom_overlay_label}"
60                 fi
61  
62                 local overlay_devices
63 @@ -222,10 +222,27 @@
64                                 media="$(echo ${media} | tr ":" " ")"
65  
66                                 case ${media} in
67 +                                       ${old_root_overlay_label}=*)
68 +                                               device="${media#*=}"
69 +                                               fix_backwards_compatibility ${device} / union
70 +                                               overlay_devices="${overlay_devices} ${device}"
71 +                                               ;;
72 +
73 +                                       ${old_home_overlay_label}=*)
74 +                                               device="${media#*=}"
75 +                                               fix_backwards_compatibility ${device} /home bind
76 +                                               overlay_devices="${overlay_devices} ${device}"
77 +                                               ;;
78 +
79                                         ${custom_overlay_label}=*)
80                                                 device="${media#*=}"
81                                                 overlay_devices="${overlay_devices} ${device}"
82                                                 ;;
83 +
84 +                                       ${old_custom_overlay_label}=*)
85 +                                               device="${media#*=}"
86 +                                               overlay_devices="${overlay_devices} ${device}"
87 +                                               ;;
88                                  esac
89                         done
90                 fi