Skip to content

Commit 85fe69c

Browse files
committed
od: od-update: Make OD beta -> OD beta upgrade working
1 parent d4bc20f commit 85fe69c

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

board/opendingux/opk_update_script.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,11 @@ clear
107107
echo 'Update in progress - please be patient.'
108108
echo
109109

110+
echo "$DEVICE" > /tmp/_force_thisdevice
110111
if [ "$(whoami)" = "root" -a ! -x /usr/sbin/od-update ]; then
111-
PATH=$(pwd):$PATH FORCE_DEVICE="$DEVICE" ./od-update $1
112+
./od-update $1
112113
else
113-
sudo PATH=$(pwd):$PATH FORCE_DEVICE="$DEVICE" od-update $1
114+
sudo od-update $1
114115
fi
115116

116117
# ----------

board/opendingux/target_skeleton/usr/bin/thisdevice

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ lepus;wolsen,ldkh ;LDK (horizontal);lepus;ldkh;
3434
END
3535
)
3636

37+
FORCE_DEVICE_FILE=/tmp/_force_thisdevice
38+
3739
if [ $# -le 0 ]; then
3840
display_usage
3941
exit 1
@@ -116,7 +118,11 @@ case $1 in
116118
echo 'DEVICE_STORAGE="'$STORAGE'"'
117119
;;
118120
--detect)
119-
detect_device
121+
if [ -r "$FORCE_DEVICE_FILE" ]; then
122+
cat "$FORCE_DEVICE_FILE"
123+
else
124+
detect_device
125+
fi
120126
;;
121127
*)
122128
echo "invalid command $1 (-h will show valid options)" 1>&2

board/opendingux/target_skeleton/usr/sbin/od-update

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
#!/bin/sh
22

3-
if [ $# -ne 1 ]; then
3+
if [ $# -lt 1 ]; then
44
echo -e "Incorrect number of parameters.
55
Usage:
66
\t$0 <data_dir>"
77
exit 1
88
fi
99

10-
if [ -z "$FORCE_DEVICE" ]; then
11-
DEVICE=$(thisdevice --detect)
12-
[ -z "$DEVICE" ] && DEVICE=undetected
10+
if [ -x ./thisdevice ]; then
11+
THISDEVICE=./thisdevice
1312
else
14-
DEVICE="$FORCE_DEVICE"
13+
THISDEVICE=$(which thisdevice 2> /dev/null)
1514
fi
1615

17-
DEVICEINFO=$(thisdevice --device "$DEVICE" 2> /dev/null)
16+
if [ -z "$THISDEVICE" ]; then
17+
echo "thisdevice utility can't be found"
18+
exit 12
19+
fi
20+
21+
DEVICE=$($THISDEVICE --detect)
22+
[ -z "$DEVICE" ] && DEVICE=undetected
23+
24+
DEVICEINFO=$($THISDEVICE --device "$DEVICE" 2> /dev/null)
1825
if [ $? -ne 0 ] ; then
1926
echo "Unknown device $DEVICE"
2027
exit 12
@@ -26,13 +33,13 @@ BOOTLD=$1/ubiboot-$DEVICE_BOOTLOADER.bin
2633
DEVICETREE=$1/$DEVICE_DEVICETREE.dtb
2734

2835
if [ ! -r "$BOOTLD" ]; then
29-
echo "Bootloader $2 does not exists"
36+
echo "Bootloader $DEVICE_BOOTLOADER does not exists"
3037
exit 13
3138
fi
3239

3340
[ ! -r $DEVICETREE ] && DEVICETREE=/sys/firmware/fdt
3441
if [ ! -r "$DEVICETREE" ]; then
35-
echo "Device tree $3 does not exists"
42+
echo "Device tree $DEVICE_DEVICETREE does not exists"
3643
exit 14
3744
fi
3845

@@ -99,7 +106,7 @@ if [ -r $ROOTFS -a "$0" != "/tmp/od-update" ] ; then
99106
umount $MNT
100107

101108
# Run the updated od-update script from the rootfs
102-
exec /tmp/od-update $*
109+
exec /tmp/od-update "$@"
103110
else
104111
umount $MNT
105112
fi

0 commit comments

Comments
 (0)