4 .
/lib
/functions
/system.sh
13 export SAVE_PARTITIONS
=1
17 export CONFFILES
=/tmp
/sysupgrade.conffiles
18 export CONF_TAR
=/tmp
/sysupgrade.tgz
21 [ -f "$CONF_TAR" ] ||
export SAVE_CONFIG
=0
22 [ -f /tmp
/sysupgrade.always.overwrite.bootdisk.partmap
] && export SAVE_PARTITIONS
=0
27 supivot
() { # <new_root> <old_root>
28 /bin
/mount |
grep "on $1 type" 2>&- 1>&- ||
/bin
/mount
-o bind $1 $1
29 mkdir
-p $1$2 $1/proc
$1/sys
$1/dev
$1/tmp
$1/overlay
&& \
30 /bin
/mount
-o noatime
,move
/proc
$1/proc
&& \
31 pivot_root
$1 $1$2 ||
{
36 /bin
/mount
-o noatime
,move
$2/sys
/sys
37 /bin
/mount
-o noatime
,move
$2/dev
/dev
38 /bin
/mount
-o noatime
,move
$2/tmp
/tmp
39 /bin
/mount
-o noatime
,move
$2/overlay
/overlay
2>&-
44 install_bin
/bin
/busybox
/bin
/ash
/bin
/sh
/bin
/mount
/bin
/umount \
45 /sbin
/pivot_root
/sbin
/reboot
/bin
/sync
/bin
/dd /bin
/grep \
46 /bin
/cp /bin
/mv /bin
/tar /usr
/bin
/md5sum "/usr/bin/[" /bin
/dd \
47 /bin
/vi
/bin
/ls /bin
/cat /usr
/bin
/awk /usr
/bin
/hexdump \
48 /bin
/sleep /bin
/zcat
/usr
/bin
/bzcat
/usr
/bin
/printf /usr
/bin
/wc \
49 /bin
/cut
/usr
/bin
/printf /bin
/sync
/bin
/mkdir
/bin
/rmdir \
50 /bin
/rm /usr
/bin
/basename /bin
/kill /bin
/chmod /usr
/bin
/find \
54 install_bin
/sbin
/mount_root
55 install_bin
/sbin
/snapshot
56 install_bin
/sbin
/snapshot_tool
57 install_bin
/usr
/sbin
/ubiupdatevol
58 install_bin
/usr
/sbin
/ubiattach
59 install_bin
/usr
/sbin
/ubiblock
60 install_bin
/usr
/sbin
/ubiformat
61 install_bin
/usr
/sbin
/ubidetach
62 install_bin
/usr
/sbin
/ubirsvol
63 install_bin
/usr
/sbin
/ubirmvol
64 install_bin
/usr
/sbin
/ubimkvol
65 install_bin
/usr
/sbin
/partx
66 install_bin
/usr
/sbin
/losetup
67 install_bin
/usr
/sbin
/mkfs.ext4
68 for file in $RAMFS_COPY_BIN; do
69 install_bin
${file//:/ }
71 install_file
/etc
/resolv.conf
/lib
/*.sh
/lib
/functions
/*.sh
/lib
/upgrade
/*.sh
$RAMFS_COPY_DATA
73 [ -L "/lib64" ] && ln -s /lib
$RAM_ROOT/lib64
75 supivot
$RAM_ROOT /mnt ||
{
76 echo "Failed to switch over to ramfs. Please reboot."
80 /bin
/mount
-o remount
,ro
/mnt
83 grep /overlay
/proc
/mounts
> /dev
/null
&& {
84 /bin
/mount
-o noatime
,remount
,ro
/overlay
85 /bin
/umount
-l /overlay
89 kill_remaining
() { # [ <signal> [ <loop> ] ]
90 local sig
="${1:-TERM}"
95 echo -n "Sending $sig to remaining processes ... "
99 for stat
in /proc
/[0-9]*/stat
; do
100 [ -f "$stat" ] ||
continue
102 local pid name state ppid rest
103 read pid name state ppid rest
< $stat
104 name
="${name#(}"; name
="${name%)}"
106 # Skip PID1, ourself and our children
107 [ $pid -ne 1 -a $pid -ne $$
-a $ppid -ne $$
] ||
continue
110 read cmdline
< /proc
/$pid/cmdline
112 # Skip kernel threads
113 [ -n "$cmdline" ] ||
continue
116 kill -$sig $pid 2>/dev
/null
118 [ $loop -eq 1 ] && run
=true
131 kill_remaining KILL
1
136 if [ -n "$IMAGE" ] && type 'platform_pre_upgrade' >/dev
/null
2>/dev
/null
; then
137 IS_PRE_UPGRADE
=1 platform_pre_upgrade
"$IMAGE"
139 # Needs to be unset again because of busybox weirdness ...
143 if [ -n "$(rootfs_type)" ]; then
144 echo "Switching to ramdisk..."
148 # Exec new shell from ramfs
149 exec /bin
/busybox ash
-c "$COMMAND"