3 export PATH=/usr/bin:/bin:/usr/sbin:/sbin
5 INFORM_PATH=/mnt/inform
12 DIRNAME="/bin/dirname"
14 BLKID="/usr/sbin/blkid"
16 BOW_RESTORE="/sbin/bow-restore"
18 #------------------------------------------------
20 #------------------------------------------------
22 "$MOUNT" -t proc none /proc
23 "$MOUNT" -t sysfs none /sys
24 "$MOUNT" -t smackfs smackfs /smack
25 "$MOUNT" -t tmpfs tmpfs /run -o rw,nosuid,nodev,mode=755
26 "$MOUNT" -t tmpfs tmpfs /tmp -o mode=1777,smackfsroot=*
29 "$MOUNT" -t devpts devpts /dev/pts
32 #------------------------------------------------
34 #------------------------------------------------
36 PART_INFORM=$("$BLKID" -L "inform" -o device)
37 if [ "z$PART_INFORM" != "z" ]; then
38 "$MKDIR" -p ${INFORM_PATH}
39 "$MOUNT" -t ext4 ${PART_INFORM} ${INFORM_PATH}
43 #------------------------------------------------
45 #------------------------------------------------
47 dst_dir=`"$DIRNAME" "$1"`
48 if [ ! -d "$dst_dir" -a ! -L "$dst_dir" ]; then
49 "$MKDIR" -p "$dst_dir"
53 #------------------------------------------------
55 #------------------------------------------------
57 P_SLOT=$([[ $(</proc/cmdline) =~ partition_ab=([ab]) ]]; echo ${BASH_REMATCH[1]})
60 if [ "${P_SLOT}" != "" ]; then
62 echo "Using A/B slot: ${P_SLOT}"
65 PART_ROOTFS=`/sbin/blkid -t PARTLABEL=rootfs${P_SUFFIX} -o device`
66 if [ x$PART_ROOTFS = "x" ]
68 PART_ROOTFS=`/sbin/blkid -L rootfs`
71 PART_SYSTEM_DATA=`/sbin/blkid -t PARTLABEL=system-data -o device`
72 if [ x$PART_SYSTEM_DATA = "x" ]
74 PART_SYSTEM_DATA=`/sbin/blkid -L system-data`
77 PART_RAMDISK=`/sbin/blkid -t PARTLABEL=ramdisk${P_SUFFIX} -o device`
78 if [ x$PART_RAMDISK = "x" ]
80 PART_RAMDISK=`/sbin/blkid -L ramdisk`
83 PART_HAL=`/sbin/blkid -t PARTLABEL=hal${P_SUFFIX} -o device`
84 if [ x$PART_HAL = "x" ]
86 PART_HAL=`/sbin/blkid -L hal`
89 PART_USER=$("$BLKID" --match-token PARTLABEL=user -o device || "$BLKID" --match-token LABEL=user -o device)
92 #------------------------------------------------
94 #------------------------------------------------
96 if [ ! -e "/hal/.hal_list" ]; then
105 if [ ! -e $dst ]; then
109 done < /hal/.hal_list
111 PART_HAL=$("$BLKID" -t PARTLABEL="hal${P_SUFFIX}" -o device)
112 if [ "$need_copy" = "1" -a "z$PART_HAL" != "z" ]; then
114 "$MKDIR" -p ${HAL_PATH}
115 "$MOUNT" ${PART_HAL} ${HAL_PATH} -o ro
120 src="${HAL_PATH}/$file"
125 "$CP" -f "$src" "$dst"
127 done < /hal/.hal_list
130 "$UMOUNT" ${HAL_PATH}
134 #------------------------------------------------
136 #------------------------------------------------
148 #------------------------------------------------
150 #------------------------------------------------
151 restore_checkpoint() {
152 # Any existing checkpoint means that the RW update was unexpectedly
153 # aborded, so we must roll back the changes and update again.
154 echo "Checkpoint restore"
156 FS_TYPE="$(blkid -o value -s TYPE "${PART}")"
157 if [ "$FS_TYPE" = "ext4" ]; then
158 "$BOW_RESTORE" "${PART}"
160 echo "Checkpoint restore error: unknown filesystem ${FS_TYPE} on ${PART}"
164 #------------------------------------------------
166 #------------------------------------------------
167 restore_partitions() {
168 echo "Restore partitions"
169 . /usr/libexec/upgrade-support/upgrade-common.inc
170 if [[ "${P_SLOT}" == "" ]]
172 # We have only one slot, so it is likely that rootfs also has
174 restore_checkpoint "${PART_ROOTFS}"
175 if [ ! "z${PART_HAL}" = "z" ]; then
176 restore_checkpoint "${PART_HAL}"
179 if [ ! "z${PART_USER}" = "z" ]; then
180 restore_checkpoint "${PART_USER}"
182 if [ ! "z${PART_SYSTEM_DATA}" = "z" ]; then
183 restore_checkpoint "${PART_SYSTEM_DATA}"
187 #------------------------------------------------
189 #------------------------------------------------
190 echo "You entered into /sbin/init on initrd"
200 # Manually parse /proc/cmdline to avoid additional tools on image
201 read cmdline </proc/cmdline
202 echo "Kernel command line: $cmdline"
204 while [ $# -gt 0 ]; do
206 if [ "$key" = "bootmode" ]; then
213 if [ "z$BOOT_MODE" = "z" ]; then
214 echo "BOOT_MODE was NOT defined!!"
218 echo "BOOTMODE is ${BOOT_MODE}"
220 if [ -f /sbin/${BOOT_MODE}-init ]; then
221 exec "/sbin/${BOOT_MODE}-init"
223 echo "no ${BOOT_MODE}-init!!"