more forwardporting \o/
[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 diff --git a/scripts/boot/9990-aaa-fixme.sh b/scripts/boot/9990-aaa-fixme.sh
5 index 416d6b4..74517e8 100755
6 --- a/scripts/boot/9990-aaa-fixme.sh
7 +++ b/scripts/boot/9990-aaa-fixme.sh
8 @@ -40,7 +40,10 @@ else
9         udevinfo='udevinfo'
10  fi
11  
12 +old_root_overlay_label="live-rw"
13 +old_home_overlay_label="home-rw"
14  custom_overlay_label="persistence"
15 +old_custom_overlay_label="custom-ov"
16  persistence_list="persistence.conf"
17  old_persistence_list="live-persistence.conf"
18  
19 diff --git a/scripts/boot/9990-misc-helpers.sh b/scripts/boot/9990-misc-helpers.sh
20 index 5c5341c..addc82a 100755
21 --- a/scripts/boot/9990-misc-helpers.sh
22 +++ b/scripts/boot/9990-misc-helpers.sh
23 @@ -1553,6 +1553,32 @@ activate_custom_mounts ()
24         echo ${used_devices}
25  }
26  
27 +fix_backwards_compatibility ()
28 +{
29 +       local device dir opt backing include_list
30 +       device=${1}
31 +       dir=${2}
32 +       opt=${3}
33 +
34 +       if [ -n "${PERSISTENCE_READONLY}" ]
35 +       then
36 +               return
37 +       fi
38 +
39 +       backing="$(mount_persistence_media ${device})"
40 +       if [ -z "${backing}" ]
41 +       then
42 +               return
43 +       fi
44 +
45 +       include_list="${backing}/${persistence_list}"
46 +       if [ ! -r "${include_list}" ] && [ ! -r "${backing}/${old_persistence_list}" ]
47 +       then
48 +               echo "# persistence backwards compatibility:
49 +${dir} ${opt},source=." > "${include_list}"
50 +       fi
51 +}
52 +
53  is_mountpoint ()
54  {
55         directory="$1"
56 diff --git a/scripts/boot/9990-overlay.sh b/scripts/boot/9990-overlay.sh
57 index c6de171..4a080bc 100755
58 --- a/scripts/boot/9990-overlay.sh
59 +++ b/scripts/boot/9990-overlay.sh
60 @@ -210,7 +210,7 @@ setup_unionfs ()
61  
62                 if is_in_comma_sep_list overlay ${PERSISTENCE_METHOD}
63                 then
64 -                       overlays="${custom_overlay_label}"
65 +                       overlays="${old_root_overlay_label} ${old_home_overlay_label} ${custom_overlay_label} ${old_custom_overlay_label}"
66                 fi
67  
68                 local overlay_devices
69 @@ -222,10 +222,27 @@ setup_unionfs ()
70                                 media="$(echo ${media} | tr ":" " ")"
71  
72                                 case ${media} in
73 +                                       ${old_root_overlay_label}=*)
74 +                                               device="${media#*=}"
75 +                                               fix_backwards_compatibility ${device} / union
76 +                                               overlay_devices="${overlay_devices} ${device}"
77 +                                               ;;
78 +
79 +                                       ${old_home_overlay_label}=*)
80 +                                               device="${media#*=}"
81 +                                               fix_backwards_compatibility ${device} /home bind
82 +                                               overlay_devices="${overlay_devices} ${device}"
83 +                                               ;;
84 +
85                                         ${custom_overlay_label}=*)
86                                                 device="${media#*=}"
87                                                 overlay_devices="${overlay_devices} ${device}"
88                                                 ;;
89 +
90 +                                       ${old_custom_overlay_label}=*)
91 +                                               device="${media#*=}"
92 +                                               overlay_devices="${overlay_devices} ${device}"
93 +                                               ;;
94                                  esac
95                         done
96                 fi