Skip to content

Commit c22805b

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

2 files changed

Lines changed: 25 additions & 12 deletions

File tree

board/opendingux/opk_update_script.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,13 @@ echo 'Update in progress - please be patient.'
108108
echo
109109

110110
if [ "$(whoami)" = "root" -a ! -x /usr/sbin/od-update ]; then
111-
PATH=$(pwd):$PATH FORCE_DEVICE="$DEVICE" ./od-update $1
111+
./od-update "$1" "$DEVICE"
112112
else
113-
sudo PATH=$(pwd):$PATH FORCE_DEVICE="$DEVICE" od-update $1
113+
# Old firmware's od-update requires equally one argument
114+
# and ENV variables are restricted by sudo
115+
# so the only way to pass the device is via a tmp file
116+
echo "$DEVICE" > /tmp/_force_thisdevice
117+
sudo od-update $1
114118
fi
115119

116120
# ----------

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

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

3-
if [ $# -ne 1 ]; then
3+
if [ $# -lt 1 ]; then
44
echo -e "Incorrect number of parameters.
55
Usage:
6-
\t$0 <data_dir>"
6+
\t$0 <data_dir> [device]"
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+
[ -z "$DEVICE" ] && DEVICE=$2
22+
[ -z "$DEVICE" -a -r /tmp/_force_thisdevice ] && DEVICE=$(cat /tmp/_force_thisdevice)
23+
[ -z "$DEVICE" ] && DEVICE=$($THISDEVICE --detect)
24+
[ -z "$DEVICE" ] && DEVICE=undetected
25+
26+
DEVICEINFO=$($THISDEVICE --device "$DEVICE" 2> /dev/null)
1827
if [ $? -ne 0 ] ; then
1928
echo "Unknown device $DEVICE"
2029
exit 12
@@ -26,13 +35,13 @@ BOOTLD=$1/ubiboot-$DEVICE_BOOTLOADER.bin
2635
DEVICETREE=$1/$DEVICE_DEVICETREE.dtb
2736

2837
if [ ! -r "$BOOTLD" ]; then
29-
echo "Bootloader $2 does not exists"
38+
echo "Bootloader $DEVICE_BOOTLOADER does not exists"
3039
exit 13
3140
fi
3241

3342
[ ! -r $DEVICETREE ] && DEVICETREE=/sys/firmware/fdt
3443
if [ ! -r "$DEVICETREE" ]; then
35-
echo "Device tree $3 does not exists"
44+
echo "Device tree $DEVICE_DEVICETREE does not exists"
3645
exit 14
3746
fi
3847

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

101110
# Run the updated od-update script from the rootfs
102-
exec /tmp/od-update $*
111+
exec /tmp/od-update "$@"
103112
else
104113
umount $MNT
105114
fi

0 commit comments

Comments
 (0)