Skip to content

Commit 02f02cb

Browse files
committed
Add coreutils to deps. Add dep checking to eeprom config
1 parent 6381463 commit 02f02cb

2 files changed

Lines changed: 106 additions & 47 deletions

File tree

picore-rpi-eeprom-config

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,62 @@
22

33
# piCore script to update Raspberry Pi4/5 boot EEPROM.
44

5-
usage() {
5+
function usage() {
66
echo "Usage:"
77
echo "$0 <options>"
88
echo ""
99
echo "The default firmware upgrade is from the critical firmware branch"
10-
echo " to override, set the FIRMWARE_RELEASE_STATUS environmen variable"
11-
echo " export FIRMWARE_RELEASE_STATUS=<default|latest>"
12-
echo ""
10+
echo " to override, set the FIRMWARE_RELEASE_STATUS environmen variable"
11+
echo " export FIRMWARE_RELEASE_STATUS=<default|latest>"
12+
echo ""
1313
echo "----------------------------------------------"
1414
echo ""
1515
echo "rpi-eeprom-config options"
1616
rpi-eeprom-config -h
1717
exit
1818
}
1919

20-
mount_boot_partition() {
21-
BOOTPART="$(tc_autoscan 'bootcode.bin' 'f')"
22-
BOOTDEV=${BOOTPART%%/*}
23-
find_mountpoint "$BOOTDEV"
24-
if [ -n "$MOUNTPOINT" ]; then
25-
mount $MOUNTPOINT
26-
fi
20+
function mount_boot_partition() {
21+
BOOTPART="$(tc_autoscan 'bootcode.bin' 'f')"
22+
BOOTDEV=${BOOTPART%%/*}
23+
find_mountpoint "$BOOTDEV"
24+
if [ -n "$MOUNTPOINT" ]; then
25+
mount $MOUNTPOINT
26+
fi
27+
}
28+
29+
function load_deps() {
30+
if [ ! -f ${PACKAGEDIR}/raspi-utils.tcz ]; then
31+
echo "raspi-utils extension is required for this tool"
32+
exit 1
33+
elif [ ! -f /usr/local/bin/vcgencmd ]; then
34+
tce-load -i raspi-utils.tcz
35+
fi
36+
37+
if [ ! -f ${PACKAGEDIR}/pciutils.tcz ]; then
38+
echo "pciutils extension is required for this tool"
39+
exit 1
40+
elif [ ! -f /usr/local/bin/lspci ]; then
41+
tce-load -i pciutils.tcz
42+
fi
43+
44+
[ -f ${PACKAGEDIR}/python3.11.tcz ] && PYTHON3PKG=python3.11.tcz
45+
[ -f ${PACKAGEDIR}/python3.12.tcz ] && PYTHON3PKG=python3.12.tcz
46+
if [ ! -f ${PACKAGEDIR}/$PYTHON3PKG ]; then
47+
echo "python 3 extension is required for this tool"
48+
exit 1
49+
elif [ ! -f /usr/local/bin/python3 ]; then
50+
tce-load -i $PYTHON3PKG
51+
fi
52+
53+
[ ! -x /usr/local/bin/python ] && sudo ln -s /usr/local/bin/python3 /usr/local/bin/python
54+
55+
if [ ! -f ${PACKAGEDIR}/coreutils.tcz ]; then
56+
echo "coreutils extension is required for this tool"
57+
exit 1
58+
elif [ ! -f /usr/local/bin/sha256sum ]; then
59+
tce-load -i coreutils.tcz
60+
fi
2761
}
2862

2963
OPTS=""
@@ -34,9 +68,22 @@ for A in $@; do
3468
esac
3569
done
3670

71+
load_deps
72+
3773
if [ "$OPTS" != "" ]; then
3874
#If No OPTS are present, then we don't need to mount to just display the current config
3975
mount_boot_partition >/dev/null 2>&1
4076
fi
4177
78+
[ -f ${PACKAGEDIR}/python3.11.tcz ] && PYTHON3PKG=python3.11.tcz
79+
[ -f ${PACKAGEDIR}/python3.12.tcz ] && PYTHON3PKG=python3.12.tcz
80+
if [ ! -f ${PACKAGEDIR}/$PYTHON3PKG ]; then
81+
echo "python 3 extension is required for this tool"
82+
exit 1
83+
elif [ ! -f /usr/local/bin/python3 ]; then
84+
tce-load -i $PYTHON3PKG
85+
fi
86+
87+
[ ! -x /usr/local/bin/python ] && sudo ln -s /usr/local/bin/python3 /usr/local/bin/python
88+
4289
sudo -E rpi-eeprom-config $OPTS

picore-rpi-eeprom-update

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PACKAGEDIR=/etc/sysconfig/tcedir/optional
99

1010
checknotroot
1111

12-
update_ext() {
12+
function update_ext() {
1313
WGET="busybox wget"
1414
DIFF="busybox diff"
1515
MD5="busybox md5sum"
@@ -25,44 +25,44 @@ update_ext() {
2525
$WGET -q https://github.com/tinycorelinux/rpi-eeprom/releases/latest/download/rpi-eeprom.tcz.md5.txt -P /tmp
2626
$DIFF -q /tmp/rpi-eeprom.tcz.md5.txt /etc/sysconfig/tcedir/optional/rpi-eeprom.tcz.md5.txt >/dev/null 2>&1
2727
if [ $? -eq 0 ]; then
28-
echo "[ INFO ] Extension version Matches"
29-
exit 2
28+
echo "[ INFO ] Extension version Matches"
29+
exit 2
3030
else
31-
echo "[ INFO ] Update Required."
32-
$WGET -q https://github.com/tinycorelinux/rpi-eeprom/releases/latest/download/rpi-eeprom.tcz -P /tmp
31+
echo "[ INFO ] Update Required."
32+
$WGET -q https://github.com/tinycorelinux/rpi-eeprom/releases/latest/download/rpi-eeprom.tcz -P /tmp
3333
fi
3434

3535
cd /tmp
3636
echo "[ INFO ] Validating MD5's of new extensions"
3737
$MD5 -cs rpi-eeprom.tcz.md5.txt
3838
[ -d $UPGRADE_DIR ] || mkdir -p $UPGRADE_DIR
3939
if [ $? -eq 0 ]; then
40-
mv -f /tmp/rpi-eeprom.tcz* ${UPGRADE_DIR}
40+
mv -f /tmp/rpi-eeprom.tcz* ${UPGRADE_DIR}
4141
else
42-
echo "[ERROR] rpi-eeprom.tcz failed md5 check."
43-
exit 1
42+
echo "[ERROR] rpi-eeprom.tcz failed md5 check."
43+
exit 1
4444
fi
4545

4646
echo "[ INFO ] A reboot is needed to load new rpi-eeprom extension."
4747
exit
4848
}
4949

50-
usage() {
50+
function usage() {
5151
echo "Usage:"
5252
echo "$0 --update: Update rpi-eeprom.tcz extension"
5353
echo ""
5454
echo "The default firmware upgrade is from the critical firmware branch"
5555
echo " to override, set the FIRMWARE_RELEASE_STATUS environmen variable"
5656
echo " export FIRMWARE_RELEASE_STATUS=<default|latest>"
57-
echo ""
57+
echo ""
5858
echo "----------------------------------------------"
5959
echo ""
6060
echo "rpi-eeprom-update options"
6161
rpi-eeprom-update -h
6262
exit
6363
}
6464

65-
mount_boot_partition() {
65+
function mount_boot_partition() {
6666
BOOTPART="$(tc_autoscan 'bootcode.bin' 'f')"
6767
BOOTDEV=${BOOTPART%%/*}
6868
find_mountpoint "$BOOTDEV"
@@ -71,6 +71,41 @@ mount_boot_partition() {
7171
fi
7272
}
7373

74+
75+
function load_deps() {
76+
if [ ! -f ${PACKAGEDIR}/raspi-utils.tcz ]; then
77+
echo "raspi-utils extension is required for this tool"
78+
exit 1
79+
elif [ ! -f /usr/local/bin/vcgencmd ]; then
80+
tce-load -i raspi-utils.tcz
81+
fi
82+
83+
if [ ! -f ${PACKAGEDIR}/pciutils.tcz ]; then
84+
echo "pciutils extension is required for this tool"
85+
exit 1
86+
elif [ ! -f /usr/local/bin/lspci ]; then
87+
tce-load -i pciutils.tcz
88+
fi
89+
90+
[ -f ${PACKAGEDIR}/python3.11.tcz ] && PYTHON3PKG=python3.11.tcz
91+
[ -f ${PACKAGEDIR}/python3.12.tcz ] && PYTHON3PKG=python3.12.tcz
92+
if [ ! -f ${PACKAGEDIR}/$PYTHON3PKG ]; then
93+
echo "python 3 extension is required for this tool"
94+
exit 1
95+
elif [ ! -f /usr/local/bin/python3 ]; then
96+
tce-load -i $PYTHON3PKG
97+
fi
98+
99+
[ ! -x /usr/local/bin/python ] && sudo ln -s /usr/local/bin/python3 /usr/local/bin/python
100+
101+
if [ ! -f ${PACKAGEDIR}/coreutils.tcz ]; then
102+
echo "coreutils extension is required for this tool"
103+
exit 1
104+
elif [ ! -f /usr/local/bin/sha256sum ]; then
105+
tce-load -i coreutils.tcz
106+
fi
107+
}
108+
74109
OPTS=""
75110
for A in $@; do
76111
case $A in
@@ -80,32 +115,9 @@ for A in $@; do
80115
esac
81116
done
82117

83-
mount_boot_partition >/dev/null 2>&1
118+
load_deps
84119

85-
if [ ! -f ${PACKAGEDIR}/raspi-utils.tcz ]; then
86-
echo "raspi-utils extension is required for this tool"
87-
exit 1
88-
elif [ ! -f /usr/local/bin/vcgencmd ]; then
89-
tce-load -i raspi-utils.tcz
90-
fi
91-
92-
if [ ! -f ${PACKAGEDIR}/pciutils.tcz ]; then
93-
echo "pciutils extension is required for this tool"
94-
exit 1
95-
elif [ ! -f /usr/local/bin/lspci ]; then
96-
tce-load -i pciutils.tcz
97-
fi
98-
99-
[ -f ${PACKAGEDIR}/python3.11.tcz ] && PYTHON3PKG=python3.11.tcz
100-
[ -f ${PACKAGEDIR}/python3.12.tcz ] && PYTHON3PKG=python3.12.tcz
101-
if [ ! -f ${PACKAGEDIR}/$PYTHON3PKG ]; then
102-
echo "python 3 extension is required for this tool"
103-
exit 1
104-
elif [ ! -f /usr/local/bin/python3 ]; then
105-
tce-load -i $PYTHON3PKG
106-
fi
107-
108-
[ ! -x /usr/local/bin/python ] && sudo ln -s /usr/local/bin/python3 /usr/local/bin/python
120+
mount_boot_partition >/dev/null 2>&1
109121

110122
echo "piCore rpi-eeprom package version: $VERSION"
111123
sudo -E rpi-eeprom-update $OPTS

0 commit comments

Comments
 (0)